Witam,
piszę grę na projekt w SDL-u a dokładniej małą bijatykę. Mam problem z AI. Chodzi o to, że kiedy odpalam program postać komputera lata po planszy w kółko , dopiero po jakimś czasie kręci się w pobliżu gracza. Nie bardzo wiem jak go uspokoić :/
void Computer::lookingForPlayer(Human &human) {
//If a human player is on the left side
if(human.getPosX() < this->getPosX())
{
setMVel(this->getMVelX() - Player_VEL, this->getMVelY());
}
//if player is on the right side
if(human.getPosX() > this->getPosX())
{
setMVel(this->getMVelX() + Player_VEL, this->getMVelY());
}
if(human.getPosY() < this->getPosY())
{
setMVel(this->getMVelX(), this->getMVelY() - Player_VEL);
}
if(human.getPosY() > this->getPosY())
{
setMVel(this->getMVelX(), this->getMVelY() + Player_VEL);
}
}
Ktoś może mnie nakierować? Proszę o szybką odpowiedź.