1 / 9

Microsoft ® Small Basic

Microsoft ® Small Basic. 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. . What is Collision Detection?.

eshe
Download Presentation

Microsoft ® Small Basic

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Microsoft® Small Basic Collision Detection Estimated time to complete this lesson: 1 hour

  2. Collision Detection In this lesson, you will learn how to: Use the concept of collision detection in games.

  3. What is Collision Detection? Now let’s talk about collision detection in games. In general, collision detection refers to determining the intersection of two moving objects. • Collision detection in games requires the following steps: • Select two objects to test for collision. • Determine whether those two objects collided.

  4. How to Detect Collision? Before we discuss how to detect collisions, you should consider what happens to two objects when they collide. Collision detection is a basic aspect of two-dimensional and three-dimesional games. Algorithms help to detect the collision. Most games use posteriori collision detection—that is, they detect the collision after it has occurred. Two objects are said to collide if they come in contact with each other. The objects may continue moving after collision or one may come to rest, depending on the nature of collision.

  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 must make the turtle hit the target by specifying the correct angle and the correct distance. Now that you understand the concept of collision detection in games, let’s make a game that uses the logic of collision detection.

  6. Hit the Target – How to Play It’s time to play the game! • 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.

  7. Hit the Target – The Code Now let’s understand the code for the game in detail… • 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.

  8. Let’s Summarize… Congratulations! Now you know how to: • Use the concept of collision detection in games.

  9. It’s Time to Apply Your Learning… Using the concept of collision detection, create a game that involves two types of objects: a bucket and apples. The apples fall randomly from the top of the graphics window. 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 that the player caught in 30 seconds. Your game should resemble the example in this slide.

More Related