aboutsummaryrefslogtreecommitdiff
path: root/player.c
diff options
context:
space:
mode:
authorquou <quou@disroot.org>2023-05-06 12:22:50 +1000
committerquou <quou@disroot.org>2023-05-06 12:22:50 +1000
commit937edea9599718e959f8ed135e97c68728855975 (patch)
treeea5d5551b470603d2d907dba4869ff52e742d9de /player.c
parent91aef268319a77ee8f5a082ca89264bf2671e212 (diff)
Add solid environment collisions.
Diffstat (limited to 'player.c')
-rw-r--r--player.c24
1 files changed, 16 insertions, 8 deletions
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;
}