Jump to content
  • Advertisement
Sign in to follow this  
BierbyteZ

XNA: Vectors or variables

This topic is 2853 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello everyone,

Im new to the programming with XNA and trieng to create my first game with it, a little space shooter like game.

I was searching for tutorials on the web and found lots of them but there is a question now that bothers me.

Some tutorials show that they just work with Variables. The position is stored in two variables x and y. Manipulated via get and set methods.

Other tutorials show that the coordinates are stored in a Vector2.

Now im a bit confused because I have no idea which is the better way to go.
Creating variables only and manipulate them or work with vectors?

Anybody can tell me what would be the better way?

Greetings
bierbytez

Share this post


Link to post
Share on other sites
Advertisement
It's almost always better to group x and y coordinates together into a single 'point' or 'vector' class (as appropriate). Most often when you see people using separate x and y variables, it's because they're not using an appropriate math library (which probably isn't the case here, since we're talking about XNA), because they aren't yet familiar with the concepts of vectors and/or user-defined types, or because they have some domain-specific reason for working with the variables in that way.

Short answer: use Vector2.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!