aboutsummaryrefslogtreecommitdiff
path: root/player.c
diff options
context:
space:
mode:
Diffstat (limited to 'player.c')
-rw-r--r--player.c22
1 files changed, 21 insertions, 1 deletions
diff --git a/player.c b/player.c
index 592ef4a..d79beed 100644
--- a/player.c
+++ b/player.c
@@ -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--;
}