commit ef3c281c99242ed4adda9855082d5908e768b69f
parent df5aadc9e21983da65064fc5db5d2d8eaf5b9fce
Author: amin <dev@aminmesbah.com>
Date: Mon, 1 Jul 2019 00:46:42 +0000
Call it move mode
FossilOrigin-Name: f79403e5c3ae71dc1fdfa015136177ae7ed6c3042083bb131406c4693eb46eb4
Diffstat:
2 files changed, 26 insertions(+), 26 deletions(-)
diff --git a/src/game.c b/src/game.c
@@ -13,20 +13,20 @@ internal bool btn_is_down(u32 button_states, enum GameButton b)
return result;
}
-internal void move_state_print(enum MoveState s)
+internal void move_mode_print(enum MoveMode s)
{
switch(s)
{
- case MOVE_STATE_FALLING:
+ case MOVE_MODE_FALLING:
printf("FALLING\n");
break;
- case MOVE_STATE_GROUNDED:
+ case MOVE_MODE_GROUNDED:
printf("GROUNDED\n");
break;
- case MOVE_STATE_JUMPING:
+ case MOVE_MODE_JUMPING:
printf("JUMPING\n");
break;
- case MOVE_STATE_CLIMBING:
+ case MOVE_MODE_CLIMBING:
printf("CLIMBING\n");
break;
default:
@@ -85,7 +85,7 @@ internal void game_init(struct GameMemory *game_memory, v2u framebuffer)
// In Knytt, the player is 9 by 14 texels and a tile is 24 by 24 texels.
// These dimensions are relative to a square 'meter', one tile
game_state->player.dimensions = (v2) {0.375f, 0.583f};
- game_state->player.move_state = MOVE_STATE_FALLING;
+ game_state->player.move_mode = MOVE_MODE_FALLING;
game_state->player.facing = DIR_RIGHT;
mem_st_init(
@@ -246,7 +246,7 @@ void game_update_and_render(struct GameMemory *game_memory, struct GameInput *ga
// game_update_player
{
struct Entity *player = &game_state->player;
- move_state_print(player->move_state);
+ move_mode_print(player->move_mode);
f32 dt = game_input->dt;
u32 button_states = game_input->button_states;
if (dt >= 0.5f)
@@ -282,27 +282,27 @@ void game_update_and_render(struct GameMemory *game_memory, struct GameInput *ga
rect player_rect = math_rect_from_center_dim(player->pos.local, player->dimensions);
// TODO: tune these acceleration rates
- switch(player->move_state)
+ switch(player->move_mode)
{
- case MOVE_STATE_FALLING:
+ case MOVE_MODE_FALLING:
player->acceleration.y = -acceleration_rate;
break;
- case MOVE_STATE_GROUNDED:
+ case MOVE_MODE_GROUNDED:
if(entity_is_adjacent_to_solid_tiles(game_state->world, player->pos, player_rect, DIR_DOWN))
{
player->acceleration.y = 0.0f;
if (btn_is_down(button_states, BTN_JUMP))
{
player->acceleration.y = acceleration_rate;
- player->move_state = MOVE_STATE_JUMPING;
+ player->move_mode = MOVE_MODE_JUMPING;
}
}
else
{
- player->move_state = MOVE_STATE_FALLING;
+ player->move_mode = MOVE_MODE_FALLING;
}
break;
- case MOVE_STATE_CLIMBING:
+ case MOVE_MODE_CLIMBING:
if (player->facing == previous_facing_dir
&& entity_is_adjacent_to_solid_tiles(game_state->world, player->pos, player_rect, player->facing))
{
@@ -321,22 +321,22 @@ void game_update_and_render(struct GameMemory *game_memory, struct GameInput *ga
}
else
{
- player->move_state = MOVE_STATE_FALLING;
+ player->move_mode = MOVE_MODE_FALLING;
}
break;
- case MOVE_STATE_JUMPING:
+ case MOVE_MODE_JUMPING:
{
// TODO: give this a real timer
bool jump_timed_out = false;
if (!jump_timed_out && btn_is_down(button_states, BTN_JUMP))
{
player->acceleration.y = acceleration_rate;
- player->move_state = MOVE_STATE_JUMPING;
+ player->move_mode = MOVE_MODE_JUMPING;
}
else
{
player->acceleration.y = -acceleration_rate;
- player->move_state = MOVE_STATE_FALLING;
+ player->move_mode = MOVE_MODE_FALLING;
}
break;
}
@@ -441,13 +441,13 @@ void game_update_and_render(struct GameMemory *game_memory, struct GameInput *ga
if (collision_occurred)
{
- if (edges_collided[RECT_EDGE_TOP] && player->move_state == MOVE_STATE_FALLING)
+ if (edges_collided[RECT_EDGE_TOP] && player->move_mode == MOVE_MODE_FALLING)
{
- player->move_state = MOVE_STATE_GROUNDED;
+ player->move_mode = MOVE_MODE_GROUNDED;
}
else if (edges_collided[RECT_EDGE_LEFT] || edges_collided[RECT_EDGE_RIGHT])
{
- player->move_state = MOVE_STATE_CLIMBING;
+ player->move_mode = MOVE_MODE_CLIMBING;
}
}
diff --git a/src/game.h b/src/game.h
@@ -37,12 +37,12 @@ struct AbsolutePos
v2 local;
};
-enum MoveState
+enum MoveMode
{
- MOVE_STATE_FALLING,
- MOVE_STATE_GROUNDED,
- MOVE_STATE_CLIMBING,
- MOVE_STATE_JUMPING,
+ MOVE_MODE_FALLING,
+ MOVE_MODE_GROUNDED,
+ MOVE_MODE_CLIMBING,
+ MOVE_MODE_JUMPING,
};
enum Direction
@@ -60,7 +60,7 @@ struct Entity
v2 velocity;
v2 dimensions;
enum Direction facing;
- enum MoveState move_state;
+ enum MoveMode move_mode;
f32 jump_timeout;
};