From 10472f61d97ee93733048293873255876b0c10c5 Mon Sep 17 00:00:00 2001 From: Trevor Boddy Date: Sat, 24 Sep 2022 15:54:09 -0400 Subject: [PATCH] bg and stage work --- res/bg/1.png | Bin 2363 -> 2565 bytes res/bg/1l.png | Bin 0 -> 2439 bytes res/bg/1r.png | Bin 0 -> 2473 bytes res/font.png | Bin 3467 -> 3474 bytes res/resources.res | 2 + src/background.h | 30 ++++++++-- src/chrome.h | 11 ++++ src/enemies.h | 5 +- src/stage.h | 141 ++++++++++++++++++++++++++++++++++------------ 9 files changed, 147 insertions(+), 42 deletions(-) create mode 100644 res/bg/1l.png create mode 100644 res/bg/1r.png diff --git a/res/bg/1.png b/res/bg/1.png index 996286565ef054211a948f7edfc1a59567f8dc8c..612d0f2f4df4594acce6ff7fb4a7afa281a200b7 100644 GIT binary patch delta 904 zcmdlj)GD&!3lo<~h@pv*;F)Q+Pr`-R4<}ZWLZ3Ef0TXGY9zZdeqWjy&PJ9V)>cU*qoTJDAoi~EC52lTYF zZ4f)cq;OyTj3YlI|A9F<3g;rF4>7$w#wLS#TiF}tv~Btm&BAeq;bf-B zdaVOnMf>B=OXfHDN@?1EU$B^Y%EsdzeukF^EO}LoZ7CNd2Da{G!M=lDqGZo z9$jDvwvUWZ+PQni2L=m{={J^dm}cA_{w!nOmy@#HUQ@R&`o8t#vKrl$-&Sl6ZsCdg zX}8sZD{}R5hCjIstqbLRIZDErPIx(<(Ehaa>G2*$UWR)jj}&VEFJgMwWK>&I?{h*T z&j0RPj$6S?n?5WFsyrMVRW8;$!Jpws|K*oaw`zF=E46&*GctUWveUJA(kI8OED_%< zaAB6m2iernjMW?ZsvcGgRZS1-QGDw4rQ%La${wxsc7Bofl76YV31w|zy#JZ+Wct(> zJ54F7+w-4e#;+vV?LIDhs?{B)w@zBNrM}&XtLuTSMx)wX<;=^`DJLXL`@MpD?HJxW z>|iz9x?NsxRho}X>EMZ+#cjpqP_8WyqFJ?|)bm2FM z?OffmRbH-PN9G9yBVQ}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c)s_;Qrvy;DLSZ6_(<X$}YSaCQ8f6)sm_g2#&k@%=7?Q`ODFe1}(n#8P N002ovPDHLkV1gw-oSpyx diff --git a/res/resources.res b/res/resources.res index f46d91e..aa1c19c 100644 --- a/res/resources.res +++ b/res/resources.res @@ -15,6 +15,8 @@ IMAGE bossBar "chrome/boss.png" FAST // background IMAGE bg1 "bg/1.png" FAST +IMAGE bg1L "bg/1l.png" FAST +IMAGE bg1R "bg/1r.png" FAST // player and enemies diff --git a/src/background.h b/src/background.h index cc871db..8ee0247 100644 --- a/src/background.h +++ b/src/background.h @@ -8,11 +8,22 @@ // draw +s16 bgI; +Image* bgImage; static void drawBg(){ for(u16 x = 0; x < BG_W; x++) for(u16 y = 0; y < BG_H; y++){ if(x % 8 == 0 && y % 8 == 0){ - VDP_drawImageEx(BG_B, &bg1, TILE_ATTR_FULL(PAL1, 0, 0, 0, BG_I + 1), x - 4, y, 0, DMA); + bgI = BG_I; + bgImage = &bg1; + if(x == 8){ + bgI += 64; + bgImage = &bg1L; + } else if(x == 24){ + bgI += 128; + bgImage = &bg1R; + } + if(x != 16) VDP_drawImageEx(BG_B, bgImage, TILE_ATTR_FULL(PAL1, 0, 0, 0, bgI), x - 4, y, 0, DMA); } } } @@ -26,15 +37,26 @@ static void drawBg(){ #define BG_SIZE 64 #define BG_LIMIT FIX16(-256) +#define BG_MOD FIX16(0.25) + s16 bgPos; fix16 bgPosF; +fix16 bgSpeed = BG_SPEED; static void scrollBg(){ - bgPosF = fix16Sub(bgPosF, BG_SPEED); - if(bgPosF <= BG_LIMIT) bgPosF = fix16Sub(bgPosF, BG_LIMIT); - bgPos = fix16ToInt(bgPosF); + if(bossHealth > 0){ + if(bgSpeed > 0) if(clock % 10 == 0) bgSpeed = fix16Sub(bgSpeed, BG_MOD); + } else { + if(bgSpeed < BG_SPEED) if(clock % 10 == 0) bgSpeed = fix16Add(bgSpeed, BG_MOD); + } + if(bgSpeed > 0){ + bgPosF = fix16Sub(bgPosF, bgSpeed); + if(bgPosF <= BG_LIMIT) bgPosF = fix16Sub(bgPosF, BG_LIMIT); + bgPos = fix16ToInt(bgPosF); + } } + // loop void loadBg(){ diff --git a/src/chrome.h b/src/chrome.h index 8327faa..d6c96e3 100644 --- a/src/chrome.h +++ b/src/chrome.h @@ -81,6 +81,16 @@ static void loadBombs(){ } +// speed + +#define SPEED_X 24 +#define SPEED_Y 1 + +static void loadSpeed(){ + VDP_drawText("+++", SPEED_X, SPEED_Y); +} + + // loop void loadChrome(){ @@ -89,6 +99,7 @@ void loadChrome(){ loadTime(); loadLives(); loadBombs(); + loadSpeed(); } void updateChrome(){ diff --git a/src/enemies.h b/src/enemies.h index 4ab8aa6..a97b687 100644 --- a/src/enemies.h +++ b/src/enemies.h @@ -89,7 +89,10 @@ static void updateEnemy(s16 i){ enemies[i].dead = TRUE; enemies[i].suicide(i); } else { - if(!enemies[i].seen && enemies[i].pos.y >= fix16Sub(0, enemies[i].off.y)){ + if(!enemies[i].seen && + enemies[i].pos.y >= fix16Sub(0, enemies[i].off.y) && + enemies[i].pos.x >= fix16Sub(0, enemies[i].off.x) && + enemies[i].pos.x <= fix16Add(FIX16(GAME_W), enemies[i].off.x)){ enemies[i].seen = TRUE; SPR_setVisibility(enemies[i].image, VISIBLE); } diff --git a/src/stage.h b/src/stage.h index ac8d0f4..abe875a 100644 --- a/src/stage.h +++ b/src/stage.h @@ -1,33 +1,5 @@ // stage -/* - -sine from left -sine from right -big middle -sine from left, big right -sine from right, big left -big middle -swarm -big from left and right -swarm, big right -swarm, big left - -midboss - -big from left and right -big from right and left -big from left, small formation -big from right, small formation -big from left, small formation -big from right, small formation - -midboss - -final boss at 30 seconds left - -*/ - s16 stageClock, nextClock; @@ -290,15 +262,71 @@ static void waveBig5(bool right){ } enemies[i].ints[0] += 56; } - if(enemies[i].clock == 120 || enemies[i].clock == 180){ - enemies[i].speed = fix16Sub(enemies[i].speed, FIX16(0.1)); - enemies[i].angle += enemies[i].bools[0] ? -64 : 64; + if(enemies[i].clock == 120){ + enemies[i].speed = FIX16(0.5); updateEnemyVel(i); } } spawnEnemy(spawner, updater, EMPTY); } +static void waveBig6(bool right){ + struct enemySpawner spawner = { + .angle = right ? 512 : 0, + .speed = FIX16(1), + .x = right ? (GAME_W + 16) : -32, + .y = 40, + .image = right ? &fairyGreen : &fairyYellow, + .offX = 16, + .offY = 16, + .health = 4 + }; + spawner.bools[0] = right; + void updater(s16 i){ + if(enemies[i].clock % 10 == 0 && enemies[i].clock >= 60 && enemies[i].clock < 180){ + enemies[i].angle += enemies[i].bools[0] ? -24 : 24; + updateEnemyVel(i); + } + if(enemies[i].clock % 35 == 0 && enemies[i].clock > 0 && enemies[i].clock < 180){ + struct bulletSpawner spawner = { + .x = enemies[i].pos.x, + .y = enemies[i].pos.y + }; + for(u8 j = 0; j < 4; j++){ + spawner.angle = random() % 256; + if(enemies[i].bools[0]) spawner.angle += 256; + if(j < 2){ + spawner.speed = FIX16(1.25); + spawner.big = TRUE; + spawner.image = &bigBullet; + } else { + spawner.speed = FIX16(1.75); + spawner.light = TRUE; + spawner.image = &smallBullet; + } + spawnBullet(spawner, EMPTY); + } + } + + } + spawnEnemy(spawner, updater, EMPTY); +} + + +static void waveFormation(bool right){ + struct enemySpawner spawner = { + .angle = 256, + .speed = FIX16(0.75), + .x = 80, + .y = -16, + .image = &fairyRed, + .offX = 16, + .offY = 16, + .health = 6 + }; + // spawnEnemy(spawner) +} + // bosses @@ -387,7 +415,7 @@ static void waveMidboss1(){ .offX = 24, .offY = 28, .boss = TRUE, - .health = 50 + .health = 40 }; bossMax = spawner.health; void updater(s16 i){ @@ -395,7 +423,7 @@ static void waveMidboss1(){ if(enemies[i].bools[0]){ bossHealth = enemies[i].health; bossMove(i); - if(enemies[i].health >= 25){ + if(enemies[i].health >= 20){ // ring if(enemies[i].clock % 90 == 0){ struct bulletSpawner spawner = { @@ -494,7 +522,7 @@ static void waveMidboss1(){ // loop -s16 currentWave = 0; +s16 currentWave = 13; void updateStage(){ if(enemyCount == 0){ @@ -539,12 +567,12 @@ void updateStage(){ waveSwarm(2); waveBig4(TRUE, TRUE); break; - case 9: // swarm (2), big left + case 9: waveSwarm(2); waveBig4(FALSE, TRUE); break; - // midboss + // midboss case 10: waveMidboss1(); break; @@ -553,6 +581,16 @@ void updateStage(){ waveBig5(FALSE); waveBig5(TRUE); break; + // big from right and left + case 12: + waveBig6(TRUE); + waveBig6(FALSE); + break; + // big from left, small formation + case 13: + waveBig6(FALSE); + waveFormation(TRUE); + break; } currentWave++; @@ -560,4 +598,33 @@ void updateStage(){ stageClock++; if(stageClock >= CLOCK_LIMIT) stageClock -= CLOCK_LIMIT; -} \ No newline at end of file +} + + +/* + +sine from left +sine from right +big middle +sine from left, big right +sine from right, big left +big middle +swarm +big from left and right +swarm, big right +swarm, big left + +midboss + +big from left and right +big from right and left +big from left, small formation +big from right, small formation +big from left, small formation +big from right, small formation + +midboss + +final boss at 30 seconds left + +*/ \ No newline at end of file