Hey guys!
Im making a game with a friend just for fun.
Its a Tower Defense game, where you need to protect a place from the enemys adding towers and stuff.
Ok what im doing now it's the AI for the enemys, so im kinda making a path so the enemies can try to reach the player's tower.
I got the enemy1 struct:
struct Enemy1
{
void LoadEnemy(int dificulty);
void Spawn(int SpawnX, int SpawnY, int id);
void Move(int id, int speed, int LastX, int LastY);
int image_id;
int speed;
int health;
int id;
int level;
int money;
int score;
bool Path1;
bool Path2;
bool Path3;
bool Path4;
bool Path5;
};
The bools for paths are just a thing that i tested and they didnt work so forget it.
Now the Functions of the enemy:
Load:
void Enemy1::LoadEnemy(int dificulty)
{
image_id = GetFreeSpriteID();
dbLoadImage("res//enemy1.png", image_id);
level = 1;
speed = -2 * dificulty;
score = 100;
money = 1000;
health = 10;
Path1 = false;
Path2 = false;
Path3 = false;
Path4 = false;
Path5 = false;
}
Spawn:
void Enemy1::Spawn(int SpawnX, int SpawnY, int id)
{
int Eid = id;
int EImid = image_id;
dbSprite(Eid, SpawnX, SpawnY, EImid);
}
Move:
void Enemy1::Move(int id, int speed, int LastX, int LastY)
{
PointSprite(id, LastX, LastY);
dbMoveSprite(id, speed);
if(dbSpriteX(id) >= 1100 || dbSpriteX(id) <= -80)
{
dbDeleteSprite(id);
}
else if(dbSpriteY(id) >= 800 || dbSpriteY(id) <= -80)
{
dbDeleteSprite(id);
}
}
Ok so here's the main function :
void DarkGDK ( void )
{
dbSyncOn ( );
dbSyncRate ( 0 );
dbSetImageColorKey(255, 0, 255);
dbDisableEscapeKey ( );
dbSetDisplayModeAntialias(WIDTH, HEIGHT, 32, 1, 0, 0);
dbSetWindowPosition( 0, 0);
dbSetWindowTitle("GAMENAME - BLABLABLA");
LoadImages();
LoadEverything();
Player player;
Enemy1 enemy1;
player.Init();
enemy1.LoadEnemy(1);
dbSprite(enemy1.id, 50, 50, enemy1.image_id);
while ( LoopGDK ( ) )
{
dbPasteImage(1, 0, 0);
//Update
player.Update();
enemy1.Move(enemy1.id, enemy1.speed, 200, 300);
if ( dbEscapeKey ( ) ) break;
SystemUpdate(player);
dbSync ( );
}
return;
}
Well i dont see what's wrong but what really happens is that the enemy stays on the x:0 and y:0 ... and no movement.
I already did it once and it worked but i dont remmember what i changed :S
Hope you guys can help me
PS: If you need more info just ask
Oh and i forgot that i know its not sync'ing because i had a X and Y displayers and they are getting the new ones above the oldest..
CREDITS:
GetFreeSpriteID() Function was provided by Hassan (i think so, was a long time ago)
C++ Medium 3.5/5
VB6 Advanced: 4/5
VB.NET Advanced: 4/5