This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
notes:comporg:fall2023:projects:magx [2023/11/15 18:01] – [Player Physics and Animations] walley | notes:comporg:fall2023:projects:magx [2023/11/15 18:07] (current) – [Player Physics and Animations] walley | ||
---|---|---|---|
Line 50: | Line 50: | ||
- Position X | - Position X | ||
- Position Y | - Position Y | ||
- | Again, the Position data will be updated relative to the Obstacle X reference point. | + | Again, the Position data will be updated relative to the Obstacle X reference point. Additionally, |
+ | ===Obstacle Collision and Rendering=== | ||
+ | The processes for both collision checks and rendering are relatively the same. First, we check the Obstacle flag to see which pattern is currently spawned, and then grab the size variable associated with it. Secondly, we use that size variable to for-loop through each element in the obstacle to then either run collision checks on it, or render it. | ||
+ | For Collision, we check if the element is either a Block or a Spike using the Object Type variable. If it's a block, we run checks to see if the Player is on top of it, so that the Player can run and jump along it, or if the Player is in it to trigger a game over. For Spikes, there are two boxes inside it that if the player enters | ||
+ | also triggers a game over. | ||
+ | For Rendering, the Object Type check is the same to select the right texture region, which gets printed at that position. Relatively simple. | ||