SlideShare a Scribd company logo
1 of 9
Microsoft® Small Basic Collision Detection Estimated time to complete this lesson: 1 hour
Collision Detection In this lesson, you will learn about: Using the concept of collision detection in games.
What is Collision Detection? Now let’s talk about collision detection in games. In general, collision detection is about determining the intersection of two moving objects. Collision detection in games takes place in the following steps: ,[object Object]
 Checking whether a collision occurred between the identified objects or not.,[object Object]
 Hit the Target – The Game You use the logic of collision detection to detect the collision between the turtle and the target. The game ends as soon as the two objects collide. The game involves two objects: the turtle and the target. The player has to make the turtle hit the target by entering the correct angle and the distance. Now that you have understood the concept of collision detection in games, let’s make a game that uses the logic of collision detection.
Hit the Target – How to Play It’s time to play the game! Steps to play the game: ,[object Object]
Enter the distance that the turtle needs to cover to hit the target.
Click the ‘Hit’ button to hit the target.
Click the ‘Reset’ button to reset the position of the target.,[object Object]

More Related Content

What's hot

Computer Coding with Scratch: Lesson 2_primaryschoollessons
Computer Coding with Scratch: Lesson 2_primaryschoollessonsComputer Coding with Scratch: Lesson 2_primaryschoollessons
Computer Coding with Scratch: Lesson 2_primaryschoollessonsSeniorInfants
 
Programming in scratch
Programming in scratchProgramming in scratch
Programming in scratchHussam Mostafa
 
Coding Basics with Scratch
Coding Basics with ScratchCoding Basics with Scratch
Coding Basics with ScratchNicole Baratta
 
Scratch programming introduction to game creation
Scratch programming  introduction to game creationScratch programming  introduction to game creation
Scratch programming introduction to game creationAnkita Shirke
 
2.3 exploring shapes
2.3   exploring shapes2.3   exploring shapes
2.3 exploring shapesallenbailey
 
Scratch Lesson 1 – Basics
Scratch Lesson 1 – BasicsScratch Lesson 1 – Basics
Scratch Lesson 1 – BasicsDavid Oromaner
 
Information technology
Information technologyInformation technology
Information technologyAthiAtheeswari
 
Information technology
Information technologyInformation technology
Information technologypanchukrishnan
 
Arcade Game Design with Sploder - Library Program
Arcade Game Design with Sploder - Library ProgramArcade Game Design with Sploder - Library Program
Arcade Game Design with Sploder - Library ProgramRino Landa
 
6. production reflection(2)
6. production reflection(2)6. production reflection(2)
6. production reflection(2)rhiannah baker
 
Lesson three presentation
Lesson three presentationLesson three presentation
Lesson three presentationsutt202
 
Houchens jeffrey secret helper gdd
Houchens jeffrey secret helper gddHouchens jeffrey secret helper gdd
Houchens jeffrey secret helper gddjhouchens99
 

What's hot (20)

Computer Coding with Scratch: Lesson 2_primaryschoollessons
Computer Coding with Scratch: Lesson 2_primaryschoollessonsComputer Coding with Scratch: Lesson 2_primaryschoollessons
Computer Coding with Scratch: Lesson 2_primaryschoollessons
 
Programming in scratch
Programming in scratchProgramming in scratch
Programming in scratch
 
Scratch Animation
Scratch AnimationScratch Animation
Scratch Animation
 
3 Kodu
3 Kodu3 Kodu
3 Kodu
 
Coding Basics with Scratch
Coding Basics with ScratchCoding Basics with Scratch
Coding Basics with Scratch
 
Scratch programming introduction to game creation
Scratch programming  introduction to game creationScratch programming  introduction to game creation
Scratch programming introduction to game creation
 
Scratch an Editing App
 Scratch  an Editing App  Scratch  an Editing App
Scratch an Editing App
 
Scratch Lesson 5
Scratch Lesson 5Scratch Lesson 5
Scratch Lesson 5
 
Kodu
KoduKodu
Kodu
 
2.3 exploring shapes
2.3   exploring shapes2.3   exploring shapes
2.3 exploring shapes
 
Scratch Lesson 6
Scratch Lesson 6Scratch Lesson 6
Scratch Lesson 6
 
Scratch Lesson 1 – Basics
Scratch Lesson 1 – BasicsScratch Lesson 1 – Basics
Scratch Lesson 1 – Basics
 
Scratch Programming
Scratch ProgrammingScratch Programming
Scratch Programming
 
Lasso tool
Lasso toolLasso tool
Lasso tool
 
Information technology
Information technologyInformation technology
Information technology
 
Information technology
Information technologyInformation technology
Information technology
 
Arcade Game Design with Sploder - Library Program
Arcade Game Design with Sploder - Library ProgramArcade Game Design with Sploder - Library Program
Arcade Game Design with Sploder - Library Program
 
6. production reflection(2)
6. production reflection(2)6. production reflection(2)
6. production reflection(2)
 
Lesson three presentation
Lesson three presentationLesson three presentation
Lesson three presentation
 
Houchens jeffrey secret helper gdd
Houchens jeffrey secret helper gddHouchens jeffrey secret helper gdd
Houchens jeffrey secret helper gdd
 

Similar to 4.3 collision detection

Unity - Building your first real-time 3D project
Unity - Building your first real-time 3D projectUnity - Building your first real-time 3D project
Unity - Building your first real-time 3D projectNexusEdgesupport
 
Unity - Building Your First Real-Time 3D Project - All Slides
Unity - Building Your First Real-Time 3D Project - All SlidesUnity - Building Your First Real-Time 3D Project - All Slides
Unity - Building Your First Real-Time 3D Project - All SlidesNexusEdgesupport
 
Run and jump tutorial (part 1) actors
Run and jump tutorial (part 1)   actorsRun and jump tutorial (part 1)   actors
Run and jump tutorial (part 1) actorsMuhd Basheer
 
Run and jump tutorial (part 2) scenes
Run and jump tutorial (part 2)   scenesRun and jump tutorial (part 2)   scenes
Run and jump tutorial (part 2) scenesMuhd Basheer
 
Excite artificial intelligence Class 9
Excite artificial intelligence Class 9Excite artificial intelligence Class 9
Excite artificial intelligence Class 9TutorialAICSIP
 
GameMaker 1) intro to gamemaker
GameMaker 1) intro to gamemakerGameMaker 1) intro to gamemaker
GameMaker 1) intro to gamemakeriain bruce
 
Scratch for kids syllabus for 5 hours by bibek pandit
Scratch for kids syllabus for 5 hours by bibek panditScratch for kids syllabus for 5 hours by bibek pandit
Scratch for kids syllabus for 5 hours by bibek panditBibekPandit2
 
Introduction to Game Programming: Using C# and Unity 3D - Chapter 2 (Preview)
Introduction to Game Programming: Using C# and Unity 3D - Chapter 2 (Preview)Introduction to Game Programming: Using C# and Unity 3D - Chapter 2 (Preview)
Introduction to Game Programming: Using C# and Unity 3D - Chapter 2 (Preview)noorcon
 
Gamemaker lesson 1
Gamemaker lesson 1Gamemaker lesson 1
Gamemaker lesson 1iain bruce
 
Run and jump tutorial (part 3) behaviours
Run and jump tutorial (part 3)   behavioursRun and jump tutorial (part 3)   behaviours
Run and jump tutorial (part 3) behavioursMuhd Basheer
 
How tomakea gameinunity3d
How tomakea gameinunity3dHow tomakea gameinunity3d
How tomakea gameinunity3dDao Tung
 
ITS488 Lecture 4: Google VR Cardboard Game Development: Basket Ball Game #2
ITS488 Lecture 4: Google VR Cardboard Game Development: Basket Ball Game #2ITS488 Lecture 4: Google VR Cardboard Game Development: Basket Ball Game #2
ITS488 Lecture 4: Google VR Cardboard Game Development: Basket Ball Game #2Kobkrit Viriyayudhakorn
 
Up cloth - GameDesignDoccument
Up cloth - GameDesignDoccumentUp cloth - GameDesignDoccument
Up cloth - GameDesignDoccumentEléonore Arbaux
 
Lecture 4: ITS488 Digital Content Creation with Unity - Game and VR Programming
Lecture 4: ITS488 Digital Content Creation with Unity - Game and VR Programming Lecture 4: ITS488 Digital Content Creation with Unity - Game and VR Programming
Lecture 4: ITS488 Digital Content Creation with Unity - Game and VR Programming Kobkrit Viriyayudhakorn
 
