Advertisement

Vectors in 2D games

Started by June 04, 2000 03:08 AM
1 comment, last by Qoy 24 years, 6 months ago
I'm about to implement some AI and player movement code in my overhead scrolling 2D shooter, and I am planning on using vectors somewhere along the line. I was wondering, how much are vectors used, and what are they used for in 2D games? Are there any tutorials on how to use them anywhere? (Not how to implement them, I got that down I'm pretty sure). Are they used for player movements, or only AI stuff? Basically, a tutorial or reference somewhere would be nice. Thanks! Edited by - Qoy on 6/4/00 3:09:42 AM
Hi, vectors involve an angle and a magnitude(distence or speed). If you are just making a 2D game I would just have a x and y velocity variable and a x,y position variable and not worry about the angle of the path. Then say
x += x_velocity;
y += y_velocity;
every frame. Now just deal with changing the velocity to do different movements.

Vectors could be useful in collisions, because you have the angle and the force. That way you can calculate exactly what should happen. I would like to know of a good tutorial on vectors(3d preferbly) too. I''m sure there''s lots but one that applies vectors to calculating colliosions in games would be nice. I suppose the collision has to do with the mass or weight as well as the magnitude though.
Advertisement
I''m gonna bump this back to the top... because I was sort of wondering more about how they''re used for object (player or enemy?) movement, rather than for collision detection..

Thanks for your reply, Erik!

This topic is closed to new replies.

Advertisement