I really need help here guys my AI doesn't work so if anyone could see the error, then please help me.
#include "DarkGDK.h"
#include "Time.h"
void DarkGDK ( void )
{
dbSetWindowSize(800,600);
dbLoadImage("test.bmp",1);
dbLoadImage("enemy.bmp",2);
dbSyncOn ( );
dbSyncRate ( 60 );
//Movement Variables
int Jumps = 2;
bool Enemyfalling = true;
bool Playerfalling = true;
const int Gravity = 4;
dbSprite(1,1,1,1);
dbSprite(2,400,0,2);
while ( LoopGDK ( ) )
{
int EnemyY = dbSpriteY(2);
int PlayerY = dbSpriteY(1);
int PlayerPosX = dbSpriteX(1);
int EnemyPosX = dbSpriteX(2);
if (Playerfalling == true);
if (PlayerY <= 400)
{
dbMoveSprite(1,-Gravity);
Playerfalling = true;
}else
{
Playerfalling = false;
}
if (Enemyfalling == true);
if (EnemyY <= 400)
{
dbMoveSprite(2,-Gravity);
Enemyfalling = true;
}else
{
Enemyfalling = false;
}
if (dbSpriteCollision(1,2) != 1)
{
EnemyPosX += PlayerPosX;
dbRotateSprite(2,90);
dbMoveSprite(2,PlayerPosX);
dbRotateSprite(2,0);
}else if (dbSpriteCollision(1,2) == 1)
{
dbRotateSprite(2,90);
dbMoveSprite(2,4);
dbRotateSprite(2,0);
}
if (dbSpaceKey() == 1)
{
if (Playerfalling == false)
{
dbMoveSprite(1,120);
}else if (Playerfalling == true)
{
}
}
if (dbRightKey() == 1)
{
dbRotateSprite(1,90);
dbMoveSprite(1,3);
dbRotateSprite(1,0);
}
if (dbLeftKey() == 1)
{
dbRotateSprite(1,90);
dbMoveSprite(1,-3);
dbRotateSprite(1,0);
}
dbSync ( );
}
return;
}
EDIT:Sry I want the enemy to follow my player whatever direction the player goes
Beginner In the Language.