How to Design Effective Learning Games: Sharon Boller and Karl Kapp
How to Design Effective Learning Games: Sharon Boller and Karl KappHow to Design Effective Learning Games: Sharon Boller and Karl Kapp
How to Design Effective Learning Games: Sharon Boller and Karl KappSharon Boller
 
Work Flow for 2D Game
Work Flow for 2D GameWork Flow for 2D Game
Work Flow for 2D Gamebowes96123
 

Similar to 4.3 collision detection (20)

Unity - Building your first real-time 3D project
Unity - Building your first real-time 3D projectUnity - Building your first real-time 3D project
Unity - Building your first real-time 3D project
 
A mazing Game
A mazing GameA mazing Game
A mazing Game
 
Unity - Building Your First Real-Time 3D Project - All Slides
Unity - Building Your First Real-Time 3D Project - All SlidesUnity - Building Your First Real-Time 3D Project - All Slides
Unity - Building Your First Real-Time 3D Project - All Slides
 
Run and jump tutorial (part 1) actors
Run and jump tutorial (part 1)   actorsRun and jump tutorial (part 1)   actors
Run and jump tutorial (part 1) actors
 
Run and jump tutorial (part 2) scenes
Run and jump tutorial (part 2)   scenesRun and jump tutorial (part 2)   scenes
Run and jump tutorial (part 2) scenes
 
Excite artificial intelligence Class 9
Excite artificial intelligence Class 9Excite artificial intelligence Class 9
Excite artificial intelligence Class 9
 
02 unity 3_d_part_1
02 unity 3_d_part_102 unity 3_d_part_1
02 unity 3_d_part_1
 
GameMaker 1) intro to gamemaker
GameMaker 1) intro to gamemakerGameMaker 1) intro to gamemaker
GameMaker 1) intro to gamemaker
 
intern.pdf
intern.pdfintern.pdf
intern.pdf
 
Scratch for kids syllabus for 5 hours by bibek pandit
Scratch for kids syllabus for 5 hours by bibek panditScratch for kids syllabus for 5 hours by bibek pandit
Scratch for kids syllabus for 5 hours by bibek pandit
 
Introduction to Game Programming: Using C# and Unity 3D - Chapter 2 (Preview)
Introduction to Game Programming: Using C# and Unity 3D - Chapter 2 (Preview)Introduction to Game Programming: Using C# and Unity 3D - Chapter 2 (Preview)
Introduction to Game Programming: Using C# and Unity 3D - Chapter 2 (Preview)
 
Gamemaker lesson 1
Gamemaker lesson 1Gamemaker lesson 1
Gamemaker lesson 1
 
Pres.p game.2
Pres.p game.2Pres.p game.2
Pres.p game.2
 
Run and jump tutorial (part 3) behaviours
Run and jump tutorial (part 3)   behavioursRun and jump tutorial (part 3)   behaviours
Run and jump tutorial (part 3) behaviours
 
How tomakea gameinunity3d
How tomakea gameinunity3dHow tomakea gameinunity3d
How tomakea gameinunity3d
 
ITS488 Lecture 4: Google VR Cardboard Game Development: Basket Ball Game #2
ITS488 Lecture 4: Google VR Cardboard Game Development: Basket Ball Game #2ITS488 Lecture 4: Google VR Cardboard Game Development: Basket Ball Game #2
ITS488 Lecture 4: Google VR Cardboard Game Development: Basket Ball Game #2
 
Up cloth - GameDesignDoccument
Up cloth - GameDesignDoccumentUp cloth - GameDesignDoccument
Up cloth - GameDesignDoccument
 
Lecture 4: ITS488 Digital Content Creation with Unity - Game and VR Programming
Lecture 4: ITS488 Digital Content Creation with Unity - Game and VR Programming Lecture 4: ITS488 Digital Content Creation with Unity - Game and VR Programming
Lecture 4: ITS488 Digital Content Creation with Unity - Game and VR Programming
 
How to Design Effective Learning Games: Sharon Boller and Karl Kapp
How to Design Effective Learning Games: Sharon Boller and Karl KappHow to Design Effective Learning Games: Sharon Boller and Karl Kapp
How to Design Effective Learning Games: Sharon Boller and Karl Kapp
 
