This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
notes:cprog:fall2024:projects:fwg1 [2024/10/24 03:40] – [bounds checking] mwinter4 | notes:cprog:fall2024:projects:fwg1 [2024/10/24 03:46] (current) – [bounds checking] mwinter4 | ||
---|---|---|---|
Line 52: | Line 52: | ||
To bound check, we can simply view the coordinates of our main player character to determine if they are at coordinates that rest outside of the screen height and width. Here is an example of how one might horizontally check bounds and wrap the player around to the opposite side: | To bound check, we can simply view the coordinates of our main player character to determine if they are at coordinates that rest outside of the screen height and width. Here is an example of how one might horizontally check bounds and wrap the player around to the opposite side: | ||
+ | |||
+ | < | ||
+ | void ourFunction(player* p){ | ||
+ | if(p-> | ||
+ | { | ||
+ | p-> | ||
+ | }; | ||
+ | } | ||
+ | </ | ||
+ | This assumes that we've passed in a pointer to our player structure that we will call p for this function. | ||
+ | |||
+ | There is also the assumption that there is a member variable of this structure called <wrap hi>" |