This commit is contained in:
t. boddy 2026-02-16 17:00:35 -05:00
parent 1702a06d9f
commit 364a34ce33
20 changed files with 453 additions and 64 deletions

View file

@ -34,7 +34,7 @@ void spawnEnemy(u8 type, u8 zone){
do {
// Random X within zone: zoneStart + random(0-511)
randX = zoneStart + FIX32(random() % 512);
randY = FIX32(16 + (random() % 192));
randY = FIX32(16 + (random() % 128));
attempts++;
} while(!isValidEnemyPosition(randX, randY) && attempts < 100);
@ -61,8 +61,22 @@ void spawnEnemy(u8 type, u8 zone){
}
static void boundsEnemy(u8 i){
if(enemies[i].pos.y >= GAME_H_F - FIX32(enemies[i].off) || enemies[i].pos.y <= FIX32(enemies[i].off))
enemies[i].vel.y *= -1;
if(enemies[i].ints[3] >= 0){
// carrying: only check for reaching the top
if(enemies[i].pos.y <= FIX32(0)){
s16 h = enemies[i].ints[3];
if(humans[h].active) killHuman(h);
enemies[i].ints[3] = -1;
humanBeingCarried = FALSE;
// TODO: spawn mutant here
killEnemy(i);
return;
}
} else {
// not carrying: bounce off top and bottom
if(enemies[i].pos.y >= GAME_H_F - FIX32(enemies[i].off) || enemies[i].pos.y <= FIX32(enemies[i].off))
enemies[i].vel.y *= -1;
}
if(enemies[i].pos.x >= GAME_WRAP){
enemies[i].pos.x -= GAME_WRAP;
@ -73,7 +87,6 @@ static void boundsEnemy(u8 i){
}
static void updateEnemy(u8 i){
boundsEnemy(i);
enemies[i].pos.x += enemies[i].vel.x;
enemies[i].pos.y += enemies[i].vel.y;
@ -83,6 +96,9 @@ static void updateEnemy(u8 i){
break;
}
boundsEnemy(i);
if(!enemies[i].active) return;
s16 sx = getScreenX(enemies[i].pos.x, player.camera);
s16 sy = fix32ToInt(enemies[i].pos.y);
fix32 dx = getWrappedDelta(enemies[i].pos.x, player.pos.x);