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. 38
      Faceball2030/main.cpp

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

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

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

Loading…
Cancel
Save