collision work
This commit is contained in:
parent
9102b190c8
commit
cf71ad715a
|
@ -6,6 +6,9 @@
|
||||||
#define BULLET_DIST FIX32(4)
|
#define BULLET_DIST FIX32(4)
|
||||||
#define BULLET_DIST_BIG FIX32(8)
|
#define BULLET_DIST_BIG FIX32(8)
|
||||||
|
|
||||||
|
|
||||||
|
// lifecycle
|
||||||
|
|
||||||
void spawnBullet(struct bulletSpawner spawner, void(*updater)){
|
void spawnBullet(struct bulletSpawner spawner, void(*updater)){
|
||||||
s16 i = -1;
|
s16 i = -1;
|
||||||
for(s16 j = 0; j < BULLET_COUNT; j++) if(!bullets[j].active && i == -1) i = j;
|
for(s16 j = 0; j < BULLET_COUNT; j++) if(!bullets[j].active && i == -1) i = j;
|
||||||
|
|
|
@ -45,10 +45,11 @@ void collideObstacleWithPlayer(s16 i){
|
||||||
fix16Add(obstacles[i].pos.x, obstacles[i].size.x) > fix16Sub(player.pos.x, PLAYER_OFF) &&
|
fix16Add(obstacles[i].pos.x, obstacles[i].size.x) > fix16Sub(player.pos.x, PLAYER_OFF) &&
|
||||||
obstacles[i].pos.y < fix16Add(player.pos.y, PLAYER_OFF) &&
|
obstacles[i].pos.y < fix16Add(player.pos.y, PLAYER_OFF) &&
|
||||||
fix16Add(obstacles[i].pos.y, obstacles[i].size.y) > fix16Sub(player.pos.y, PLAYER_OFF)
|
fix16Add(obstacles[i].pos.y, obstacles[i].size.y) > fix16Sub(player.pos.y, PLAYER_OFF)
|
||||||
|
|
||||||
){
|
){
|
||||||
if(obstacles[i].pos.x > player.pos.x) player.pos.x = fix16Sub(fix16Sub(obstacles[i].pos.x, FG_SPEED), PLAYER_OFF);
|
if(obstacles[i].pos.x > player.pos.x) player.pos.x = fix16Sub(fix16Sub(obstacles[i].pos.x, FG_SPEED), PLAYER_OFF);
|
||||||
|
// else if(fix16Add(obstacles[i].pos.x, obstacles[i].size.x) > fix16Sub(player.pos.x, PLAYER_OFF)) player.pos.x = fix16Add(fix16Add(obstacles[i].pos.x, obstacles[i].size.x), PLAYER_OFF);
|
||||||
else if(obstacles[i].pos.y > player.pos.y) player.pos.y = fix16Sub(obstacles[i].pos.y, PLAYER_OFF);
|
else if(obstacles[i].pos.y > player.pos.y) player.pos.y = fix16Sub(obstacles[i].pos.y, PLAYER_OFF);
|
||||||
|
else if(fix16Add(obstacles[i].pos.y, obstacles[i].size.y) > fix16Sub(player.pos.y, PLAYER_OFF)) player.pos.y = fix16Add(fix16Add(obstacles[i].pos.y, obstacles[i].size.y), PLAYER_OFF);
|
||||||
checkPlayerBounds();
|
checkPlayerBounds();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Reference in New Issue