Wave management added.

linux_template
sigonasr2 2 years ago
parent d4e37b6179
commit 8978130bd8
  1. 40
      Faceball2030/assets/map/map1.map
  2. 66
      Faceball2030/main.cpp
  3. 3
      Faceball2030/main.h

@ -1,44 +1,44 @@
7 7
6 6
32777 41369
32778 41514
8202 8202
8728
24584
8200 8200
16792
9160
8204 8204
40965 40965
57753 49561
24584 8744
25104 24576
8192 8192
16784 16384
8196 24996
8197 8197
8193 8193
8192 416
8194 8194
8192 8192
16272 8192
16276 8196
8193 8737
2 2
25492 24580
8201 16937
16272
8192 8192
16276 8192
8196
8197 8197
8351 8351
8197 8197
8195 8595
8198 8198
273 273
16276 8196
8195 8195
8602 8602
8194 8194
8202 8202
8202 8202
8194 8194
16278 25126

@ -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) {
enemies.push_back({ id,vec3d{x + 0.5f,0,y + 0.5f},((int)mapData[y][x].facingDir-1)*PI/2,enemyData[id].radius}); 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 });
} 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,10 +1430,9 @@ 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) {
@ -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;

@ -266,6 +266,8 @@ class FaceBall : public PixelGameEngine
std::map<EnemyID, EnemyData>enemyData; std::map<EnemyID, EnemyData>enemyData;
std::map<PowerupType, PowerupData>powerupData; std::map<PowerupType, PowerupData>powerupData;
std::vector<Enemy>enemies; std::vector<Enemy>enemies;
std::vector<Enemy>wave2Enemies;
std::vector<Enemy>wave3Enemies;
std::vector<Powerup>powerups; std::vector<Powerup>powerups;
private: private:
Mesh mapWalls,mapFloor,enemy_ShootMe,undefined, Mesh mapWalls,mapFloor,enemy_ShootMe,undefined,
@ -397,6 +399,7 @@ class FaceBall : public PixelGameEngine
void Display3DKillerModel(); void Display3DKillerModel();
int CheckPowerupCollision(vec3d movementVector, vf2d pos, float radius); int CheckPowerupCollision(vec3d movementVector, vf2d pos, float radius);
void ResetScore(); void ResetScore();
int EnemiesAlive();
public: public:
vi2d MAP_SIZE; vi2d MAP_SIZE;
float restingTriangleYDepth = 0.f; float restingTriangleYDepth = 0.f;

Loading…
Cancel
Save