diff options
Diffstat (limited to 'platformer/src/player.h')
| -rw-r--r-- | platformer/src/player.h | 34 |
1 files changed, 26 insertions, 8 deletions
diff --git a/platformer/src/player.h b/platformer/src/player.h index 4d8fdc6..e6fd033 100644 --- a/platformer/src/player.h +++ b/platformer/src/player.h @@ -16,8 +16,9 @@ * PLAYER_RUN, on ground, moving (walk vs run is just speed) * PLAYER_JUMP, in air, going up after a jump * PLAYER_FALL, in air, going down (or walked off something) - * PLAYER_SKID on ground, braking after pulling the stick back at + * PLAYER_SKID, on ground, braking after pulling the stick back at * full run; retreating_movement is on + * PLAYER_WALL_HANG in air, clinging to a hangable wall and sliding down * } PlayerState; * * typedef enum JumpKind { which jump the player is in the air from @@ -35,9 +36,10 @@ * float forward_speed; ground speed along facing_yaw, m/s (>= 0) * PlayerState state; * bool heightened_movement; on for PLAYER_SECOND_JUMP_WINDOW s after - * landing a normal or retreat jump, and for the whole - * second jump. While on, A gives the second - * jump. Later moves will read it too. + * landing a normal or retreat jump, and for the + * whole second jump, retreat jump, wall hang + * and every wall jump. On the ground, A gives the second + * jump; in the air, it lets the player wall hang. * float heightened_timer; s left before heightened_movement ends * (not counted down during the second jump) * bool retreating_movement; on for the whole skid (PLAYER_SKID) and @@ -49,6 +51,15 @@ * float skid_speed; forward_speed when the skid began * float skid_yaw; direction the skid slides (the old run * direction; the player already faces the stick) + * float wall_time; s since the current wall hang began + * float wall_jump_yaw; where a wall jump from this hang launches: the + * approach direction mirrored off the wall + * bool has_last_wall; a wall was jumped off since the last landing + * Vec3 last_wall_normal; that wall's surface: which way it faces... + * float last_wall_plane; ...and where its face lies along that + * direction. That surface can't be hung on + * again until the player lands (no climbing + * one wall, even one built from several boxes) * } Player; * * void player_init(Player *p, Vec3 spawn); @@ -61,8 +72,8 @@ * * CONVENTIONS: Include guard: PLAYER_H. * - * NOT IN SCOPE: Health, animation, extra moves beyond the second jump and the - * skid's retreat jump (see the README roadmap). + * NOT IN SCOPE: Health, animation, extra moves beyond the second jump, the + * skid's retreat jump and the wall hang (see the README roadmap). * * DONE WHEN: main.c and render.c compile against this header alone. * ============================================================ @@ -77,13 +88,15 @@ /* SM64-style "actions". Add states here only when a new move needs one; * see the README roadmap (triple jump, long jump, wall kick, ...). The second * and retreat jumps didn't need one: they're a JUMP with a different launch - * (see JumpKind). The skid did, because it follows its own ground rules. */ + * (see JumpKind). The skid and wall hang did, because each follows its own + * movement rules. */ typedef enum PlayerState { PLAYER_IDLE, /* on ground, not moving */ PLAYER_RUN, /* on ground, moving (walk vs run is just speed) */ PLAYER_JUMP, /* in air, going up after a jump */ PLAYER_FALL, /* in air, going down (or walked off something) */ - PLAYER_SKID /* on ground, braking after pulling back at full run */ + PLAYER_SKID, /* on ground, braking after pulling back at full run */ + PLAYER_WALL_HANG /* in air, clinging to a hangable wall and sliding down */ } PlayerState; /* Which jump the player is in the air from. It decides the top speed in the @@ -107,6 +120,11 @@ typedef struct Player { float skid_time; /* s since the current skid began */ float skid_speed; /* forward_speed when the skid began */ float skid_yaw; /* direction the skid slides; facing_yaw already points at the stick */ + float wall_time; /* s since the current wall hang began */ + float wall_jump_yaw; /* a wall jump's launch direction: the approach mirrored off the wall */ + bool has_last_wall; /* a wall was jumped off since the last landing... */ + Vec3 last_wall_normal; /* ...facing this way... */ + float last_wall_plane; /* ...with its face here along that direction; no regrab until landing */ } Player; void player_init(Player *p, Vec3 spawn); |
