I have an Entity instance which is updated every game tick. Let's just assume that entity moves forward constantly. I'd like to be able to give the entity's angle to a function that makes it move in that direction:

moveForward(90); should make them move to the right. If I declared my rotation as a global int, then doing

moveForward(rotation);
rotation++;

would make it trace a small circle with its movement.

How can I do this? I assume this involves vector math; I don't know any, so a brief explanation would be nice.

The speed is however fast the enemy is, and you can determine how much they should move in the x direction and how much they move in the y direction by taking the sin or cos of the angle and multiplying by speed. Because...

sin(a) = x / speed

So:

x = speed * sin(a)

And:

cos(a) = y / speed

So:

y = speed * cos(a)

In your example moveForward(90) would yield speed * sin(90) or speed * 1 in the x direction and speed * cos(90) or 0 in the y direction (It should move to the right as you specified). That should get you started in the basic sense.

@Bane it matches the drawing I made SOH-CAH-TOA, sin is opposite over hypotenuse which in the drawing is x / speed. If the angle were on the other side of the triangle it would be reversed (and if that is more practical for the purpose of game design I could change it, but I feel its all arbitrary).
–
Kevin DiTragliaSep 14 '12 at 17:57

I'm on my mobile phone so it was pretty hard to interpret that. I just skimmed over the formulas...
–
jcoSep 14 '12 at 18:00