Work Flow for 2D Game
Work Flow for 2D GameWork Flow for 2D Game
Work Flow for 2D Game
 

More from allenbailey

5.1 sharing code
5.1   sharing code5.1   sharing code
5.1 sharing codeallenbailey
 
3.6 debugging aids
3.6   debugging aids3.6   debugging aids
3.6 debugging aidsallenbailey
 
3.5 the controls object
3.5   the controls object3.5   the controls object
3.5 the controls objectallenbailey
 
3.4 events and interactivity
3.4   events and interactivity3.4   events and interactivity
3.4 events and interactivityallenbailey
 
3.3 the math object
3.3   the math object3.3   the math object
3.3 the math objectallenbailey
 
3.2 stacks and arrays
3.2   stacks and arrays3.2   stacks and arrays
3.2 stacks and arraysallenbailey
 
3.1 file input and output
3.1   file input and output3.1   file input and output
3.1 file input and outputallenbailey
 
2.6 flickr, image list, and network objects
2.6   flickr, image list, and network objects2.6   flickr, image list, and network objects
2.6 flickr, image list, and network objectsallenbailey
 
2.5 clock, desktop, and dictionary objects
2.5   clock, desktop, and dictionary objects2.5   clock, desktop, and dictionary objects
2.5 clock, desktop, and dictionary objectsallenbailey
 
2.4 sound, program, and text objects
2.4   sound, program, and text objects2.4   sound, program, and text objects
2.4 sound, program, and text objectsallenbailey
 
2.2 turtle graphics
2.2   turtle graphics2.2   turtle graphics
2.2 turtle graphicsallenbailey
 
2.1 graphics window
2.1   graphics window2.1   graphics window
2.1 graphics windowallenbailey
 
1.5 branching and subroutines
1.5   branching and subroutines1.5   branching and subroutines
1.5 branching and subroutinesallenbailey
 
1.4 conditions and loops
1.4   conditions and loops1.4   conditions and loops
1.4 conditions and loopsallenbailey
 
1.2 statements, properties, and operations
1.2   statements, properties, and operations1.2   statements, properties, and operations
1.2 statements, properties, and operationsallenbailey
 
1.1 introduction to small basic
1.1   introduction to small basic1.1   introduction to small basic
1.1 introduction to small basicallenbailey
 

More from allenbailey (17)

5.1 sharing code
5.1   sharing code5.1   sharing code
5.1 sharing code
 
3.6 debugging aids
3.6   debugging aids3.6   debugging aids
3.6 debugging aids
 
3.5 the controls object
3.5   the controls object3.5   the controls object
3.5 the controls object
 
3.4 events and interactivity
3.4   events and interactivity3.4   events and interactivity
3.4 events and interactivity
 
3.3 the math object
3.3   the math object3.3   the math object
3.3 the math object
 
3.2 stacks and arrays
3.2   stacks and arrays3.2   stacks and arrays
3.2 stacks and arrays
 
3.1 file input and output
3.1   file input and output3.1   file input and output
3.1 file input and output
 
2.6 flickr, image list, and network objects
2.6   flickr, image list, and network objects2.6   flickr, image list, and network objects
2.6 flickr, image list, and network objects
 
2.5 clock, desktop, and dictionary objects
2.5   clock, desktop, and dictionary objects2.5   clock, desktop, and dictionary objects
2.5 clock, desktop, and dictionary objects
 
2.4 sound, program, and text objects
2.4   sound, program, and text objects2.4   sound, program, and text objects
2.4 sound, program, and text objects
 
2.2 turtle graphics
2.2   turtle graphics2.2   turtle graphics
2.2 turtle graphics
 
2.1 graphics window
2.1   graphics window2.1   graphics window
2.1 graphics window
 
1.5 branching and subroutines
1.5   branching and subroutines1.5   branching and subroutines
1.5 branching and subroutines
 
1.4 conditions and loops
1.4   conditions and loops1.4   conditions and loops
1.4 conditions and loops
 
1.3 variables
1.3   variables1.3   variables
1.3 variables
 
1.2 statements, properties, and operations
1.2   statements, properties, and operations1.2   statements, properties, and operations
1.2 statements, properties, and operations
 
1.1 introduction to small basic
1.1   introduction to small basic1.1   introduction to small basic
1.1 introduction to small basic
 

Recently uploaded

What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embeddingZilliz
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfSeasiaInfotech2
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 

Recently uploaded (20)

What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embedding
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdf
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 

4.3 collision detection

  • 1. Microsoft® Small Basic Collision Detection Estimated time to complete this lesson: 1 hour
  • 2. Collision Detection In this lesson, you will learn about: Using the concept of collision detection in games.
  • 3.
  • 4.
  • 5. Hit the Target – The Game You use the logic of collision detection to detect the collision between the turtle and the target. The game ends as soon as the two objects collide. The game involves two objects: the turtle and the target. The player has to make the turtle hit the target by entering the correct angle and the distance. Now that you have understood the concept of collision detection in games, let’s make a game that uses the logic of collision detection.
  • 6.
  • 7. Enter the distance that the turtle needs to cover to hit the target.
  • 8. Click the ‘Hit’ button to hit the target.
  • 9.
  • 10. Next, use the Controls object to add a click button and text box and set the size of control buttons.
  • 11. Use the Shapes object to add an image of the shape, and to move and animate the shape and set its opacity level.
  • 12.
  • 13. It’s Time to Apply Your Learning… Using the concept of collision detection, create a game that involves two objects: a bucket and apples. The apples fall randomly from the top of the screen. The player tries to catch the apples in the bucket. The game runs for 30 seconds. Include a score board to display the total number of apples caught by the player in 30 seconds. Your game should look somewhat like the following.

