CS 1666
www.cs.pitt.edu/~nlf4/cs1666/
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
www.cs.pitt.edu/~nlf4/cs1666/
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
screen, how can we check whether they've hit one another?
2
3
4
5
6
7
8
9
10
11
12
13
○ 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
■ result will be NULL if there is no intersection
14