From 48e1ff047596297e767b1faa930298e6c7830b39 Mon Sep 17 00:00:00 2001 From: Samuel Walker Date: Fri, 30 Aug 2024 15:54:02 -0600 Subject: [PATCH] better movement --- src/main.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/src/main.c b/src/main.c index 2dcfb84..4e7d065 100644 --- a/src/main.c +++ b/src/main.c @@ -4,6 +4,7 @@ Line l; s16 angle = 0; +s16 x, y; const u8 map[10][10] = {{1,1,1,1,1,1,1,1,1,1}, {1,0,0,0,0,0,0,0,0,1}, @@ -141,6 +142,8 @@ void mapscan(){ void render(){ + l.pt1.x = x / 10; + l.pt1.y = y / 10; //Clear the bitmap BMP_clear(); @@ -165,13 +168,13 @@ void render(){ BMP_flip(1); //Increment the destination y coordinate - l.pt2.y = l.pt2.y + 2; + //l.pt2.y = l.pt2.y + 2; //Reset the destination y coordinate if it hits 160 - if (l.pt2.y == 160) - { - l.pt2.y = 0; - } + //if (l.pt2.y == 160) + //{ + //l.pt2.y = 0; + //} SYS_doVBlankProcess(); @@ -191,15 +194,15 @@ void update(){ s16 ind = (int)((float)angle/360.0f*1024.0f); fix16 dy = sinFix16(ind); fix16 dx = cosFix16(ind); - l.pt1.y += fix16ToInt(fix16Mul(dy, FIX16(SPEED))); - l.pt1.x += fix16ToInt(fix16Mul(dx, FIX16(SPEED))); + y += fix16ToInt(fix16Mul(dy, FIX16(SPEED))); + x += fix16ToInt(fix16Mul(dx, FIX16(SPEED))); } if(joy & BUTTON_DOWN) { s16 ind = (int)((float)angle/360.0f*1024.0f); fix16 dy = sinFix16(ind); fix16 dx = cosFix16(ind); - l.pt1.y -= fix16ToInt(fix16Mul(dy, FIX16(SPEED))); - l.pt1.x -= fix16ToInt(fix16Mul(dx, FIX16(SPEED))); + y -= fix16ToInt(fix16Mul(dy, FIX16(SPEED))); + x -= fix16ToInt(fix16Mul(dx, FIX16(SPEED))); } } @@ -211,6 +214,8 @@ void initVDP(){ int main() { + x = 150; + y = 150; initVDP(); //Initialise the bitmap engine