From af7c842d19c318b8958e1acecce6ff0a7c7b0591 Mon Sep 17 00:00:00 2001 From: John Tsiombikas Date: Sun, 30 Oct 2022 12:05:57 +0200 Subject: [PATCH] laser shots --- src/data.h | 6 +++++- src/gamescr.c | 14 +++++++++++++- src/gba/main.c | 2 ++ src/logoscr.c | 1 - 4 files changed, 20 insertions(+), 3 deletions(-) diff --git a/src/data.h b/src/data.h index 11fe418..2e3b1da 100644 --- a/src/data.h +++ b/src/data.h @@ -27,7 +27,11 @@ enum { SPRID_LEDGRN = SPRID(56, 16), /*SPRID_ENEMY = SPRID(0, 64)*/ SPRID_ENEMY0 = SPRID(0, 32), - SPRID_HUSK = SPRID(112, 64) + SPRID_HUSK = SPRID(112, 64), + SPRID_LAS0 = SPRID(0, 64), + SPRID_LAS1 = SPRID(32, 64), + SPRID_LAS2 = SPRID(64, 64), + SPRID_LAS3 = SPRID(0, 96) }; /* main game data */ diff --git a/src/gamescr.c b/src/gamescr.c index e467381..4fce8f7 100644 --- a/src/gamescr.c +++ b/src/gamescr.c @@ -19,6 +19,7 @@ #define P_RATE 500 #define E_RATE 500 +#define SHOT_TIME 50 static int gamescr_start(void); static void gamescr_stop(void); @@ -284,8 +285,8 @@ static int update(void) pos[0] += fwd[0]; pos[1] += fwd[1]; } + if((keystate & BN_B) && (timer_msec - last_shot >= P_RATE)) { - emuprint("pew"); last_shot = timer_msec; for(i=0; i= 0) { @@ -372,6 +373,17 @@ static int update(void) } enemy++; } + if(timer_msec - last_shot <= SHOT_TIME) { + spr_oam(oam, dynspr_base + snum++, SPRID_LAS0, -8, 118, SPR_SZ32 | SPR_256COL); + spr_oam(oam, dynspr_base + snum++, SPRID_LAS1, 22, 103, SPR_SZ32 | SPR_256COL); + spr_oam(oam, dynspr_base + snum++, SPRID_LAS2, 54, 88, SPR_SZ32 | SPR_256COL); + spr_oam(oam, dynspr_base + snum++, SPRID_LAS3, 86, 72, SPR_SZ32 | SPR_256COL); + + spr_oam(oam, dynspr_base + snum++, SPRID_LAS0, 240 + 8 - 32, 118, SPR_SZ32 | SPR_256COL | SPR_HFLIP); + spr_oam(oam, dynspr_base + snum++, SPRID_LAS1, 240 - 22 - 32, 103, SPR_SZ32 | SPR_256COL | SPR_HFLIP); + spr_oam(oam, dynspr_base + snum++, SPRID_LAS2, 240 - 54 - 32, 88, SPR_SZ32 | SPR_256COL | SPR_HFLIP); + spr_oam(oam, dynspr_base + snum++, SPRID_LAS3, 240 - 86 - 32, 72, SPR_SZ32 | SPR_256COL | SPR_HFLIP); + } for(i=snum; i