summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkdx <kikoodx@paranoici.org>2023-05-06 01:07:06 +0200
committerkdx <kikoodx@paranoici.org>2023-05-06 01:07:06 +0200
commit3f57eb64fea1482146f22dbc4dadafa991e2ad36 (patch)
tree687eff786c5f14f4b909e5c2eb85663cbdc30f5c
parent65368603bd1931662a3f058221783032f1033b4a (diff)
downloadstudy-sttky-3f57eb64fea1482146f22dbc4dadafa991e2ad36.tar.gz
i don't want to think about death tonight
-rw-r--r--map/game2.tmj69
-rw-r--r--src/main.c11
-rw-r--r--src/map.c8
-rw-r--r--src/player.c12
4 files changed, 91 insertions, 9 deletions
diff --git a/map/game2.tmj b/map/game2.tmj
new file mode 100644
index 0000000..0a532a9
--- /dev/null
+++ b/map/game2.tmj
@@ -0,0 +1,69 @@
+{ "compressionlevel":-1,
+ "height":16,
+ "infinite":false,
+ "layers":[
+ {
+ "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,
+ 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, 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, 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, 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 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,
+ 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,
+ 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,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1,
+ 1, 1, 1, 1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 1, 1, 1, 1, 1, 1, 1, 1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 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, 2, 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],
+ "height":16,
+ "id":1,
+ "name":"Tile Layer 1",
+ "opacity":1,
+ "type":"tilelayer",
+ "visible":true,
+ "width":26,
+ "x":0,
+ "y":0
+ },
+ {
+ "draworder":"topdown",
+ "id":2,
+ "name":"Object Layer 1",
+ "objects":[
+ {
+ "height":5,
+ "id":1,
+ "name":"player",
+ "rotation":0,
+ "type":"",
+ "visible":true,
+ "width":5,
+ "x":0,
+ "y":94.5
+ }],
+ "opacity":1,
+ "type":"objectgroup",
+ "visible":true,
+ "x":0,
+ "y":0
+ }],
+ "nextlayerid":3,
+ "nextobjectid":2,
+ "orientation":"orthogonal",
+ "renderorder":"right-down",
+ "tiledversion":"1.10.1",
+ "tileheight":9,
+ "tilesets":[
+ {
+ "firstgid":1,
+ "source":"tset.tsj"
+ }],
+ "tilewidth":9,
+ "type":"map",
+ "version":"1.10",
+ "width":26
+} \ No newline at end of file
diff --git a/src/main.c b/src/main.c
index 0cf5124..0c623ec 100644
--- a/src/main.c
+++ b/src/main.c
@@ -13,7 +13,7 @@ static Game *game = NULL;
static void deinit(void);
static int main_loop(void *udata);
-static void acid(void);
+static void acid(const Game *game);
int
main(int argc, char **argv)
@@ -87,7 +87,7 @@ main_loop(void *udata)
pxCls(0);
pxPalt(0, true);
game_draw(game);
- acid();
+ acid(game);
pxFlip();
if (TZR_DrawEnd())
return 1;
@@ -95,12 +95,13 @@ main_loop(void *udata)
}
static void
-acid(void)
+acid(const Game *game)
{
PxCol cols[8] = { 0, 1, 2, 3, 4, 5, 6, 7 };
+ const int bg = (game->queue_restart_scene != 0);
for (int i = 0; i < 1024; i++) {
- const int i = 1 + rand() % 7;
- const int k = 1 + rand() % 7;
+ const int i = !bg + rand() % (7 + bg);
+ const int k = !bg + rand() % (7 + bg);
if (i == k)
continue;
cols[i] ^= cols[k];
diff --git a/src/map.c b/src/map.c
index 8352b80..05c4862 100644
--- a/src/map.c
+++ b/src/map.c
@@ -7,13 +7,13 @@
#include <stddef.h>
extern const Tiled2cMap embed_game_tmj;
-extern const Tiled2cMap embed_grablmao_tmj;
-extern const Tiled2cMap embed_pizzeria_tmj;
-extern const Tiled2cMap embed_banger_tmj;
-extern const Tiled2cMap embed_end_tmj;
+extern const Tiled2cMap embed_game2_tmj;
+extern const Tiled2cMap embed_game3_tmj;
+extern const Tiled2cMap embed_game4_tmj;
static const Tiled2cMap *const maps[] = {
&embed_game_tmj,
+ &embed_game2_tmj,
NULL
};
static unsigned int map_id;
diff --git a/src/player.c b/src/player.c
index a4d346e..155d8bd 100644
--- a/src/player.c
+++ b/src/player.c
@@ -8,6 +8,9 @@ IMPL_INIT(player, 0) {
IMPL(update) {
IMPL_UNUSED;
+ if (g->queue_restart_scene)
+ return;
+
const int kleft = TZR_IsKeyDown(SDL_SCANCODE_A) ||
TZR_IsKeyDown(SDL_SCANCODE_LEFT);
const int kright = TZR_IsKeyDown(SDL_SCANCODE_D) ||
@@ -28,7 +31,16 @@ IMPL(update) {
g->queue_next_scene = 1;
printf("YO\n");
}
+
move();
+
+ if (collide_spike(0, 0))
+ this->dead += 1;
+ else
+ this->dead = 0;
+
+ if (this->dead > 3)
+ g->queue_restart_scene = 60;
}
IMPL(draw) {