From cd7300f0a3e810d42035e623aec5297ef1476ca5 Mon Sep 17 00:00:00 2001 From: Devine Lu Linvega Date: Wed, 23 Sep 2020 10:34:41 -0700 Subject: [PATCH] Fixed issue with position --- nasu6.c | 21 +++++++++++++++------ sprite.chr | Bin 4096 -> 4096 bytes 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/nasu6.c b/nasu6.c index 7224c3c..dc98cd2 100644 --- a/nasu6.c +++ b/nasu6.c @@ -43,6 +43,14 @@ setpt(Point* p, int x, int y) return p; } +Point* +divpt(Point* p, int v) +{ + p->x /= v; + p->y /= v; + return p; +} + /* noodle */ void @@ -152,6 +160,7 @@ handle_mouse(SDL_Event* event, Brush* b) case SDL_MOUSEMOTION: if(b->down) { setpt(&b->pos, event->motion.x, event->motion.y); + divpt(&b->pos, ZOOM); pixel(pixels, b->pos, 0xFFFFFF); setpt(&b->prev, b->pos.x, b->pos.y); } @@ -198,13 +207,13 @@ paint(uint32_t* dst, int id, int color) p.x = px + tx + (id % 8); p.y = py + ty + ((id % 64) / 8); if(color == 1) - pixel(dst, p, 0x00FFFF); + pixel(dst, p, 0x72DEC2); else if(color == 2) - pixel(dst, p, 0xFF0000); + pixel(dst, p, 0xFFFFFF); else if(color == 3) - pixel(dst, p, 0x00FF00); + pixel(dst, p, 0x333333); else - pixel(dst, p, 0x0000FF); + pixel(dst, p, 0x000000); } int @@ -221,11 +230,11 @@ load(FILE* f) } id = 0; - for(b = 0; b < (1024 * 4) - 16; b += 16) { + for(b = 0; b < 1024 * 4; b += 16) { for(i = 0; i < 8; i++) { for(j = 7; j >= 0; j--) { ch1 = buffer[b + i]; - ch2 = buffer[b + i + 16]; + ch2 = buffer[b + i + 8]; color = ((ch1 >> j) & 0x1) + (((ch2 >> j) & 0x1) << 1); paint(pixels, id, color); id++; diff --git a/sprite.chr b/sprite.chr index 070d886b90c9f27320abf5b051f4b56f5aeee039..e25e2ba2fbd6980c9036cbf48ab159df7dc0ac0f 100644 GIT binary patch delta 25 YcmZorXiyON0|pF0U=Icx1wQZt0G4|Sa{vGU delta 25 TcmZorXiyMfKm!{EKJWtoBn$%)