Game Development Reference
In-Depth Information
class
Vector2
{
private int
x, y;
public int
X
{
get
{
return
x; }
set
{ x =
value
; }
}
// Same for Y property
...
}
Then the code using the
Vector2
would look like this:
Vector2
v =
new
Vector
();
v.X = 10;
// Automatically calls get property on X
The neat thing about a property is it follows the syntax of a normal variable, even
though it secretly isn't one. There are quite a few other unique features in C#, as
well,butthemajorityofthemdonotreallyseeuseinthecodeforthisgame.When
going through the code, if you find yourself struggling with C#-isms, you can find
many references online for learning C# coming from a C++ or Java background.
XNA
XNA
is a 2D and 3D game library for C# that was created by Microsoft for the
development of games that work on the PC, Xbox 360, and Windows Phone 7.
PC development is completely free, but in order to develop for the Xbox 360,
there is a $100/year subscription (though students can get one year free at
ht-
tp://www.dreamspark.com/
)
. However, paying the fee also allows you to poten-
tially release your game on the Xbox Live Indie Games store. There have been
some major commercial successes that used the XNA framework. One of the most
popular is the indie game
Bastion
, which launched on the Xbox 360 in 2011.
I personally think XNA is a great framework for first learning how to program
games (especially 3D ones). It handles the more tedious aspects of programming
a gameāsuch as creating a window, initializing the graphics library, and most im-