From fd2c1baa4edc4a99ff3752f86267ae98f017a77b Mon Sep 17 00:00:00 2001 From: kdx Date: Sun, 19 Mar 2023 01:37:14 +0100 Subject: spikes! --- CMakeLists.txt | 2 ++ map/idkwymlol.json | 2 +- map/weallstartsomewhere.json | 2 +- res/tset.png | Bin 236 -> 316 bytes src/background.c | 1 + src/game.c | 4 ++++ src/player.c | 4 +++- src/spike.c | 5 +++++ 8 files changed, 17 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1cc5221..dfa631c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,6 +21,8 @@ set(SOURCES src/main.c src/map.c src/player.c + src/rotrect.c + src/spike.c ) set(ASSETS diff --git a/map/idkwymlol.json b/map/idkwymlol.json index 55ba8ff..9c849bd 100644 --- a/map/idkwymlol.json +++ b/map/idkwymlol.json @@ -1 +1 @@ -{"width":25,"height":14,"data":[1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,1,1,1,1,0,1,0,1,1,0,0,0,0,0,0,1,1,0,0,1,1,1,0,0,0,1,0,0,1,0,0,1,1,1,1,1,0,0,1,1,1,0,0,1,0,1,1,0,0,0,1,1,1,0,0,0,1,0,0,0,1,0,0,1,0,0,0,0,1,0,1,1,0,0,1,1,1,0,0,0,0,1,0,0,0,1,0,1,1,1,1,0,1,1,0,1,1,0,0,1,0,1,1,1,0,1,1,0,0,1,1,0,1,0,0,0,0,1,0,0,1,1,2,0,1,0,0,0,1,0,1,1,0,1,1,0,0,1,0,0,0,1,1,0,0,1,1,1,1,0,0,0,1,0,0,0,1,1,1,0,0,1,0,0,0,1,1,0,4,0,1,1,0,0,0,0,0,1,0,0,0,0,0,0,0,0,1,0,0,0,0,1,1,1,0,1,1,0,0,0,0,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1]} \ No newline at end of file +{"width":25,"height":14,"data":[1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,1,1,1,1,0,1,0,1,1,0,0,0,0,0,0,1,1,0,0,1,1,1,0,0,0,1,0,0,1,0,0,1,1,1,1,1,0,0,1,1,1,0,0,1,0,1,1,0,0,0,1,1,1,0,0,0,1,0,0,0,1,0,0,1,0,0,0,0,1,0,1,1,0,0,1,1,1,0,0,0,0,1,0,0,0,1,0,1,1,1,1,0,1,1,0,1,1,0,0,1,0,1,1,1,0,1,1,0,0,1,1,0,1,0,0,0,0,1,0,0,1,1,2,0,1,0,0,0,1,0,1,1,0,1,1,0,0,1,0,0,0,1,1,0,0,1,1,1,1,0,0,0,1,0,0,0,1,1,1,0,0,1,0,0,0,1,1,0,4,0,1,1,0,0,0,0,0,1,0,0,0,0,0,0,0,0,1,0,0,0,0,1,1,1,0,1,1,0,0,0,0,1,0,0,0,0,0,0,0,0,1,5,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1]} \ No newline at end of file diff --git a/map/weallstartsomewhere.json b/map/weallstartsomewhere.json index 57f5963..b3fd04d 100644 --- a/map/weallstartsomewhere.json +++ b/map/weallstartsomewhere.json @@ -1 +1 @@ -{"width":25,"height":14,"data":[1,1,1,1,1,1,1,1,1,1,1,1,1,1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,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,1,1,1,1,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,1,0,1,0,0,0,1,1,1,1,1,0,0,1,0,1,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,1,1,1,0,0,0,1,1,1,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,1,0,1,0,0,0,0,0,0,0,0,0,0,1,1,0,2,0,0,0,5,0,0,0,0,1,0,1,1,1,0,0,5,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1]} \ No newline at end of file diff --git a/res/tset.png b/res/tset.png index 481c648..e751df9 100644 Binary files a/res/tset.png and b/res/tset.png differ diff --git a/src/background.c b/src/background.c index 03730e8..fc3b1ba 100644 --- a/src/background.c +++ b/src/background.c @@ -1,6 +1,7 @@ #include "lzy.h" #include "cfg.h" #include "rotrect.h" +#include long tick = 0; diff --git a/src/game.c b/src/game.c index c7159ae..615e06e 100644 --- a/src/game.c +++ b/src/game.c @@ -3,6 +3,7 @@ #include "map.h" #include "player.h" #include "cfg.h" +#include "spike.h" #include void @@ -64,6 +65,9 @@ game_restart_scene(Game *this) case 4: exit_init(game_create_entity(this), dx, dy); break; + case 5: + spike_init(game_create_entity(this), dx, dy); + break; default: break; } diff --git a/src/player.c b/src/player.c index f5a824f..3af2dfc 100644 --- a/src/player.c +++ b/src/player.c @@ -1,4 +1,5 @@ #include "deathpart.h" +#include "entity.h" #include "entityimpl.h" #include "game.h" #include "input.h" @@ -44,7 +45,8 @@ IMPL_UPDATE() { if (this->vel[0] == 0.0 && this->vel[1] >= -0.0) this->player.dirx *= -1; - if (this->bonk_ceiling) { + if (this->bonk_ceiling || + entity_place_meeting(this, g, ET_spike) != NULL) { int dy = this->pos[1] - 6; for (int y = 0; y < 7; y++) { int dx = this->pos[0] - 6; diff --git a/src/spike.c b/src/spike.c index 4fb7a47..4173729 100644 --- a/src/spike.c +++ b/src/spike.c @@ -1,4 +1,5 @@ #include "entityimpl.h" +#include "rotrect.h" extern long tick; @@ -6,7 +7,11 @@ IMPL_UPDATE() { } IMPL_END IMPL_DRAW() { + const double angle = (float)tick / 16; + rotrect(this->pos[0], this->pos[1], 10, 10, angle); + rotrect(this->pos[0], this->pos[1], 10, 10, -angle); } IMPL_END IMPL_INIT(spike) { + this->height = this->width = 8; } IMPL_END -- cgit v1.2.3