Sign in to follow this  

XNA: Vectors or variables

This topic is 2637 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
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

This topic is 2637 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this