Professional Documents
Culture Documents
Collision Detection
Estimated time to complete this lesson: 1 hour
Collision Detection
In this lesson, you will learn how to:
Use the concept of collision detection in games.
Collision detection in games requires the following steps: Select two objects to test for collision. Determine whether those two objects collided.
The game involves two objects: the turtle and the target. The player must make the turtle hit the target by specifying the correct angle and the correct distance.
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.
Steps to play the game: Set the angle to specify the direction in which the turtle will move. Specify the distance that the turtle must cover to hit the target. Click the Hit button to hit the target. Click the Reset button to reset the position of the target.
Create the user interface by using the GraphicsWindow object. Next, use the Controls object to add a button and a text box and to set the size of the button. Use the Shapes object to add an image of the shape, to move and animate the shape, and to set its opacity level. Use the Turtle object, and set its angle and moving distance by using the Math object.
Lets Summarize