for (int i=0; i<size; i++)
while (b[i].getX()==temp.getX() && b[i].getY()==temp.getY())
this code loops through an array of size=size, initializing each instance of the array with random x and y values. these instances move randomly in one of 8 possible directions. Following is the class function "bug::move()"
int xMove, yMove, bMove;
if (xMove==0 && x-1>0)
if (xMove==2 && x+1<maxX)
if (yMove==0 && y-1>0)
if (yMove==2 && y+1<maxY)
this code works pretty well (the bugs stay in valid range), but i keep getting instances in which a bug will not move (by random chance, the values just dont change). I'm not detecting, logically, what is causing this. that is why i put in a while loop after b[i].move() to move again if the values are both the same. Which also poses a problem of my bug moving more than once (i have no code to reset the values to their previous state, i believe that re-initializing them with random values isnt an option).