Sign in to follow this  

[C#/XNA] New Concepts

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

I've been programming for a little while, and I have yet to come across something like this: currentPosition = originalPosition = initializationVector; It's from a book I'm reading, and I'm not sure what the result of that would be. Also, in the (Game) class constructer, there's the line: Enabled = false; In all the tutorials on Classes I've seen, I have yet to see one use something like this, can someone explain how and why it's used? Thanks a million.

Share this post


Link to post
Share on other sites
currentPosition = originalPosition = initializationVector;

This simply assigns initializationVector to both originalPosition and currentPosition. A standard practice for the = operator is to return the assigned value, so originalPosition is assigned first, then it passes the intitialized value to currentPosition so it can be assigned.

I usually consider this bad style and sometimes hard to read. It's just the same to write that as...

currentPosition = initializationVector;
originalPosition = initializationVector;

...but I think this is more readable.


As for your second questions, it looks to me like a bool variable Enabled is being set to false. You'd have to investigate the context of Enabled to find out what effect that has.

Share this post


Link to post
Share on other sites
Quote:
Original post by deathkrush
Enable might be declared inside the Game class. Take a look at the class definition.


That's what I was just thinking, but I pulled up the XNA documentation and Enabled is not one of the properties listed in the Game class. It may be a property inherited from a base class of Game. I suspect it's a window related property that controls whether the game window is visible and/or receiving messages, but I don't have XNA installed on this computer so I can't do any tests. Does the tutorial eventually set Enabled to true, like in an initialization function?

Share this post


Link to post
Share on other sites
Are you sure that code isn't inside of a GameComponent or DrawableGameComponent? As said above, the Game class does not contain an Enabled field or property, so unless you declared that variable, you would get a compiler error if you put that in your Game class.

Share this post


Link to post
Share on other sites

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