summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkdx <kikoodx@paranoici.org>2023-03-26 19:35:31 +0200
committerkdx <kikoodx@paranoici.org>2023-03-26 19:35:31 +0200
commit9cff6ac680741ceea3bc20e82dfe8012266a33d3 (patch)
tree30a77f53b9abfa2786183ac9cab0bfcd834ac4ae
parentb343ac085f87db7c52552b1a86aa26aa6da7a10f (diff)
downloadjamdelaloose-9cff6ac680741ceea3bc20e82dfe8012266a33d3.tar.gz
oh fuck i'm fucked
-rw-r--r--map/brulez.tmj156
-rw-r--r--res/alarm.wavbin0 -> 246828 bytes
-rw-r--r--res/cursor.bmpbin0 -> 4234 bytes
-rw-r--r--res/glass.wavbin0 -> 199754 bytes
-rw-r--r--res/piou.wavbin0 -> 45728 bytes
-rw-r--r--res/window.bmpbin0 -> 16522 bytes
-rw-r--r--res/windowclean.bmpbin0 -> 16522 bytes
-rw-r--r--src/alarm.c6
-rw-r--r--src/entity.c2
-rw-r--r--src/entity.h7
-rw-r--r--src/entityimpl.h12
-rw-r--r--src/main.c7
-rw-r--r--src/player.c26
-rw-r--r--src/window.c19
14 files changed, 209 insertions, 26 deletions
diff --git a/map/brulez.tmj b/map/brulez.tmj
index d5997f7..c846cf2 100644
--- a/map/brulez.tmj
+++ b/map/brulez.tmj
@@ -22,7 +22,7 @@
"name":"Tile Layer 1",
"opacity":1,
"type":"tilelayer",
- "visible":true,
+ "visible":false,
"width":25,
"x":0,
"y":0
@@ -33,26 +33,158 @@
"name":"Object Layer 1",
"objects":[
{
+ "height":64,
+ "id":2,
+ "name":"window",
+ "rotation":0,
+ "type":"",
+ "visible":true,
+ "width":64,
+ "x":283,
+ "y":59
+ },
+ {
"height":16,
- "id":1,
- "name":"player",
+ "id":4,
+ "name":"alarm",
"rotation":0,
"type":"",
"visible":true,
"width":16,
- "x":144,
- "y":96
+ "x":-26,
+ "y":-8
},
{
- "height":32,
- "id":2,
+ "height":64,
+ "id":5,
+ "name":"window",
+ "rotation":0,
+ "type":"",
+ "visible":true,
+ "width":64,
+ "x":51,
+ "y":56
+ },
+ {
+ "height":64,
+ "id":6,
+ "name":"window",
+ "rotation":0,
+ "type":"",
+ "visible":true,
+ "width":64,
+ "x":381,
+ "y":58
+ },
+ {
+ "height":64,
+ "id":7,
+ "name":"window",
+ "rotation":0,
+ "type":"",
+ "visible":true,
+ "width":64,
+ "x":165,
+ "y":54
+ },
+ {
+ "height":64,
+ "id":8,
+ "name":"window",
+ "rotation":0,
+ "type":"",
+ "visible":true,
+ "width":64,
+ "x":-41,
+ "y":71
+ },
+ {
+ "height":64,
+ "id":9,
+ "name":"window",
+ "rotation":0,
+ "type":"",
+ "visible":true,
+ "width":64,
+ "x":81,
+ "y":135
+ },
+ {
+ "height":64,
+ "id":10,
+ "name":"window",
+ "rotation":0,
+ "type":"",
+ "visible":true,
+ "width":64,
+ "x":347,
+ "y":136
+ },
+ {
+ "height":64,
+ "id":11,
+ "name":"window",
+ "rotation":0,
+ "type":"",
+ "visible":true,
+ "width":64,
+ "x":210,
+ "y":142
+ },
+ {
+ "height":64,
+ "id":12,
+ "name":"window",
+ "rotation":0,
+ "type":"",
+ "visible":true,
+ "width":64,
+ "x":-19,
+ "y":161
+ },
+ {
+ "height":64,
+ "id":13,
+ "name":"window",
+ "rotation":0,
+ "type":"",
+ "visible":true,
+ "width":64,
+ "x":65,
+ "y":-33
+ },
+ {
+ "height":64,
+ "id":14,
+ "name":"window",
+ "rotation":0,
+ "type":"",
+ "visible":true,
+ "width":64,
+ "x":215,
+ "y":-31
+ }],
+ "opacity":1,
+ "type":"objectgroup",
+ "visible":true,
+ "x":0,
+ "y":0
+ },
+ {
+ "draworder":"topdown",
+ "id":3,
+ "name":"Object Layer 2",
+ "objects":[
+ {
+ "height":16,
+ "id":15,
"name":"player",
"rotation":0,
"type":"",
"visible":true,
- "width":32,
- "x":256,
- "y":144
+ "width":16,
+ "x":190,
+ "y":112
}],
"opacity":1,
"type":"objectgroup",
@@ -60,8 +192,8 @@
"x":0,
"y":0
}],
- "nextlayerid":3,
- "nextobjectid":3,
+ "nextlayerid":4,
+ "nextobjectid":16,
"orientation":"orthogonal",
"renderorder":"right-down",
"tiledversion":"1.10.0",
diff --git a/res/alarm.wav b/res/alarm.wav
new file mode 100644
index 0000000..d8bb99b
--- /dev/null
+++ b/res/alarm.wav
Binary files differ
diff --git a/res/cursor.bmp b/res/cursor.bmp
new file mode 100644
index 0000000..0d381c4
--- /dev/null
+++ b/res/cursor.bmp
Binary files differ
diff --git a/res/glass.wav b/res/glass.wav
new file mode 100644
index 0000000..bea3d4a
--- /dev/null
+++ b/res/glass.wav
Binary files differ
diff --git a/res/piou.wav b/res/piou.wav
new file mode 100644
index 0000000..21772a2
--- /dev/null
+++ b/res/piou.wav
Binary files differ
diff --git a/res/window.bmp b/res/window.bmp
new file mode 100644
index 0000000..26f5932
--- /dev/null
+++ b/res/window.bmp
Binary files differ
diff --git a/res/windowclean.bmp b/res/windowclean.bmp
new file mode 100644
index 0000000..4b98fb5
--- /dev/null
+++ b/res/windowclean.bmp
Binary files differ
diff --git a/src/alarm.c b/src/alarm.c
new file mode 100644
index 0000000..247f369
--- /dev/null
+++ b/src/alarm.c
@@ -0,0 +1,6 @@
+#include "entityimpl.h"
+#include "lzr.h"
+
+IMPL_INIT(alarm) {
+ LZR_PlayMusic("res/alarm.wav", -1);
+}
diff --git a/src/entity.c b/src/entity.c
index 75ad7ec..07bea1e 100644
--- a/src/entity.c
+++ b/src/entity.c
@@ -47,7 +47,7 @@ Entity *
entity_place_meeting(Entity *this, struct Game *g, unsigned int type)
{
for (__auto_type i = 0; i < MAX_ENTITIES; i++)
- if (this != &g->entities[i] && g->entities[i].type == type &&
+ if (this != &g->entities[i] && (type == -1u || g->entities[i].type == type) &&
entity_meet(this, &g->entities[i]))
return &g->entities[i];
return NULL;
diff --git a/src/entity.h b/src/entity.h
index 01230d5..f4ed7cd 100644
--- a/src/entity.h
+++ b/src/entity.h
@@ -8,6 +8,7 @@ struct Entity {
unsigned long uuid;
void (*update)(Entity *this, struct Game *g);
void (*draw)(Entity *this, struct Game *g);
+ void (*smash)(Entity *this, struct Game *g);
unsigned int type;
int pos[2];
double vel[2];
@@ -15,6 +16,12 @@ struct Entity {
int width;
int height;
bool ignore_solids;
+ bool broken;
+ union {
+ struct {
+ double recoil;
+ } player;
+ };
};
unsigned int entity_type(const char *typename);
diff --git a/src/entityimpl.h b/src/entityimpl.h
index afc9dc2..e21462d 100644
--- a/src/entityimpl.h
+++ b/src/entityimpl.h
@@ -5,12 +5,13 @@
#include "entitytag.h"
#include <string.h>
-//[[maybe_unused]] static void *_draw;
-//[[maybe_unused]] static void *_update;
+[[maybe_unused]] static void *_draw;
+[[maybe_unused]] static void *_update;
+[[maybe_unused]] static void *_smash;
#define IMPL(X) static void X(Entity *this, Game *g); \
+__attribute__((constructor)) static void init_##X() { _##X = X; } \
static void X([[maybe_unused]] Entity *this, [[maybe_unused]] Game *g)
-/*__attribute__((constructor)) static void init_##X() { _##X = X; } \ */
#define IMPL_INIT(X) static void init(Entity *this, int x, int y); \
__attribute__((constructor)) static void init_tag() { \
@@ -20,8 +21,9 @@ __attribute__((constructor)) static void init_tag() { \
static void _init(Entity *this); \
static void init(Entity *this, int x, int y) { \
memset(this, 0, sizeof(*this)); \
- this->update = update; \
- this->draw = draw; \
+ this->update = _update; \
+ this->draw = _draw; \
+ this->smash = _smash; \
this->pos[0] = x; \
this->pos[1] = y; \
this->type = entity_type(#X); \
diff --git a/src/main.c b/src/main.c
index ff51bb3..7aaf2a0 100644
--- a/src/main.c
+++ b/src/main.c
@@ -28,12 +28,17 @@ main([[maybe_unused]] int argc, [[maybe_unused]] char **argv)
}
game_init(game);
+ if (LZR_SoundLoad("res/piou.wav", 10.0) < 0)
+ return 1;
+ if (LZR_SoundLoad("res/glass.wav", 10.0) < 0)
+ return 1;
+
while (!LZR_ShouldQuit()) {
LZR_CycleEvents();
game_update(game);
LZR_DrawBegin();
- LZR_DrawSetColor(0, 0, 0, 0);
+ LZR_DrawSetColor(0.4, 0.3, 0.3, 0);
LZR_DrawClear();
game_draw(game);
LZR_DrawEnd();
diff --git a/src/player.c b/src/player.c
index b51572b..de51b1c 100644
--- a/src/player.c
+++ b/src/player.c
@@ -1,17 +1,29 @@
+#include "entity.h"
#include "entityimpl.h"
+#include "lzr.h"
IMPL(draw) {
- LZR_DrawSetColor(1, 1, 1, 1);
- LZR_DrawRectangle(true, this->pos[0] - this->width / 2,
- this->pos[1] - this->height / 2,
- this->width, this->height);
+ const float a = 1.0 - this->player.recoil;
+ LZR_DrawSetColor(1, a, a, 1);
+ const LZR_ImageDrawSettings stg =
+ {0, 0, -1, -1, 1.0, 1.0, 0.0, true,
+ LZR_GetTick() / 8 % 2, (LZR_GetTick() + 4) / 8 % 2};
+ LZR_DrawImageEx(LZR_IMAGE("res/cursor.bmp"), this->pos[0], this->pos[1],
+ stg);
}
IMPL(update) {
- this->vel[0] = LZR_BUTTON(RIGHT) - LZR_BUTTON(LEFT);
- entity_move(this, g);
+ LZR_MousePosition(&this->pos[0], &this->pos[1]);
+ this->player.recoil *= 0.9;
+ if (LZR_BUTTON(MOUSE_L) && this->player.recoil < 0.1) {
+ this->player.recoil = 1.0;
+ LZR_PlaySound(0);
+ __auto_type e = entity_place_meeting(this, g, -1);
+ if (e != NULL && e->smash != NULL)
+ e->smash(e, g);
+ }
}
IMPL_INIT(player) {
- this->height = this->width = 12;
+ this->width = this->height = 1;
}
diff --git a/src/window.c b/src/window.c
new file mode 100644
index 0000000..9eebb36
--- /dev/null
+++ b/src/window.c
@@ -0,0 +1,19 @@
+#include "entityimpl.h"
+#include "lzr.h"
+
+IMPL(draw) {
+ const LZR_ImageDrawSettings stg =
+ {0, 0, -1, -1, 1.0, 1.0, 0.0, true, false, false};
+ LZR_DrawSetColor(1, 1, 1, 1);
+ LZR_DrawImageEx(LZR_IMAGE(this->broken ? "res/window.bmp" : "res/windowclean.bmp"),
+ this->pos[0], this->pos[1], stg);
+}
+
+IMPL(smash) {
+ LZR_PlaySound(1);
+ this->broken = 1;
+}
+
+IMPL_INIT(window) {
+ this->width = this->height = 64;
+}