diff options
Diffstat (limited to 'player.c')
-rw-r--r-- | player.c | 22 |
1 files changed, 21 insertions, 1 deletions
@@ -55,7 +55,7 @@ void init_player(Player* player, World* world) { } void update_player(Player* player, World* world) { - int dx, dy; + int dx, dy, cbx, cby; int face, moving = 0; Entity e; CPosition* pos; @@ -132,6 +132,26 @@ void update_player(Player* player, World* world) { game_change_state(&game, game_state_dead); } + world->cam_x = pos->x - ((renderer_w / 2) << fbits); + world->cam_y = pos->y - ((renderer_h / 2) << fbits); + + if (world->cam_x < 0) { + world->cam_x = 0; + } + + if (world->cam_y < 0) { + world->cam_y = 0; + } + + cbx = (mbmp_w - renderer_w) << fbits; + if (world->cam_x > cbx) { + world->cam_x = cbx; + } + cby = (mbmp_h - renderer_h) << fbits; + if (world->cam_y > cby) { + world->cam_y = cby; + } + player->shoot_countdown--; } |