|
|
@ -325,7 +325,15 @@ void FaceBall::LoadLevel(int level) |
|
|
|
mapFloor.tris.push_back({ {{(float)x + 1,0,(float)y},{(float)x,0,(float)y + 1},{(float)x + 1,0,(float)y + 1}},{{1,0},{0,1},{1,1}},{WHITE,WHITE,WHITE}, floor_tex }); |
|
|
|
mapFloor.tris.push_back({ {{(float)x + 1,0,(float)y},{(float)x,0,(float)y + 1},{(float)x + 1,0,(float)y + 1}},{{1,0},{0,1},{1,1}},{WHITE,WHITE,WHITE}, floor_tex }); |
|
|
|
EnemyID id = mapData[y][x].enemyId; |
|
|
|
EnemyID id = mapData[y][x].enemyId; |
|
|
|
if (id>=SHOOTME&& id < POWERUP_ARMOR) { |
|
|
|
if (id>=SHOOTME&& id < POWERUP_ARMOR) { |
|
|
|
|
|
|
|
if (mapData[y][x].wave1) { |
|
|
|
enemies.push_back({ id,vec3d{x + 0.5f,0,y + 0.5f},((int)mapData[y][x].facingDir - 1) * PI / 2,enemyData[id].radius }); |
|
|
|
enemies.push_back({ id,vec3d{x + 0.5f,0,y + 0.5f},((int)mapData[y][x].facingDir - 1) * PI / 2,enemyData[id].radius }); |
|
|
|
|
|
|
|
} else |
|
|
|
|
|
|
|
if (mapData[y][x].wave2) { |
|
|
|
|
|
|
|
wave2Enemies.push_back({ id,vec3d{x + 0.5f,0,y + 0.5f},((int)mapData[y][x].facingDir - 1) * PI / 2,enemyData[id].radius }); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else { |
|
|
|
|
|
|
|
wave3Enemies.push_back({ id,vec3d{x + 0.5f,0,y + 0.5f},((int)mapData[y][x].facingDir - 1) * PI / 2,enemyData[id].radius }); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if (id >= POWERUP_ARMOR) { |
|
|
|
if (id >= POWERUP_ARMOR) { |
|
|
|
SpawnPowerup(PowerupType((int)id-55), vec3d{ x + 0.5f,0,y + 0.5f }); |
|
|
|
SpawnPowerup(PowerupType((int)id-55), vec3d{ x + 0.5f,0,y + 0.5f }); |
|
|
@ -1422,12 +1430,11 @@ void FaceBall::HandleKeys(float fElapsedTime) { |
|
|
|
else { |
|
|
|
else { |
|
|
|
pitch = 0; |
|
|
|
pitch = 0; |
|
|
|
if (GetMouse(0).bPressed) { |
|
|
|
if (GetMouse(0).bPressed) { |
|
|
|
if (bullets.size() >= shotLimit) { |
|
|
|
if (bullets.size() < shotLimit) { |
|
|
|
bullets.erase(bullets.begin()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
bullets.push_back({ bullet,{player.GetPos().x,player.GetPos().y - 0.15f, player.GetPos().z},fYaw,0.125f,{shotSpd * std::cosf(fYaw),shotSpd * std::sinf(fYaw)},GREEN,true }); |
|
|
|
bullets.push_back({ bullet,{player.GetPos().x,player.GetPos().y - 0.15f, player.GetPos().z},fYaw,0.125f,{shotSpd * std::cosf(fYaw),shotSpd * std::sinf(fYaw)},GREEN,true }); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
if (GetKey(Q).bHeld) { |
|
|
|
if (GetKey(Q).bHeld) { |
|
|
|
mat4x4 leftMat = Matrix_MakeRotationY(-PI / 2); |
|
|
|
mat4x4 leftMat = Matrix_MakeRotationY(-PI / 2); |
|
|
|
vec3d vLeftStrafe = Matrix_MultiplyVector(leftMat, vForward); |
|
|
|
vec3d vLeftStrafe = Matrix_MultiplyVector(leftMat, vForward); |
|
|
@ -2123,6 +2130,47 @@ bool FaceBall::OnUserUpdate(float fElapsedTime) |
|
|
|
if (camoDuration >= 0) { |
|
|
|
if (camoDuration >= 0) { |
|
|
|
camoDuration -= fElapsedTime; |
|
|
|
camoDuration -= fElapsedTime; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (EnemiesAlive() < 5) { |
|
|
|
|
|
|
|
if (tagsRemaining <= 0) { |
|
|
|
|
|
|
|
//Look at all wave 2 enemies first, if we can't spawn one in then look at wave 3 enemies, and try to spawn one in.
|
|
|
|
|
|
|
|
if (wave2Enemies.size()>0){ |
|
|
|
|
|
|
|
for (int i=0;i<wave2Enemies.size();i++){ |
|
|
|
|
|
|
|
Enemy&e=wave2Enemies[i]; |
|
|
|
|
|
|
|
if (CheckEnemyCollision({0,0,0},{e.pos.x,e.pos.z},e.radius)==-1&& |
|
|
|
|
|
|
|
!CheckPlayerCollision({0,0,0},{e.pos.x,e.pos.z},e.radius)){ |
|
|
|
|
|
|
|
enemies.push_back(e); |
|
|
|
|
|
|
|
wave2Enemies.erase(wave2Enemies.begin()+i); |
|
|
|
|
|
|
|
goto spawningDone; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} else
|
|
|
|
|
|
|
|
if (wave3Enemies.size()>0){ |
|
|
|
|
|
|
|
for (int i=0;i<wave3Enemies.size();i++){ |
|
|
|
|
|
|
|
Enemy&e=wave3Enemies[i]; |
|
|
|
|
|
|
|
if (CheckEnemyCollision({0,0,0},{e.pos.x,e.pos.z},e.radius)==-1&& |
|
|
|
|
|
|
|
!CheckPlayerCollision({0,0,0},{e.pos.x,e.pos.z},e.radius)){ |
|
|
|
|
|
|
|
enemies.push_back(e); |
|
|
|
|
|
|
|
wave3Enemies.erase(wave3Enemies.begin()+i); |
|
|
|
|
|
|
|
goto spawningDone; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
spawningDone: |
|
|
|
|
|
|
|
int a; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else { |
|
|
|
|
|
|
|
//Look at wave 2 enemies, and try to spawn one in.
|
|
|
|
|
|
|
|
for (int i=0;i<wave2Enemies.size();i++){ |
|
|
|
|
|
|
|
Enemy&e=wave2Enemies[i]; |
|
|
|
|
|
|
|
if (CheckEnemyCollision({0,0,0},{e.pos.x,e.pos.z},e.radius)==-1&& |
|
|
|
|
|
|
|
!CheckPlayerCollision({0,0,0},{e.pos.x,e.pos.z},e.radius)){ |
|
|
|
|
|
|
|
enemies.push_back(e); |
|
|
|
|
|
|
|
wave2Enemies.erase(wave2Enemies.begin()+i); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
for (std::vector<Bullet>::iterator it = bullets.begin(); it != bullets.end();) { |
|
|
|
for (std::vector<Bullet>::iterator it = bullets.begin(); it != bullets.end();) { |
|
|
|
Bullet& b = *it; |
|
|
|
Bullet& b = *it; |
|
|
|
if (!b.Update(fElapsedTime)) { |
|
|
|
if (!b.Update(fElapsedTime)) { |
|
|
@ -2262,6 +2310,16 @@ void FaceBall::ResetScore() { |
|
|
|
lastAwardedScore = 0; |
|
|
|
lastAwardedScore = 0; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int FaceBall::EnemiesAlive(){ |
|
|
|
|
|
|
|
int alive=0; |
|
|
|
|
|
|
|
for (Enemy&e:enemies){ |
|
|
|
|
|
|
|
if (!e.isDead()){ |
|
|
|
|
|
|
|
alive++; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return alive; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
int main() |
|
|
|
int main() |
|
|
|
{ |
|
|
|
{ |
|
|
|
FaceBall demo; |
|
|
|
FaceBall demo; |
|
|
|