Ajout de la peur chez les fantomes

master
Fife 6 years ago
parent 4da0f9d0f2
commit 7b9f51e39c
  1. 33
      iaghost2.cpp

@ -17,7 +17,11 @@ void IA2::Initialisation(Script_GUI * v)
void IA2::Update()
{
if(SGUI->GetVulnerability() > 0)SetIt(1);
if(SGUI->GetVulnerability() > 0)
{
SetIt(1);
couldown = 0;
}
else SetIt(0);
//Intersection//
@ -33,7 +37,6 @@ void IA2::Update()
if(!GetObject()->GetRigibody()->CollisionDecor(GetX() + (direction%2), GetY() + (!(direction%2))) || !GetObject()->GetRigibody()->CollisionDecor(GetX() - (direction%2), GetY() - (!(direction%2))))
{
PrintMini(10,10,"Test",0);
bool possibledirection[4];
for(int i = 0; i < 4 ; i++)possibledirection[i] = !(GetObject()->GetRigibody()->CollisionDecor(GetX() + (i == 1) - (i == 3), GetY() + (i == 0) - (i == 2)));
@ -69,6 +72,14 @@ void IA2::Update()
betterdirection[ 3 -(best == 1)] = 1;
}
if(SGUI->GetVulnerability() > 0)
{
bool buffer[4];
for(int i = 0; i < 4 ; i++)buffer[i] = betterdirection[i];
for(int i = 0; i < 4 ; i++)betterdirection[i] = buffer[3 - i];
}
int end = 4;
while(end > 0)
{
@ -79,6 +90,8 @@ void IA2::Update()
}
else end --;
}
couldown = rand_int(10);
}
}
else
@ -102,15 +115,17 @@ void IA2::Update()
if(!GetObject()->GetRigibody()->CollisionDecor( GetX() + (directionuser == 2) - (directionuser == 4) , GetY() + (directionuser == 1) - (directionuser == 3) ))direction = directionuser;
switch(direction)
if(couldown <= 1)
{
case 1: Move(0,1); break;
case 2: Move(1,0); break;
case 3: Move(0,-1); break;
case 4: Move(-1,0); break;
}
switch(direction)
{
case 1: Move(0,1); break;
case 2: Move(1,0); break;
case 3: Move(0,-1); break;
case 4: Move(-1,0); break;
}
}
//************//
if(GetObject()->CollisionTag("TP1"))

Loading…
Cancel
Save