using
System;
using
System.Collections.Generic;
using
Microsoft.Xna.Framework;
using
Microsoft.Xna.Framework.Content;
using
Microsoft.Xna.Framework.GamerServices;
using
Microsoft.Xna.Framework.Graphics;
using
Microsoft.Xna.Framework.Input;
public
class GameClass
: Microsoft.Xna.Framework.Game
{
GraphicsDeviceManager graphics;
public GameClass()
{
graphics =
new
GraphicsDeviceManager(this);
}
// ** 2DLINE ** 2DLINE ** 2DLINE ** 2DLINE **
2DLINE ** 2DLINE ** 2DLINE ** 2DLINE
// ** 2DLINE ** 2DLINE ** 2DLINE ** 2DLINE **
2DLINE ** 2DLINE ** 2DLINE ** 2DLINE
public void
DrawLine2D(Vector2 from,
Vector2 to,
Color colour)
{
VertexPositionColor[]
pnts = {new
VertexPositionColor(new
Vector3(from.X, from.Y, 0), colour),
new
VertexPositionColor(new
Vector3(to.X, to.Y, 0), colour)};
VertexDeclaration
basicEffectVertexDeclaration
=
new
VertexDeclaration(graphics.GraphicsDevice,
VertexPositionColor.VertexElements);
BasicEffect basicEffect;
basicEffect = new
BasicEffect(graphics.GraphicsDevice,
null);
basicEffect.Alpha = 1.0f;
basicEffect.VertexColorEnabled = true;
basicEffect.TextureEnabled = false;
basicEffect.Projection = Matrix.CreateOrthographicOffCenter(0.0F,
graphics.GraphicsDevice.Viewport.Width,
graphics.GraphicsDevice.Viewport.Height, 0.0f,
0.0F, -1.0F);
basicEffect.View = Matrix.Identity;
basicEffect.World = Matrix.Identity;
graphics.GraphicsDevice.VertexDeclaration =
basicEffectVertexDeclaration;
graphics.GraphicsDevice.RenderState.PointSize = 2;
// Line Thickness
graphics.GraphicsDevice.RenderState.FillMode =
FillMode.Solid;
graphics.GraphicsDevice.RenderState.CullMode =
CullMode.None;
graphics.GraphicsDevice.VertexDeclaration = basicEffectVertexDeclaration;
basicEffect.Begin();
foreach (EffectPass
pass in basicEffect.CurrentTechnique.Passes)
{
pass.Begin();
graphics.GraphicsDevice.DrawUserPrimitives<VertexPositionColor>(
PrimitiveType.LineList,
pnts, 0, 1);
pass.End();
}
basicEffect.End();
}//
End DrawQuad(..)
// ** 2DLINE ** 2DLINE ** 2DLINE ** 2DLINE **
2DLINE ** 2DLINE ** 2DLINE ** 2DLINE
// ** 2DLINE ** 2DLINE ** 2DLINE ** 2DLINE **
2DLINE ** 2DLINE ** 2DLINE ** 2DLINE
protected override
void Update(GameTime
gameTime)
{
// Allows the game to exit
if (GamePad.GetState(PlayerIndex.One).Buttons.Back
== ButtonState.Pressed)
this.Exit();
base.Update(gameTime);
}
protected override
void Draw(GameTime
gameTime)
{
GraphicsDevice.Clear(Color.SeaShell);
Vector2 s = //
ScreenSize
new Vector2(
graphics.GraphicsDevice.Viewport.Width,
graphics.GraphicsDevice.Viewport.Height);
// ** 2DLINE ** 2DLINE ** 2DLINE ** 2DLINE **
2DLINE ** 2DLINE ** 2DLINE ** 2DLINE
// ** 2DLINE ** 2DLINE ** 2DLINE ** 2DLINE **
2DLINE ** 2DLINE ** 2DLINE ** 2DLINE
DrawLine2D( new
Vector2(0,0), new
Vector2(s.X,s.Y),
Color.Red);
DrawLine2D( new
Vector2(s.X,0), new
Vector2(0,s.Y),
Color.Blue);
base.Draw(gameTime);
}
}
//
Program Entry Point
static
class Program
{
static void
Main(string[] args)
{
using (GameClass
game = new
GameClass())
{
game.Run();
}
}
} |