gfx, shit
This commit is contained in:
parent
364a34ce33
commit
0151304d05
8 changed files with 140 additions and 33 deletions
44
src/humans.h
44
src/humans.h
|
|
@ -1,3 +1,5 @@
|
|||
#define HUMAN_OFF 16
|
||||
|
||||
|
||||
void spawnHuman(u8 zone){
|
||||
s16 i = -1;
|
||||
|
|
@ -16,8 +18,8 @@ void spawnHuman(u8 zone){
|
|||
humans[i].vel.x = (random() % 2 == 0) ? speeds[random() % 3] : -speeds[random() % 3];
|
||||
humans[i].vel.y = (random() % 2 == 0) ? FIX32(0.1) : FIX32(-0.1);
|
||||
|
||||
humans[i].image = SPR_addSprite(&humanSprite,
|
||||
getScreenX(humans[i].pos.x, player.camera), fix32ToInt(humans[i].pos.y),
|
||||
humans[i].image = SPR_addSprite(&koaSprite,
|
||||
getScreenX(humans[i].pos.x, player.camera) - HUMAN_OFF, fix32ToInt(humans[i].pos.y) - HUMAN_OFF,
|
||||
TILE_ATTR(PAL0, 0, 0, 0));
|
||||
if(!humans[i].image){
|
||||
humans[i].active = FALSE;
|
||||
|
|
@ -52,7 +54,7 @@ static void updateHuman(u8 i){
|
|||
humans[i].state = HUMAN_FALLING;
|
||||
humans[i].carriedBy = -1;
|
||||
humans[i].vel.x = 0;
|
||||
humans[i].vel.y = FIX32(2);
|
||||
humans[i].vel.y = FIX32(3);
|
||||
humanBeingCarried = FALSE;
|
||||
}
|
||||
break;
|
||||
|
|
@ -68,16 +70,46 @@ static void updateHuman(u8 i){
|
|||
humans[i].vel.y = (random() % 2 == 0) ? FIX32(0.1) : FIX32(-0.1);
|
||||
}
|
||||
break;
|
||||
|
||||
case HUMAN_COLLECTED: {
|
||||
fix32 targetX, targetY;
|
||||
if(humans[i].trailIndex == 0){
|
||||
targetX = player.pos.x;
|
||||
targetY = player.pos.y + FIX32(24);
|
||||
} else {
|
||||
// find the human ahead in the chain
|
||||
targetX = player.pos.x;
|
||||
targetY = player.pos.y + FIX32(24);
|
||||
for(s16 j = 0; j < HUMAN_COUNT; j++){
|
||||
if(humans[j].active && humans[j].state == HUMAN_COLLECTED
|
||||
&& humans[j].trailIndex == humans[i].trailIndex - 1){
|
||||
targetX = humans[j].pos.x;
|
||||
targetY = humans[j].pos.y + FIX32(8);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
fix32 deltaX = getWrappedDelta(targetX, humans[i].pos.x);
|
||||
humans[i].pos.x += deltaX >> 2;
|
||||
humans[i].pos.y += (targetY - humans[i].pos.y) >> 2;
|
||||
// X wrap
|
||||
if(humans[i].pos.x >= GAME_WRAP)
|
||||
humans[i].pos.x -= GAME_WRAP;
|
||||
if(humans[i].pos.x < 0)
|
||||
humans[i].pos.x += GAME_WRAP;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// collect: check overlap with player (walking or falling only)
|
||||
fix32 dx = getWrappedDelta(humans[i].pos.x, player.pos.x);
|
||||
if(humans[i].state != HUMAN_CARRIED){
|
||||
if(humans[i].state != HUMAN_CARRIED && humans[i].state != HUMAN_COLLECTED){
|
||||
fix32 dy = humans[i].pos.y - player.pos.y;
|
||||
if(dx >= FIX32(-24) && dx <= FIX32(24) && dy >= FIX32(-24) && dy <= FIX32(24)){
|
||||
score += (humans[i].state == HUMAN_FALLING) ? 2000 : 1000;
|
||||
sfxPickup();
|
||||
killHuman(i);
|
||||
humans[i].state = HUMAN_COLLECTED;
|
||||
humans[i].trailIndex = collectedCount++;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
@ -86,7 +118,7 @@ static void updateHuman(u8 i){
|
|||
s16 sy = fix32ToInt(humans[i].pos.y);
|
||||
bool visible = (dx >= -CULL_LIMIT && dx <= CULL_LIMIT);
|
||||
SPR_setVisibility(humans[i].image, visible ? VISIBLE : HIDDEN);
|
||||
SPR_setPosition(humans[i].image, sx, sy);
|
||||
SPR_setPosition(humans[i].image, sx - HUMAN_OFF, sy - HUMAN_OFF);
|
||||
}
|
||||
|
||||
void updateHumans(){
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue