SlideShare une entreprise Scribd logo
1  sur  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]

Contenu connexe

Tendances

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
 

Tendances (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
 

Similaire à 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
 

Similaire à 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
 

Plus de 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
 

Plus de 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
 

Dernier

presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxRemote DBA Services
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Angeliki Cooney
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityWSO2
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...apidays
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesrafiqahmad00786416
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Victor Rentea
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Victor Rentea
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamUiPathCommunity
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 

Dernier (20)

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 

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.

Notes de l'éditeur

  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