diff options
| author | arngo <[email protected]> | 2023-05-26 17:42:01 -0400 |
|---|---|---|
| committer | arngo <[email protected]> | 2023-05-26 17:42:01 -0400 |
| commit | 41952aa435d9443dc7a96d2c59506cfe5c426328 (patch) | |
| tree | f4ee6bef708f0dfe97b44bd910831d1b932c05e9 /src/player.c | |
| parent | 92a20f1c3f48eb0c6bf04585b8bb3ab0aea5c99a (diff) | |
| parent | 524040a76a673b0fcc7ad49ac009fc4506ef76e1 (diff) | |
| download | TOJam2023-41952aa435d9443dc7a96d2c59506cfe5c426328.tar.gz TOJam2023-41952aa435d9443dc7a96d2c59506cfe5c426328.zip | |
Merge branch 'master' of github.com:realtradam/TOJam2023
Diffstat (limited to 'src/player.c')
| -rw-r--r-- | src/player.c | 38 |
1 files changed, 34 insertions, 4 deletions
diff --git a/src/player.c b/src/player.c index d9a87d2..a12a4d7 100644 --- a/src/player.c +++ b/src/player.c @@ -12,6 +12,7 @@ struct player_t int32_t hp; float damage_timer; //ms world_id collision_id; + move_state_t move_state; } player; @@ -92,15 +93,44 @@ parse_player_input(void) units_move_down_input(NULL, &reset_movement); units_move_left_input(NULL, &reset_movement); units_move_right_input(NULL, &reset_movement); - player_position->dx = *(float*)units_move_right_input(NULL, NULL) + *(float*)units_move_left_input(NULL, NULL); - player_position->dy = *(float*)units_move_down_input(NULL, NULL) + *(float*)units_move_up_input(NULL, NULL); + + // if you arent mid jump, then record attempted movement + if(player.move_state != mv_state_jumping) + { + player_position->dx = *(float*)units_move_right_input(NULL, NULL) + *(float*)units_move_left_input(NULL, NULL); + player_position->dy = *(float*)units_move_down_input(NULL, NULL) + *(float*)units_move_up_input(NULL, NULL); + + if(((player_position->dy != 0) || (player_position->dx != 0)) && player.move_state == mv_state_standing) + { + player.move_state = mv_state_jumping; + player_position->dy = 0; + player_position->dx = 0; + } + } } void move_player(void) { - player.sprite.iter += 1; - player.sprite.iter %= player.sprite.config.count; + rodeo_log( + rodeo_logLevel_info, + "%d, %d\n", + player.move_state, + player.sprite.iter + ); + if(player.move_state != mv_state_standing) + { + player.sprite.iter += 1; + player.sprite.iter %= player.sprite.config.count; + if(player.sprite.iter > 19) + { + player.move_state = mv_state_mid_air; + } + } + if(player.sprite.iter == 60) + { + player.move_state = mv_state_standing; + } cvec_collision_2d_world_item_value *player_position = rodeo_collision_2d_world_item_get_by_id(player.collision_id); player_position->x += player_position->dx; player_position->dx = 0; |
