Attempting to make enemies turn and follow player, but they all seem to… I’m not sure, they rotate in the general direction of the player, but at times they go off on their own. The way I organized my classes is horrendous, but I wanted to throw something together to test and see if I could do something like this… apparently not.
I’m Posting the whole code here:
http://pastebin.java-gaming.org/b5fd1362b3f
but I know it has to be something wrong with the rotation I use, here is where I update the enemies:
for(Move sube: enemies)
{
//set rotation
sube.setRot(Math.atan2(playerCenterY - sube.getCenterY(), playerCenterX - sube.getCenterY()));
sube.setXloc(sube.getX() + (ENEMY_SPEED * Math.cos(sube.getRot())));
sube.setYloc(sube.getY() + (ENEMY_SPEED * Math.sin(sube.getRot())));
}
Am I calculating the rotation wrong? any help is appreciated