bg and stage work

This commit is contained in:
t. boddy 2022-09-24 15:54:09 -04:00
parent 51aed3b0ba
commit 10472f61d9
9 changed files with 147 additions and 42 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.3 KiB

After

Width:  |  Height:  |  Size: 2.5 KiB

BIN
res/bg/1l.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

BIN
res/bg/1r.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.4 KiB

After

Width:  |  Height:  |  Size: 3.4 KiB

View File

@ -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

View File

@ -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(){

View File

@ -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(){

View File

@ -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);
}

View File

@ -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;
}
}
/*
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
*/