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/08 15:52] – [Player Physics and Animations] walley | notes:comporg:fall2023:projects:magx [2023/11/15 18:07] (current) – [Player Physics and Animations] walley | ||
---|---|---|---|
Line 28: | Line 28: | ||
===Animation Control=== | ===Animation Control=== | ||
+ | |||
+ | Since the player has three different states (running, jumping, and sliding), there will be 3 different animation states. | ||
+ | |||
+ | While sliding, the player will be shown as sliding across the ground in a single pose. | ||
+ | |||
+ | While jumping, the player will have two different visuals for jumping up and falling down. The asset that gets drawn will be dependent on the player' | ||
+ | |||
+ | While running, the player will cycle between four different running sprites. A flag variable will be used to note which sprite should get displayed (0-3). Every 7 frames, the flag will get incremented and then modulated by 4. This can be achieved by using the FrameCounter that's built into Vircon32. | ||
+ | |||
+ | The running animation is the default one that gets played, and will be overwritten when the player either jumps or slides. | ||
+ | |||
+ | ===Obstacle Infrastructure and Generation=== | ||
+ | Every good runner needs to have obstacles to avoid! For this runner, we'll have two building blocks: A block and a spike. | ||
+ | |||
+ | Our obstacles will be controlled by an integer flag. A zero means no obstacle is spawned, and any number higher corresponds with an obstacle pattern. This flag can be triggered by the console clock, RNG, or whatever. | ||
+ | |||
+ | When an obstacle is spawned (the flag is turned from 0 to a number), A variable we'll call " | ||
+ | |||
+ | Each obstacle pattern will essentially be an array/list for each building element. Each element will have three variables: | ||
+ | - Object type ( 0=Block, 1=Spike ) | ||
+ | - Position X | ||
+ | - Position Y | ||
+ | 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. | ||
+ |