aboutsummaryrefslogtreecommitdiff
path: root/player.c
diff options
context:
space:
mode:
authorquou <quou@disroot.org>2023-05-07 12:53:46 +1000
committerquou <quou@disroot.org>2023-05-07 12:54:06 +1000
commit5f341eacdf0d75a4b334969a2d8a4701d61e4d9e (patch)
treeee3a4c44b92e975530e1e6fed18c8852a6f70a93 /player.c
parent5ef6a71e935e2c3d1e5f9828e8cdbd78403a06a0 (diff)
Add waves and stuff.
Diffstat (limited to 'player.c')
-rw-r--r--player.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/player.c b/player.c
index ff3f53b..9075048 100644
--- a/player.c
+++ b/player.c
@@ -87,7 +87,7 @@ void update_player(Player* player, World* world) {
if (dx || dy) {
vec_nrmise(&dx, &dy);
- if (dx) {
+ if (dx && !button_pressed(btn_shoot)) {
face = dx < 0 ? 0 : 1;
} else {
face = player->face;
@@ -117,13 +117,18 @@ void update_player(Player* player, World* world) {
animation_player_walk_left;
}
+ if (!button_pressed(btn_shoot)) {
+ player->sdx = player->ldx;
+ player->sdy = player->ldy;
+ }
+
if (button_pressed(btn_shoot) && player->shoot_countdown <= 0) {
new_player_bullet(
world,
pos->x,
pos->y,
- (player->ldx * player_bullet_speed) >> fbits,
- (player->ldy * player_bullet_speed) >> fbits,
+ (player->sdx * player_bullet_speed) >> fbits,
+ (player->sdy * player_bullet_speed) >> fbits,
100
);