diff options
author | kdx <kikoodx@paranoici.org> | 2024-02-06 22:46:57 +0100 |
---|---|---|
committer | kdx <kikoodx@paranoici.org> | 2024-02-06 22:46:57 +0100 |
commit | 26fe60792c7cf8ce2abbec738786de63b75bf427 (patch) | |
tree | 46698a2eebd271154258c0780f9641ae243968cd | |
parent | 164ee8ddae61586b5afc51da403ade637f1b512d (diff) | |
download | maximalistmanifesto-26fe60792c7cf8ce2abbec738786de63b75bf427.tar.gz |
cmyk test
-rw-r--r-- | inc/__.h | 1 | ||||
-rw-r--r-- | inc/color.h | 5 | ||||
-rw-r--r-- | inc/game.h | 2 | ||||
-rw-r--r-- | map/3.tmj | 4 | ||||
-rw-r--r-- | src/color.c | 22 | ||||
-rw-r--r-- | src/font.c | 4 | ||||
-rw-r--r-- | src/game.c | 14 | ||||
-rw-r--r-- | src/main.c | 31 | ||||
-rw-r--r-- | src/player.c | 2 | ||||
-rw-r--r-- | src/tile.c | 2 |
10 files changed, 71 insertions, 16 deletions
@@ -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(); @@ -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); @@ -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); +} @@ -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); } @@ -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); @@ -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); @@ -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) |