diff --git a/res/explosions/blue1.png b/res/explosions/blue1.png new file mode 100644 index 0000000..fce12ca Binary files /dev/null and b/res/explosions/blue1.png differ diff --git a/res/explosions2.png b/res/explosions2.png new file mode 100644 index 0000000..e8db999 Binary files /dev/null and b/res/explosions2.png differ diff --git a/res/explosions3.png b/res/explosions3.png new file mode 100644 index 0000000..8b0fe99 Binary files /dev/null and b/res/explosions3.png differ diff --git a/res/resources.res b/res/resources.res index aa1c19c..bd173be 100644 --- a/res/resources.res +++ b/res/resources.res @@ -39,4 +39,5 @@ SPRITE playerBullet "bullets/player.png" 4 3 FAST 5 // explosion -SPRITE explosion "explosions.png" 4 4 FAST 5 \ No newline at end of file +// SPRITE explosion "explosions.png" 4 4 FAST 5 +IMAGE explosion2 "explosions2.png" FAST \ No newline at end of file diff --git a/src/enemies.h b/src/enemies.h index a97b687..1161402 100644 --- a/src/enemies.h +++ b/src/enemies.h @@ -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); } \ No newline at end of file diff --git a/src/explosions.h b/src/explosions.h index c0cf130..61ca6bf 100644 --- a/src/explosions.h +++ b/src/explosions.h @@ -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); } \ No newline at end of file diff --git a/src/main.c b/src/main.c index 4b2b9c6..63cb9be 100644 --- a/src/main.c +++ b/src/main.c @@ -32,6 +32,7 @@ void loadGame(){ loadBg(); loadChrome(); loadPlayer(); + loadExplosions(); } static void updateGame(){ diff --git a/src/stage.h b/src/stage.h index bcb2a87..ae98812 100644 --- a/src/stage.h +++ b/src/stage.h @@ -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){ diff --git a/src/structs.h b/src/structs.h index 6802ef8..d0efc63 100644 --- a/src/structs.h +++ b/src/structs.h @@ -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]; \ No newline at end of file