Hey!
I have a newbie q for ya’ll =)
Im having some problems with a path route system that i have made for my editor, this system is used to make patrol routes for enemies in the game, to do this you have to get into the path route mode.
When youre here you click with left mb to add a path point and right mb to delete the last point in the route.
The thing now is that sometimes when i put a point ner another enemy, the active enemy just dissapears and the enemy thats closest to the new point gets to be the active enemy, this i think is pretty wierd and anoying.
So the question is: Can Vector objects be unstable and work in paculiar ways or is it my code that is funky?
here’s some code:
Enemy path mode:
if(enemyPath)
{
if(me.getButton() == 1)
{
if(me.getX() > 40 && me.getX() < 140 && me.getY() > 30 && me.getY() < 50)
{
enemyPath = false;
firstClick = false;
}
else if(me.getX() > 20 && me.getX() < 600 && me.getY() > 20 && me.getY() < 500 && firstClick)
{
int i;
i = e.patrolCount;
if(i < 23)
{
e.patrolRoute[i][0] = (double)(me.getX()-indexX);
e.patrolRoute[i][1] = (double)(me.getY()-indexY);
e.patrolCount++;
}
}
else
firstClick = true;
}
else
{
if(e.patrolCount > 0)
e.patrolCount--;
}
m.e.set(activeEnemy, e);
}
Activate Enemy Event:
else if(me.getButton() > 1 && !enemyPath && !enemyMode && !enemyPref)
{
if(me.getX() > 20 && me.getX() < 600 && me.getY() > 20 && me.getY() < 500)
{
int TileX = (int)(me.getX()-indexX);
int TileY = (int)(me.getY()-indexY);
for(int i = 0; i < m.e.size(); i++)
{
e = m.e.get(i);
if(TileX > e.pos[0] && TileX < e.pos[0] + 48 && TileY > e.pos[1] && TileY < e.pos[1] + 48)
{
activeEnemy = i;
enemyMode = true;
}
}
}
}
Tnx