summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkdx <kikoodx@paranoici.org>2023-05-04 15:41:25 +0200
committerkdx <kikoodx@paranoici.org>2023-05-04 15:41:25 +0200
commit89362ef1dc7223941d3267d50813544cef09672e (patch)
treec8cb7766d3bb926d37669757046254edab609fcf
parent963183139997c2fe26a50399451bb47c3a3e9efc (diff)
downloadstudy-sttky-89362ef1dc7223941d3267d50813544cef09672e.tar.gz
my best game yet
-rw-r--r--src/camera.c6
-rw-r--r--src/px.c10
2 files changed, 9 insertions, 7 deletions
diff --git a/src/camera.c b/src/camera.c
index a862133..5cca51b 100644
--- a/src/camera.c
+++ b/src/camera.c
@@ -8,7 +8,8 @@
static double cam[2] = {0, 0};
static double off[2] = {0, 0};
-int flip_offset;
+int flip_offset_x;
+int flip_offset_y;
void
camera_init(void)
@@ -31,7 +32,8 @@ 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]);
- flip_offset += rand();
+ flip_offset_x += rand() % 15 - 8;
+ flip_offset_y += rand() % 15 - 8;
}
int
diff --git a/src/px.c b/src/px.c
index 6397386..8b6e531 100644
--- a/src/px.c
+++ b/src/px.c
@@ -57,7 +57,8 @@ pxDeinit(void)
int
pxFlip(void)
{
- extern int flip_offset;
+ extern int flip_offset_x;
+ extern int flip_offset_y;
uint8_t *pixels = NULL;
int pitch = 0;
@@ -66,13 +67,12 @@ pxFlip(void)
return -1;
}
- printf("--------------\n");
for (int y = 0; y < PX_HEIGHT; y++) {
- const int iy = (y + flip_offset) % PX_HEIGHT;
- printf("%d\n", iy);
+ const int iy = (y + flip_offset_y) % PX_HEIGHT;
for (int x = 0; x < PX_WIDTH; x++) {
+ const int ax = (x + flip_offset_x) % PX_WIDTH;
const int ix = x << 2;
- PxCol col = pxbuf[x + iy * PX_WIDTH];
+ PxCol col = pxbuf[ax + iy * PX_WIDTH];
if (pxpal[col].spal)
col = pxpal[col].spal - 1;
pixels[ix + y * pitch + 0] = pxpal[col].b;