In 2D or 3D game programming, the axes are the basis for the position of objects. With the coordinate system, it is convenient for you to place or locate the objects. In 2D games the coordinate system is made up of two axes, X and Y. In 3D games, there is another axis, that is the Z axis. Usually, drawing the axes on your screen is a handy tool for your game debugging. In this recipe, you will learn how to render the axes in 2D in Windows Phone 7.
Follow the given steps to draw the 2D axis:
1. Create a Windows Phone Game project in Visual Studio 2010, change the name from
Game1.cs
toDraw2DAxesGame.cs
. Then add a new class namedAxes2D.cs
. This class is responsible for drawing the 2D line on screen. We declare the field variables in theAxes2D
class:// Pixel Texture Texture2D pixel; public int Thickness = 5; // Render depth of the primitive line object (0 = front, 1 = // back) public float Depth;
2. Then, we define the overload constructor...