diff options
author | kdx <kikoodx@paranoici.org> | 2023-03-17 17:00:47 +0100 |
---|---|---|
committer | kdx <kikoodx@paranoici.org> | 2023-03-17 17:00:47 +0100 |
commit | 4d17f417ebdd3f161138530120c459a35c90ea5f (patch) | |
tree | 85b8ef73eb7fd977c90ef27ca406dc9d8fcf4533 /src/player.c | |
parent | 066760bd7abbcc973ca46ab306f1e24481d3280c (diff) | |
download | hyperultra-4d17f417ebdd3f161138530120c459a35c90ea5f.tar.gz |
bounce on walls
Diffstat (limited to 'src/player.c')
-rw-r--r-- | src/player.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/player.c b/src/player.c index 9d02ce0..b4765df 100644 --- a/src/player.c +++ b/src/player.c @@ -5,13 +5,14 @@ #include "cfg.h" #include "input.h" #include <string.h> +#include <math.h> static void player_update(Entity *this, Game *g) { const int on_ground = entity_collide(this, g, 0, 1); - this->vel[0] = 2.0; + this->vel[0] = 2.0 * this->player.dirx; this->vel[1] *= 0.99; this->vel[1] += 0.2; this->player.scale_x += 0.1 * (1.0 - this->player.scale_x); @@ -42,6 +43,8 @@ player_update(Entity *this, Game *g) } entity_move(this, g); + if (this->vel[0] == 0.0) + this->player.dirx *= -1; } static void @@ -74,4 +77,5 @@ player_init(Entity *this) this->height = 12; this->player.scale_x = 1.0; this->player.scale_y = 1.0; + this->player.dirx = 1; } |