summaryrefslogtreecommitdiff
path: root/src/player.c
diff options
context:
space:
mode:
authorkdx <kikoodx@paranoici.org>2023-03-17 16:38:10 +0100
committerkdx <kikoodx@paranoici.org>2023-03-17 16:38:10 +0100
commit0d8386099bb5febeaa0e6c31e68b308109080428 (patch)
treebce16ea59c29e6a572add298b4d8765e0b3a39b1 /src/player.c
parentf3f3100dbd1f8ff31c3e6fd2acfd2c6edffcc181 (diff)
downloadhyperultra-0d8386099bb5febeaa0e6c31e68b308109080428.tar.gz
jump
Diffstat (limited to 'src/player.c')
-rw-r--r--src/player.c25
1 files changed, 23 insertions, 2 deletions
diff --git a/src/player.c b/src/player.c
index dc60dbb..3787a80 100644
--- a/src/player.c
+++ b/src/player.c
@@ -3,13 +3,34 @@
#include "game.h"
#include "lzy.h"
#include "cfg.h"
+#include "input.h"
#include <string.h>
static void
player_update(Entity *this, Game *g)
{
- this->vel[0] = 1.2;
- this->vel[1] += 0.1;
+ const int on_ground = entity_collide(this, g, 0, 1);
+
+ this->vel[0] = 2.0;
+ this->vel[1] *= 0.99;
+ this->vel[1] += 0.2;
+
+ if (on_ground && input_pressed(K_O)) {
+ const int diry = input_down(K_UP) - input_down(K_DOWN);
+ switch (diry) {
+ case -1:
+ this->vel[1] = -2.8;
+ break;
+ default:
+ case 0:
+ this->vel[1] = -3.8;
+ break;
+ case 1:
+ this->vel[1] = -4.8;
+ break;
+ }
+ }
+
entity_move(this, g);
}