diff options
author | kdx <kikoodx@paranoici.org> | 2023-05-04 10:17:15 +0200 |
---|---|---|
committer | kdx <kikoodx@paranoici.org> | 2023-05-04 10:17:15 +0200 |
commit | 27a17adee2cbd332efef35e276672090c51afbf4 (patch) | |
tree | 4010f6f81ebd9591f2587d2ddc57860d968ce859 | |
parent | ade15c6bc63cf87f7d20ed5a3893360cd0a8f596 (diff) | |
download | study-sttky-27a17adee2cbd332efef35e276672090c51afbf4.tar.gz |
i like it
-rw-r--r-- | map/tset.tsj | 8 | ||||
-rw-r--r-- | res/pal.png | bin | 75 -> 82 bytes | |||
-rw-r--r-- | res/tset.png | bin | 86 -> 166 bytes | |||
-rw-r--r-- | src/camera.c | 14 | ||||
-rw-r--r-- | src/main.c | 20 | ||||
-rw-r--r-- | src/map.c | 6 | ||||
-rw-r--r-- | src/player.c | 4 |
7 files changed, 37 insertions, 15 deletions
diff --git a/map/tset.tsj b/map/tset.tsj index e455c7c..dc47d67 100644 --- a/map/tset.tsj +++ b/map/tset.tsj @@ -6,8 +6,8 @@ "width":16 }, "image":"..\/res\/tset.png", - "imageheight":16, - "imagewidth":32, + "imageheight":9, + "imagewidth":27, "margin":0, "name":"tset", "spacing":0, @@ -22,6 +22,10 @@ { "id":1, "type":"spike" + }, + { + "id":2, + "type":"spike" }], "tilewidth":9, "type":"tileset", diff --git a/res/pal.png b/res/pal.png Binary files differindex e35b859..7290652 100644 --- a/res/pal.png +++ b/res/pal.png diff --git a/res/tset.png b/res/tset.png Binary files differindex f4193a3..149e764 100644 --- a/res/tset.png +++ b/res/tset.png diff --git a/src/camera.c b/src/camera.c index 9dd95da..87d1f2c 100644 --- a/src/camera.c +++ b/src/camera.c @@ -2,13 +2,12 @@ #include "cfg.h" #include "clamp.h" #include "map.h" +#include <math.h> #include <stdlib.h> static double cam[2] = {0, 0}; static double off[2] = {0, 0}; -int shake = 0; - void camera_init(void) { @@ -30,19 +29,20 @@ camera_update(double dest[2]) cam[i] += 0.1 * (dest[i] - cam[i]); cam[0] = clamp(DWIDTH/2.0, map_width() * TSIZE - DWIDTH/2.0, cam[0]); cam[1] = clamp(DHEIGHT/2.0, map_height() * TSIZE - DHEIGHT/2.0, cam[1]); - off[0] = shake ? (2 - rand() % 5) : 0; - off[1] = shake ? (2 - rand() % 5) : 0; - shake -= (shake > 0); + if (rand() % 60 == 0) + off[1] = rand() % 10; + else + off[1] -= (off[1] > 0); } int camera_x(double scale) { - return -cam[0] * scale + DWIDTH / 2.0 + off[0]; + return -cam[0] * scale + DWIDTH / 2.0 + off[0] - 2 + rand() % 5; } int camera_y(double scale) { - return -cam[1] * scale + DHEIGHT / 2.0 + off[1]; + return -cam[1] * scale + DHEIGHT / 2.0 + off[1] - 2 + rand() % 5; } @@ -13,6 +13,7 @@ static Game *game = NULL; static void deinit(void); static int main_loop(void *udata); +static void acid(void); int main(int argc, char **argv) @@ -84,8 +85,27 @@ main_loop(void *udata) return 1; pxCls(0); game_draw(game); + acid(); pxFlip(); if (TZR_DrawEnd()) return 1; return 0; } + +static void +acid(void) +{ + PxCol cols[8] = { 0, 1, 2, 3, 4, 5, 6, 7 }; + for (int i = 0; i < 1024; i++) { + const int i = rand() % 8; + const int k = rand() % 8; + if (i == k) + continue; + cols[i] ^= cols[k]; + cols[k] ^= cols[i]; + cols[i] ^= cols[k]; + } + for (int i = 0; i < 8; i++) + pxSpal(i, cols[i]); + pxSpal(0, 0); +} @@ -84,8 +84,6 @@ draw_layer(const Tiled2cLayer *layer) { extern const PxSpr spr_tset; const int tset_w = spr_tset.w; - const int ox = camera_x(layer->parallaxx); - const int oy = camera_y(layer->parallaxy); for (int y = 0; y < map_height(); y++) for (int x = 0; x < map_width(); x++) { const unsigned tile = @@ -93,8 +91,8 @@ draw_layer(const Tiled2cLayer *layer) if (tile == 0) continue; const unsigned vtile = tile_visual(tile); - const int dx = ox + x * TSIZE; - const int dy = oy + y * TSIZE; + const int dx = camera_x(layer->parallaxx) + x * TSIZE; + const int dy = camera_y(layer->parallaxy) + y * TSIZE; const int ix = vtile % (tset_w / TSIZE) * TSIZE; const int iy = vtile / (tset_w / TSIZE) * TSIZE; pxSpr(&spr_tset, dx, dy, ix, iy, TSIZE, TSIZE); diff --git a/src/player.c b/src/player.c index 5df62e5..cdf42c7 100644 --- a/src/player.c +++ b/src/player.c @@ -30,7 +30,7 @@ IMPL(update) { IMPL(draw) { IMPL_UNUSED; extern const PxSpr spr_player; - const int dx = this->pos[0] - 2 - camera_x(1); - const int dy = this->pos[1] - 2 - camera_y(1); + const int dx = this->pos[0] - 2 + camera_x(1); + const int dy = this->pos[1] - 2 + camera_y(1); pxSpr(&spr_player, dx, dy, 0, 0, -1, -1, false, false); } |