ok so the problem is
when i run this code the game runs fine i can move units every thing but once i get to the section where it checks for distance between entities (called beDistance) it returns false and doesnt move the units.
can anyone see a problem with this code
for(int i = 0;i<entities.size();i++)
{
if(entities.at(i)->GetType() == 1)
{
if(logicTimer < GetTickCount())
{
///COLLISION SYSTEM///
int ix = entities.at(i)->GetX();
int iy = entities.at(i)->GetY();
for(int c=0;c<entities.size();c++)
{
//testI = beDistance(entities.at(0)->GetSprite(),entities.at(1)->GetSprite());
if(beDistance(entities.at(c)->GetSprite(),entities.at(i)->GetSprite()) < 225 && c != i)
{
testI++;
int cx = entities.at(c)->GetX();
int cy = entities.at(c)->GetY();
if(ix > cx)
{
ix++;
}
if(iy > cy)
{
iy++;
}
if(ix < cx)
{
ix--;
}
if(iy < cy)
{
iy--;
}
}
}
entities.at(i)->SetPos(ix,iy);
logicTimer = GetTickCount()+500;
///END COLLISION///
}
entities.at(i)->UpdateX();
entities.at(i)->UpdateY();
entities.at(i)->Update();
}
}
int beDistance(int a,int b)
{
int x = 0;
if(dbSpriteX(a) < dbSpriteX(b))
{
x = dbSpriteX(b) - dbSpriteX(a);
}else{
x = dbSpriteX(a) - dbSpriteX(b);
}
int y = 0;
if(dbSpriteY(a) < dbSpriteY(b))
{
y = dbSpriteY(b) - dbSpriteY(a);
}else{
y = dbSpriteY(a) - dbSpriteY(b);
}
int distance = (x*x)+(y*y);
return distance;
}