SHOOTME2 is now a thing instead of being ISHOOT (AI will be for a different enemy)

linux_template
sigonasr2 2 years ago
parent e2f92061d4
commit 82a9161028
  1. 2
      Faceball2030/Editor.h
  2. 4
      Faceball2030/assets/map/map1.map
  3. 30
      Faceball2030/main.cpp

@ -11,7 +11,9 @@ enum EnemyID {
EXIT,
START,
SHOOTME,
SHOOTME2,
ISHOOT,
ISHOOT2,
SONAR,
COIN = 56,
POWERUP_ARMOR = 57,

@ -3,13 +3,13 @@
32777
32778
8202
8200
8728
24584
8204
40965
57753
24584
8192
25104
8192
16788
8197

@ -93,7 +93,7 @@ void FaceBall::InitializeEnemyData() {
enemyData[EXIT] = { "EXIT",undefined,GREEN };
enemyData[START] = { "SPAWN POSITION",undefined,{128,64,0} };
enemyData[SHOOTME] = { "SHOOTME",enemy_ShootMe,YELLOW,1,1,PI / 8,2,1 };
enemyData[ISHOOT] = { "ISHOOT",enemy_IShoot,YELLOW,1,1,PI / 6,2,1,0.4f };
enemyData[SHOOTME2] = { "SHOOTME2",enemy_IShoot,YELLOW,1,1,PI / 6,2,1,0.5f };
enemyData[SONAR] = { "Sonar",enemy_Sonar,RED,5,1,PI / 8,2,1 };
enemyData[COIN] = { "Coin",undefined,BLUE };
enemyData[POWERUP_ARMOR] = { "Armor",undefined,{96,0,96} };
@ -1532,7 +1532,33 @@ void FaceBall::RunEnemyAI(Enemy& e,float fElapsedTime,int myIndex) {
case SHOOTME: {
e.rot += 0.5 * fElapsedTime;
}break;
case ISHOOT: {
case SHOOTME2: {
switch (e.GetPhase()) {
case Phase::DEFAULT: {
vf2d movementVec = { std::cosf(e.rot) * dat.movSpd * fElapsedTime,std::sinf(e.rot) * dat.movSpd * fElapsedTime };
if (-1 == CheckEnemyCollision({ movementVec.x,0,movementVec.y }, { e.pos.x,e.pos.z }, e.radius, myIndex) &&
!CheckCollision({ movementVec.x,0,movementVec.y }, { e.pos.x,e.pos.z }, e.radius)) {
e.pos.x += movementVec.x;
e.pos.z += movementVec.y;
}
else {
e.SetPhase(Phase::TURNING);
e.turnAmt = PI;
}
}break;
case Phase::TURNING: {
if (e.turnAmt > 0) {
float rotAmt = std::min(e.turnAmt, dat.rotSpd * fElapsedTime);
e.turnAmt -= rotAmt;
e.rot += rotAmt;
if (e.turnAmt <= 0) {
e.SetPhase(Phase::DEFAULT);
}
}
}break;
}
}break;
case ISHOOT2: {
switch (e.GetPhase()) {
case Phase::DEFAULT: {
vf2d movementVec = { std::cosf(e.rot) * dat.movSpd * fElapsedTime,std::sinf(e.rot) * dat.movSpd * fElapsedTime };

Loading…
Cancel
Save