Editor's Notes

  1. Code:' Copyright (c) Microsoft Corporation. All rights reserved.GraphicsWindow.Hide()gw = 620gh = 450GraphicsWindow.BackgroundColor = "LightBlue"GraphicsWindow.CanResize = "False"GraphicsWindow.Width = gwGraphicsWindow.Height = ghGraphicsWindow.Top = ( Desktop.Height - gh ) / 2GraphicsWindow.Left = ( Desktop.Width - gw ) / 2GraphicsWindow.Title = "Hit the Target"GraphicsWindow.Show()Turtle.Hide()rx = 40ry = 20turtlex = 315turtley = 300width = 550height = 390ScoreboxX = 400Enterkey = "Return"target = 10life = 3score = 0GraphicsWindow.FontSize = 30GraphicsWindow.DrawText(100, 200, "Press ENTER to start the game!")GraphicsWindow.KeyDown = OnpressSub Onpress enter = enter + 1If GraphicsWindow.LastKey = Enterkey And enter = 1 ThenGraphicsWindow.Clear()GraphicsWindow.FontSize = 12 GUI()MovingShape()ScoreShow()Controls.ButtonClicked = hitClickEndIfEndSubSub hitClick angle = Math.Round(Controls.GetTextBoxText(angletxt)) distance = Math.Round(Controls.GetTextBoxText(distancetxt)) clicked = Controls.GetButtonCaption(Controls.LastClickedButton) If clicked = "Hit" ThenGraphicsWindow.PenWidth = 0Turtle.Angle = angleTurtle.Move(distance)If Turtle.x > x and Turtle.x < x + 93 and Turtle.y > y and Turtle.y < y + 96 ThenShapes.HideShape(target) score = score + 10 scoreshow()Program.Delay(500)If target = score ThenGameEnd()EndIfControls.SetTextBoxText(angletxt, "")Controls.SetTextBoxText(distancetxt, "")MovingShape()ElseProgram.Delay(1000)If life > 1 ThenGraphicsWindow.ShowMessage("Click Ok to continue the game","Reset") clicked = "Reset"Else GameEnd()EndIfEndIfEndIfIf clicked = "Reset" Then life = life - 1If score >= 10 Then score = score - 5EndIfscoreshow()Controls.SetTextBoxText(angletxt, "")Controls.SetTextBoxText(distancetxt, "")MovingShape() If life < 1 ThenGameEnd()EndIfEndIfEndSubSub GUI image = Program.Directory + "cartoon.gif" GraphicsWindow.DrawRectangle(rx, ry, width, height) target = Shapes.AddImage(image) GraphicsWindow.BrushColor = "Black"Shapes.Move(target, 100, 50) Turtle.Show()Turtle.X = turtlexTurtle.y = turtleyTurtle.Angle = 0GraphicsWindow.DrawText(rx + 5, height - 10, "Enter Angle:")angletxt = Controls.AddTextBox(turtlex - 190, Turtley + 70)Controls.SetSize(angletxt, 40, 30) GraphicsWindow.DrawText(rx + 130, height - 10, "Enter Distance:")distancetxt = Controls.AddTextBox(turtlex - 50, Turtley + 70)Controls.SetSize(distancetxt, 40, 30) firebutton = Controls.AddButton("Hit", turtlex + 20, Turtley + 70) Controls.SetSize(firebutton, 80, 30) EndsubSub MovingShapeShapes.ShowShape(target)Turtle.x = turtlexTurtle.Y = turtleyTurtle.Angle = 0 x = Math.GetRandomNumber(450) y = Math.GetRandomNumber(80)If x <= 40 Then x = 40Shapes.Animate(target, x, y, 1000)ElseIf y <= 20 Then y = 20Shapes.Animate(target, x, y, 1000)Else Shapes.Animate(target, x, y, 1000)EndIfEndSubSub GameEndGraphicsWindow.ShowMessage("Your score is:" + score, "Game Over") Program.End()EndSubSub ScoreShowGraphicsWindow.FontSize = 14GraphicsWindow.BrushColor = "Gray"GraphicsWindow.FillRectangle(ScoreboxX + 50, ScoreboxX - 65, 135, 70) GraphicsWindow.BrushColor = "White"GraphicsWindow.DrawText(ScoreboxX + 60, ScoreboxX - 55, "Score :")GraphicsWindow.DrawText(ScoreboxX + 110, ScoreboxX - 55, score)GraphicsWindow.DrawText(ScoreboxX + 60, ScoreboxX - 20, "Life :")GraphicsWindow.DrawText(ScoreboxX + 110, ScoreboxX - 20, life) EndSub
  2. Code: ' Copyright (c) Microsoft Corporation. All rights reserved.GraphicsWindow.Hide()gw = 620gh = 450GraphicsWindow.CanResize = "False"GraphicsWindow.Width = gwGraphicsWindow.Height = ghGraphicsWindow.Top = (Desktop.Height - gh) / 2GraphicsWindow.Left = (Desktop.Width - gw) / 2GraphicsWindow.Title = "Catch the Apples!"GraphicsWindow.Show()applesLeft = 30gameScore = 0catcherImage = Program.Directory + "catcher.jpg"appleimage = Program.Directory + "apple.jpg"GraphicsWindow.MouseMove = OnMouseMoveCreateUI() While applesLeft > 0DropApple()applesLeft = applesLeft - 1 Shapes.SetText(applesLeftTextBox, "Apples Left: " + applesLeft)EndWhileGraphicsWindow.ShowMessage("Your Score is: " + gameScore, "GameOver")Program.End()Sub CreateUIGraphicsWindow.BackgroundColor = "LightBlue" catcher = Shapes.AddImage(catcherImage) apple = Shapes.AddImage(appleimage) GraphicsWindow.BrushColor = "Gray"GraphicsWindow.FillRectangle(1, 1, gw, 40) GraphicsWindow.FontName = "Verdana"GraphicsWindow.FontSize = 18GraphicsWindow.BrushColor = "White"GraphicsWindow.DrawText(220, 5, "Catch the Apples!") scoreTextBox = Shapes.AddText("Score: 0")Shapes.Move(scoreTextBox, 480, 5)applesLeftTextBox = Shapes.AddText("Apples Left: " + applesLeft)Shapes.Move(applesLeftTextBox, 5, 5)GraphicsWindow.PenColor = "Black"GraphicsWindow.DrawLine(0, 50, 620, 50)Shapes.Move(catcher, 0, gh - 40) Mouse.HideCursor()EndSubSub OnMouseMovecatcherX = Math.Min(GraphicsWindow.MouseX, 570)Shapes.Move(catcher, catcherX, gh - 40)EndSubSub DropAppleappleX = Math.GetRandomNumber(600)appleY = 50While (appleY < gh + 20)Shapes.Move(apple, appleX, appleY)Program.Delay(15)DetectCatch()appleY = appleY + 5EndWhileEndSubSub DetectCatchIf appleY >= gh - 40 And appleX < catcherX + 50 And appleX >= catcherX ThengameScore = gameScore + 1Shapes.SetText(scoreTextBox, "Score: " + gameScore) appleY = gh + 20EndIfEndSub