2D Movement

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
NoOne
Posts: 10
Joined: Wed Jan 11, 2006 9:30 pm

2D Movement

Post by NoOne »

Hi!

How can I make a object move in any angle in a 2d plane? Example: Start on the upper left and go to the lower right. Go and return, and so on.

Thx!!
Conquistador
Posts: 340
Joined: Wed Sep 28, 2005 4:38 pm
Location: Canada, Eh!

Post by Conquistador »

You should look at some of the 2D games or projects in the projects announcement forum, they'll have examples how to do this. Generally, you'll have to update the objects position every frame, figuring out the new position should be done using vectors, and a little math. Check here for some useful math tips. I had something like this for an old pong game I made a while ago, but I don't have it anymore.
Royal Hamilton Light Infantry - http://www.rhli.ca
Paris/Port Dover Pipes'n Drums - http://www.parisdover.ca
NoOne
Posts: 10
Joined: Wed Jan 11, 2006 9:30 pm

Post by NoOne »

I got it!! But i use another thing. I use another vector for to give me the direction, so i add the difference between the vector´s to make the object walk in the plane.

The right answer is to use sin and cos functions, but this appears to work. If anybody has the answer please tell me.

Thanks!! :lol:
krama757
Posts: 451
Joined: Sun Nov 06, 2005 12:07 am

Post by krama757 »

Well whats the problem?

All you need is a position, a vector that points to the direction, and a new position.

So if I am at (0,0) and I have a vector pointing to (2,3), I add (2,3) to (0,0) and get a new position....
Post Reply