cs 1666
play

CS 1666 www.cs.pitt.edu/~nlf4/cs1666/ Collision detection - PowerPoint PPT Presentation

CS 1666 www.cs.pitt.edu/~nlf4/cs1666/ Collision detection Collision detection We already had to implement some basic collision detection in the motion example I.e., to keep our square from moving out of the window Checking for


  1. CS 1666 www.cs.pitt.edu/~nlf4/cs1666/ Collision detection

  2. Collision detection We already had to implement some basic collision detection ● in the motion example ○ I.e., to keep our square from moving out of the window ○ Checking for collisions with the boundary of the window ● Generally, games will have many objects moving around the screen, how can we check whether they've hit one another? 2

  3. No Collision 3

  4. No Collision 4

  5. No Collision 5

  6. COLLISION! 6

  7. Colliding circles 7

  8. Complex collisions 8

  9. Complex collisions in action 9

  10. Even more complex collisions 10

  11. Really complex collisions 11

  12. Street Fighter II Hitboxes 12

  13. The same idea is used in 3D games 13

  14. Back to 2D And some help from SDL ● ○ SDL_bool SDL_HasIntersection(const SDL_Rect* A, const SDL_Rect* B) ■ True if the two SDL_Rect 's intersect ■ False otherwise ○ SDL_bool SDL_IntersectRect(const SDL_Rect* A, constSDL_Rect* B, SDL_Rect* result) ■ Same returns, but will also set result to the intersection of A and B if one exists ■ result will be NULL if there is no intersection 14

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend