summaryrefslogtreecommitdiff
path: root/src/player.c
diff options
context:
space:
mode:
authorkdx <kikoodx@paranoici.org>2023-03-18 23:40:10 +0100
committerkdx <kikoodx@paranoici.org>2023-03-18 23:41:16 +0100
commitb796e0bea418cc541257e17274b6fb14d4cb5ee8 (patch)
treed87ce38493e6af3e5c75a3171981310a20b46920 /src/player.c
parent297ee77f926197504f8e0d7d6fcf0bf602cccd66 (diff)
downloadhyperultra-b796e0bea418cc541257e17274b6fb14d4cb5ee8.tar.gz
death particles
Diffstat (limited to 'src/player.c')
-rw-r--r--src/player.c33
1 files changed, 23 insertions, 10 deletions
diff --git a/src/player.c b/src/player.c
index 24d61b0..f5a824f 100644
--- a/src/player.c
+++ b/src/player.c
@@ -1,13 +1,15 @@
+#include "deathpart.h"
#include "entityimpl.h"
+#include "game.h"
#include "input.h"
#include <math.h>
-IMPL_UPDATE()
+IMPL_UPDATE() {
const int on_ground = entity_collide(this, g, 0, 1);
this->vel[0] = 2.0 * this->player.dirx;
- this->vel[1] *= 0.99;
- this->vel[1] += 0.2;
+ this->vel[1] *= AIR_RESISTANCE;
+ this->vel[1] += GRAVITY;
this->player.scale_x += 0.1 * (1.0 - this->player.scale_x);
this->player.scale_y += 0.1 * (1.0 - this->player.scale_y);
if (fabs(this->player.scale_x - 1.0) < 0.05) this->player.scale_x = 1.01;
@@ -42,14 +44,25 @@ IMPL_UPDATE()
if (this->vel[0] == 0.0 && this->vel[1] >= -0.0)
this->player.dirx *= -1;
- if (this->bonk_ceiling)
- g->queue_restart_scene = true;
+ if (this->bonk_ceiling) {
+ int dy = this->pos[1] - 6;
+ for (int y = 0; y < 7; y++) {
+ int dx = this->pos[0] - 6;
+ for (int x = 0; x < 7; x++) {
+ deathpart_init(game_create_entity(g), dx, dy);
+ dx += 2;
+ }
+ dy += 2;
+ }
+ this->type = ET_NONE;
+ g->queue_restart_scene = 30;
+ }
if (entity_place_meeting(this, g, ET_exit) != NULL)
g->queue_next_scene = true;
-}
+} IMPL_END
-IMPL_DRAW()
+IMPL_DRAW() {
LZY_DrawSetColor(BLACK);
int width = (int)(this->width / 2) * this->player.scale_x;
int height = (int)(this->height / 2) * this->player.scale_y;
@@ -58,12 +71,12 @@ IMPL_DRAW()
LZY_DrawRect(this->pos[0] - width / 2,
this->pos[1] - height / 2,
width, height);
-}
+} IMPL_END
-IMPL_INIT(player)
+IMPL_INIT(player) {
this->width = 12;
this->height = 12;
this->player.scale_x = 1.0;
this->player.scale_y = 1.0;
this->player.dirx = 1;
-}
+} IMPL_END