explosions to blast processing, stage work

This commit is contained in:
t. boddy 2022-09-25 21:11:37 -04:00
parent 52eae61021
commit 3c79087a69
9 changed files with 81 additions and 12 deletions

BIN
res/explosions/blue1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

BIN
res/explosions2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

BIN
res/explosions3.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

View File

@ -39,4 +39,5 @@ SPRITE playerBullet "bullets/player.png" 4 3 FAST 5
// explosion
SPRITE explosion "explosions.png" 4 4 FAST 5
// SPRITE explosion "explosions.png" 4 4 FAST 5
IMAGE explosion2 "explosions2.png" FAST

View File

@ -123,5 +123,4 @@ static void updateEnemy(s16 i){
void updateEnemies(){
enemyCount = 0;
for(s16 i = 0; i < ENEMY_COUNT; i++) if(enemies[i].active) updateEnemy(i);
intToStr(enemyCount, debugStr, 2);
}

View File

@ -1,29 +1,61 @@
// explosions
#define EXPLOSION_OFFSET FIX16(16)
#define EXPLOSION_TIME 20
#define EXPLOSION_TIME 25
#define EXPLOSION_I 480
#define EXPLOSION_MOD FIX16(8)
void spawnExplosion(fix16 x, fix16 y, u8 type){
s16 i = -1;
for(s16 j = 0; j < EXPLOSION_COUNT; j++) if(!explosions[j].active && i == -1) i = j;
explosions[i].active = TRUE;
explosions[i].clock = 0;
explosions[i].image = SPR_addSprite(&explosion,
fix16ToInt(fix16Sub(x, EXPLOSION_OFFSET)),
fix16ToInt(fix16Sub(y, EXPLOSION_OFFSET)),
TILE_ATTR(PAL1, 1, 0, 0));
SPR_setAnim(explosions[i].image, type);
SPR_setDepth(explosions[i].image, 3);
explosions[i].x = fix16ToInt(fix16Div(x, EXPLOSION_MOD));
explosions[i].y = fix16ToInt(fix16Div(y, EXPLOSION_MOD));
intToStr(explosions[i].x, debugStr, 2);
if(explosions[i].y >= 3){
VDP_setTileMapXY(BG_A, TILE_ATTR_FULL(PAL1, 1, 0, 0, EXPLOSION_I), explosions[i].x, explosions[i].y);
// VDP_setTileMapXY(BG_A, TILE_ATTR_FULL(PAL1, 1, 0, 0, EXPLOSION_I), explosions[i].x - 1, explosions[i].y);
// VDP_setTileMapXY(BG_A, TILE_ATTR_FULL(PAL1, 1, 0, 0, EXPLOSION_I), explosions[i].x + 1, explosions[i].y);
// VDP_setTileMapXY(BG_A, TILE_ATTR_FULL(PAL1, 1, 0, 0, EXPLOSION_I), explosions[i].x, explosions[i].y - 1);
// VDP_setTileMapXY(BG_A, TILE_ATTR_FULL(PAL1, 1, 0, 0, EXPLOSION_I), explosions[i].x, explosions[i].y + 1);
}
}
s16 explosionI;
static void updateExplosion(s16 i){
if(explosions[i].clock >= EXPLOSION_TIME){
explosions[i].active = FALSE;
SPR_releaseSprite(explosions[i].image);
VDP_clearTileMapRect(BG_A, explosions[i].x, explosions[i].y, 1, 1);
} else {
if(explosions[i].clock > 0 && explosions[i].clock % 5 == 0){
explosionI = EXPLOSION_I + 1;
if(explosions[i].clock > 5) explosionI++;
if(explosions[i].clock > 10) explosionI++;
if(explosions[i].clock > 15) explosionI++;
// if(e)
// if(explosions[i].clock == 20) VDP_clearTileMapRect(BG_A, explosions[i].x, explosions[i].y, 1, 1);
VDP_setTileMapXY(BG_A, TILE_ATTR_FULL(PAL1, 1, 0, 0, explosionI), explosions[i].x, explosions[i].y);
// VDP_setTileMapXY(BG_A, TILE_ATTR_FULL(PAL1, 1, 0, 0, explosionI), explosions[i].x - 1, explosions[i].y);
// VDP_setTileMapXY(BG_A, TILE_ATTR_FULL(PAL1, 1, 0, 0, explosionI), explosions[i].x + 1, explosions[i].y);
// VDP_setTileMapXY(BG_A, TILE_ATTR_FULL(PAL1, 1, 0, 0, explosionI), explosions[i].x, explosions[i].y - 1);
// VDP_setTileMapXY(BG_A, TILE_ATTR_FULL(PAL1, 1, 0, 0, explosionI), explosions[i].x, explosions[i].y + 1);
}
}
explosions[i].clock++;
}
static void loadExplosions(){
VDP_loadTileSet(explosion2.tileset, EXPLOSION_I, DMA);
}
void updateExplosions(){
for(s16 i = 0; i < EXPLOSION_COUNT; i++) if(explosions[i].active) updateExplosion(i);
}

View File

@ -32,6 +32,7 @@ void loadGame(){
loadBg();
loadChrome();
loadPlayer();
loadExplosions();
}
static void updateGame(){

View File

@ -800,6 +800,41 @@ static void waveBoss1(){
}
} else {
if(enemies[i].clock % 120 == 0) enemies[i].ints[6] = 96 + random() % 64;
// rays
if(enemies[i].clock % 240 < 180 && enemies[i].clock % 15 == 0){
struct bulletSpawner spawner = {
.x = enemies[i].pos.x,
.y = enemies[i].pos.y,
.image = &hugeBullet,
.huge = TRUE,
.angle = enemies[i].ints[6],
.angle = 112 + random() % 32,
.speed = FIX16(3),
};
for(u8 j = 0; j < 3; j++){
spawnBullet(spawner, EMPTY);
spawner.angle += 128;
}
}
// homing
if(enemies[i].clock % 8 == 4){
struct bulletSpawner spawner = {
.x = enemies[i].pos.x,
.y = enemies[i].pos.y,
.speed = FIX16(2.5),
.angle = 256,
.image = &bigBullet,
.light = TRUE,
.big = TRUE,
.top = TRUE
};
spawner.vel = hone(enemies[i].pos, player.pos, spawner.speed, 64);
spawnBullet(spawner, EMPTY);
}
}
} else bossIntro(i);
}
@ -812,7 +847,7 @@ static void waveBoss1(){
// loop
s16 currentWave = 18;
s16 currentWave = 17;
void updateStage(){
if(enemyCount == 0){

View File

@ -75,11 +75,12 @@ struct enemy enemies[ENEMY_COUNT];
// explosion
#define EXPLOSION_COUNT 16
#define EXPLOSION_COUNT 32
struct explosion {
bool active;
s16 clock;
Sprite* image;
s16 x, y;
};
struct explosion explosions[EXPLOSION_COUNT];