From 5a351056409c64d6c03d5f3f6de9bf179c884e50 Mon Sep 17 00:00:00 2001 From: Samuel Walker Date: Thu, 29 Aug 2024 18:49:38 -0600 Subject: [PATCH] start of movement and map --- src/main.c | 39 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-) diff --git a/src/main.c b/src/main.c index d5efa9f..e42e390 100644 --- a/src/main.c +++ b/src/main.c @@ -1,7 +1,21 @@ #include +#define SPEED 2 + Line l; +const u8[][] = [[1,1,1,1,1,1,1,1,1,1], + [1,0,0,0,0,0,0,0,0,1], + [1,1,1,1,0,0,1,1,1,1], + [1,0,0,1,0,0,1,0,0,1], + [1,0,0,0,0,0,1,0,0,1], + [1,0,0,1,0,0,1,1,0,1], + [1,1,1,1,0,0,1,0,0,1], + [1,0,0,0,0,0,0,0,0,1], + [1,0,0,0,0,0,1,0,0,1], + [1,1,1,1,1,1,1,1,1,1]]; + + void render(){ //Clear the bitmap BMP_clear(); @@ -21,18 +35,38 @@ void render(){ l.pt2.y = 0; } + SYS_doVBlankProcess(); + } void update(){ + u16 joy = JOY_readJoypad(JOY_1); + if(joy & BUTTON_LEFT) { + l.pt1.x -= SPEED; + } + if(joy & BUTTON_RIGHT) { + l.pt1.x += SPEED; + } + if(joy & BUTTON_UP) { + l.pt1.y -= SPEED; + } + if(joy & BUTTON_DOWN) { + l.pt1.y += SPEED; + } +} - +void initVDP(){ + SYS_disableInts(); + VDP_setPlaneSize(64,32,TRUE); + SYS_enableInts(); } int main() { + initVDP(); //Initialise the bitmap engine - BMP_init(TRUE, BG_A, PAL0, FALSE); + BMP_init(FALSE, BG_A, PAL0, FALSE); //Set the colour of the line. We are using pallete 0 for the bitmap, so we have 0->15. 15 is used for white text, so we set an unused pallet colour, 14 to blue - RGB 0000FF. u16 colour_blue = RGB24_TO_VDPCOLOR(0x0000ff); @@ -52,6 +86,7 @@ int main() while(TRUE) { render(); + update(); } return 0; } \ No newline at end of file