summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkdx <kikoodx@paranoici.org>2024-02-06 22:46:57 +0100
committerkdx <kikoodx@paranoici.org>2024-02-06 22:46:57 +0100
commit26fe60792c7cf8ce2abbec738786de63b75bf427 (patch)
tree46698a2eebd271154258c0780f9641ae243968cd
parent164ee8ddae61586b5afc51da403ade637f1b512d (diff)
downloadmaximalistmanifesto-26fe60792c7cf8ce2abbec738786de63b75bf427.tar.gz
cmyk test
-rw-r--r--inc/__.h1
-rw-r--r--inc/color.h5
-rw-r--r--inc/game.h2
-rw-r--r--map/3.tmj4
-rw-r--r--src/color.c22
-rw-r--r--src/font.c4
-rw-r--r--src/game.c14
-rw-r--r--src/main.c31
-rw-r--r--src/player.c2
-rw-r--r--src/tile.c2
10 files changed, 71 insertions, 16 deletions
diff --git a/inc/__.h b/inc/__.h
index 1c2f7f9..88b3303 100644
--- a/inc/__.h
+++ b/inc/__.h
@@ -11,3 +11,4 @@
#include "game.h"
#include "e.h"
#include "font.h"
+#include "color.h"
diff --git a/inc/color.h b/inc/color.h
new file mode 100644
index 0000000..1d6deb4
--- /dev/null
+++ b/inc/color.h
@@ -0,0 +1,5 @@
+#pragma once
+void setbgcolor(float r, float g, float b);
+void setfgcolor(float r, float g, float b);
+void bgcolor();
+void fgcolor();
diff --git a/inc/game.h b/inc/game.h
index 25e1def..251abe0 100644
--- a/inc/game.h
+++ b/inc/game.h
@@ -29,7 +29,7 @@ void g_map_next();
void g_map_restart();
Map *g_map();
void g_update();
-void g_draw();
+void g_draw(int x, int y);
Entity *g_new_entity(const char *type, bool init);
Entity *g_new_entity_t2c(const Tiled2cObject *t2c);
Entity *g_get_entity(const char *type);
diff --git a/map/3.tmj b/map/3.tmj
index 8abb8ff..3e03789 100644
--- a/map/3.tmj
+++ b/map/3.tmj
@@ -2277,8 +2277,8 @@
"x":0,
"y":0
}],
- "nextlayerid":12,
- "nextobjectid":498,
+ "nextlayerid":14,
+ "nextobjectid":504,
"orientation":"orthogonal",
"renderorder":"right-down",
"tiledversion":"1.10.2",
diff --git a/src/color.c b/src/color.c
new file mode 100644
index 0000000..a7573fe
--- /dev/null
+++ b/src/color.c
@@ -0,0 +1,22 @@
+static float _fr, _fg, _fb;
+static float _br, _bg, _bb;
+
+void setfgcolor(float r, float g, float b) {
+ _fr = r;
+ _fg = g;
+ _fb = b;
+}
+
+void setbgcolor(float r, float g, float b) {
+ _br = r;
+ _bg = g;
+ _bb = b;
+}
+
+void fgcolor() {
+ TZR_DrawSetColor(_fr, _fg, _fb);
+}
+
+void bgcolor() {
+ TZR_DrawSetColor(_br, _bg, _bb);
+}
diff --git a/src/font.c b/src/font.c
index 661366d..a7a4af2 100644
--- a/src/font.c
+++ b/src/font.c
@@ -34,10 +34,10 @@ font_center(i32 x, i32 y, const char *fmt, ...)
va_start(va, fmt);
vsnprintf(buf, sizeof(buf) - 1, fmt, va);
va_end(va);
- TZR_DrawSetColor(0, 0, 0);
+ bgcolor();
TZR_DrawRectangle(x, y,
strlen(buf) * cfg.tile_width, cfg.tile_height,
.fill=true, .center=true);
- TZR_DrawSetColor(1, 1, 1);
+ fgcolor();
font_draw(buf, x - strlen(buf)*cfg.tile_width/2,y - cfg.tile_height/2);
}
diff --git a/src/game.c b/src/game.c
index c4ff9ff..5f18fe9 100644
--- a/src/game.c
+++ b/src/game.c
@@ -53,15 +53,15 @@ void g_update() {
}
}
-void g_draw() {
- int x = g_map()->t2c->width * cfg.tile_width/2 - cfg.display_width/2;
- int y = g_map()->t2c->height * cfg.tile_height/2 - cfg.display_height/2;
+void g_draw(int x, int y) {
+ int cx = g_map()->t2c->width * cfg.tile_width/2 - cfg.display_width/2;
+ int cy = g_map()->t2c->height * cfg.tile_height/2 - cfg.display_height/2;
if (g->shake) {
- x += g->shake - rand() % (g->shake * 2);
- y += g->shake - rand() % (g->shake * 2);
+ cx += g->shake - rand() % (g->shake * 2);
+ cy += g->shake - rand() % (g->shake * 2);
}
- TZR_SetCamera(x, y);
- TZR_DrawSetColor(1, 1, 1);
+ TZR_SetCamera(x + cx, y + cy);
+ fgcolor();
map_draw(g_map(), v2_zero());
PROCESS(draw_begin);
PROCESS(draw);
diff --git a/src/main.c b/src/main.c
index b2cc8f7..95f2628 100644
--- a/src/main.c
+++ b/src/main.c
@@ -78,10 +78,37 @@ static int _main_loop([[maybe_unused]] void *udata) {
return 1;
assert(TZR_DrawBegin() == 0);
- TZR_DrawSetColor(0, 0, 0);
+ TZR_DrawSetColor(1, 1, 1);
TZR_DrawClear();
- g_draw();
+ vec2 v = v2(cfg.tile_width, 0);
+ const f32 r = (float)(TZR_GetTick() % 768) / 256;
+
+ TZR_BlendMode(SDL_BLENDMODE_MUL);
+ {
+ setbgcolor(1, 1, 1);
+ setfgcolor(0, 0, 0);
+ g_draw(0, 0);
+ }
+ {
+ vec2 c = v2_round(v2_transform(v, m3_rotating(r / 0.1592)));
+ setbgcolor(1, 1, 1);
+ setfgcolor(0, 1, 1);
+ g_draw(c.x, c.y);
+ }
+ {
+ vec2 c = v2_round(v2_transform(v, m3_rotating((r + 0.333) / 0.1592)));
+ setbgcolor(1, 1, 1);
+ setfgcolor(1, 0, 1);
+ g_draw(c.x, c.y);
+ }
+ {
+ vec2 c = v2_round(v2_transform(v, m3_rotating((r + 0.666) / 0.1592)));
+ setbgcolor(1, 1, 1);
+ setfgcolor(1, 1, 0);
+ g_draw(c.x, c.y);
+ }
+ TZR_BlendMode(SDL_BLENDMODE_BLEND);
assert(TZR_DrawEnd() == 0);
return 0;
diff --git a/src/player.c b/src/player.c
index 92cbd5a..72ea1a9 100644
--- a/src/player.c
+++ b/src/player.c
@@ -100,7 +100,7 @@ UPDATE {
}
DRAW {
- TZR_DrawSetColor(1, 1, 1);
+ fgcolor();
if (this->dead && this->tick / 4 % 2 == 0)
return;
TZR_DrawImage(TZR_RES("res/player.bmp"), v2_unpack(POS), .center=true);
diff --git a/src/tile.c b/src/tile.c
index 7b3d0c7..bbcddfb 100644
--- a/src/tile.c
+++ b/src/tile.c
@@ -3,7 +3,7 @@ NAME(tile);
DRAW {
if (!this->tile)
return;
- TZR_DrawSetColor(1, 1, 1);
+ fgcolor();
const auto pos = v2_sub(POS, v2(cfg.tile_width/2., cfg.tile_height/2.));
auto tile = this->tile;
if (this->flip_x)