How can I make a character move forward in a certain direction?

Posted by Shaun Wild on Game Development See other posts from Game Development or by Shaun Wild
Published on 2012-09-14T15:51:25Z Indexed on 2012/09/14 21:49 UTC
Read the original article Hit count: 166

Filed under:

I have an entity class which is updated every game tick. Let's just assume said entity moves forward constantly. What i want to know is, how can i make it so that i can give an angle to a function and it will make my entity move in that direction. let's say for example

moveForward(90);

Would make my character move to the right, or for example declaring my rotation as a global Integer:

moveForward(rotation);
rotation++;

Would make my entity move around in a small circle, I assume this includes some kind of vector math, which I haven't done any studying on so a brief explanation of that if it's necessary would be nice.

I would appreciate a small code snippet and an explanation I can analyze, thanks in advanced :)

© Game Development or respective owner

Related posts about java