From 937edea9599718e959f8ed135e97c68728855975 Mon Sep 17 00:00:00 2001 From: quou Date: Sat, 6 May 2023 12:22:50 +1000 Subject: Add solid environment collisions. --- player.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) (limited to 'player.c') diff --git a/player.c b/player.c index d79beed..4a82cff 100644 --- a/player.c +++ b/player.c @@ -26,7 +26,8 @@ void init_player(Player* player, World* world) { ctype_position | ctype_animated | ctype_collider | - ctype_player + ctype_player | + ctype_moveable ); pos = &world->positions[e]; sprite = &world->sprites[e]; @@ -55,7 +56,7 @@ void init_player(Player* player, World* world) { } void update_player(Player* player, World* world) { - int dx, dy, cbx, cby; + int dx, dy; int face, moving = 0; Entity e; CPosition* pos; @@ -132,6 +133,19 @@ void update_player(Player* player, World* world) { game_change_state(&game, game_state_dead); } + player->shoot_countdown--; +} + +void player_take_damage(Player* player, int dmg) { + player->hp -= dmg; +} + +void update_camera(Player* player, World* world) { + const CPosition* pos; + int cbx, cby; + + pos = &world->positions[player->entity]; + world->cam_x = pos->x - ((renderer_w / 2) << fbits); world->cam_y = pos->y - ((renderer_h / 2) << fbits); @@ -151,10 +165,4 @@ void update_player(Player* player, World* world) { if (world->cam_y > cby) { world->cam_y = cby; } - - player->shoot_countdown--; -} - -void player_take_damage(Player* player, int dmg) { - player->hp -= dmg; } -- cgit v1.2.3-54-g00ecf