So im creating an 'AI' zombie so to speak, and one of the methods is for random movement (until he spots the character).
It should toggle after running through the loop each time, but instead the 'toggle switch' stays on false, and never reverts back to true. I don't see how it logically doesn't make sense, but i might have missed something... Thanks for any help you can give me :)
public void move(){ if (toggle = true){ if(i < randomI){ setLocation(getX() - 4, getY()); i++; } else{ i=0; j=0; randomI = Greenfoot.getRandomNumber(10) + 3; toggle = false; } } if(toggle = false){ if(j < randomJ){ setLocation(getX() + 4, getY()); j++; } else{ i=0; j=0; randomJ = Greenfoot.getRandomNumber(10) + 3; toggle = true; } }