Enemy rotation and following wonky...

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

Looks like you are using the y component twice instead of the x component in your setrot method call

I need to brand STUPID in big bold letters on my forehead, ty for finding that. While I’m here though do you know of a way to rotate the rectangles points, because it is only rotated when its drawn and this doesn’t work for hit detection, heck even if i knew how to rotate the 4 corners of the rectangle I wouldn’t know of a method to check whether or not something is within that area…

well a simple but probably horribly inefficient way is to have an Area for each rectangle and then perform an Area.intersect(other area) see http://docs.oracle.com/javase/6/docs/api/java/awt/geom/Area.html

I get how to do that, I usually do something along these lines:

if(subb.getCenterX()>=sube.getX()&&subb.getCenterX()<=(sube.getX()+sube.getWidth())&&subb.getCenterY()>=sube.getY()&&subb.getCenterY()<=(sube.getY()+sube.getHeight()))

which is just checking whether or not a point is within a rectangular area, but I know methods that check whether or not, for example, a circle and rectangle intersect. I have no idea how they check within the area of a circle like that as well as other irregular shapes.

circles are usually just distance checks or radius checks from the center point

shapes other than basic primitives(circle/aabb) usually require more complicated approaches, such as Separating Axis Theorem for example