Modfying draw method in AxiosGameScreen to draw Gleed2D textures
This commit is contained in:
82
axios/Engine/Gleed2D/Camera.cs
Normal file
82
axios/Engine/Gleed2D/Camera.cs
Normal file
@@ -0,0 +1,82 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Microsoft.Xna.Framework;
|
||||
|
||||
namespace Axios.Engine.Gleed2D
|
||||
{
|
||||
public class Camera
|
||||
{
|
||||
Vector2 position;
|
||||
public Vector2 Position
|
||||
{
|
||||
get
|
||||
{
|
||||
return position;
|
||||
}
|
||||
set
|
||||
{
|
||||
position = value;
|
||||
updatematrix();
|
||||
}
|
||||
}
|
||||
|
||||
float rotation;
|
||||
public float Rotation
|
||||
{
|
||||
get
|
||||
{
|
||||
return rotation;
|
||||
}
|
||||
set
|
||||
{
|
||||
rotation = value;
|
||||
updatematrix();
|
||||
}
|
||||
}
|
||||
|
||||
float scale;
|
||||
public float Scale
|
||||
{
|
||||
get
|
||||
{
|
||||
return scale;
|
||||
}
|
||||
set
|
||||
{
|
||||
scale = value;
|
||||
updatematrix();
|
||||
}
|
||||
}
|
||||
|
||||
public Matrix matrix;
|
||||
Vector2 viewport; //width and height of the viewport
|
||||
|
||||
|
||||
public Camera(float width, float height)
|
||||
{
|
||||
position = Vector2.Zero;
|
||||
rotation = 0;
|
||||
scale = 1.0f;
|
||||
viewport = new Vector2(width, height);
|
||||
updatematrix();
|
||||
}
|
||||
|
||||
void updatematrix()
|
||||
{
|
||||
matrix = Matrix.CreateTranslation(-position.X, -position.Y, 0.0f) *
|
||||
Matrix.CreateRotationZ(rotation) *
|
||||
Matrix.CreateScale(scale) *
|
||||
Matrix.CreateTranslation(viewport.X / 2, viewport.Y / 2, 0.0f);
|
||||
}
|
||||
|
||||
public void updateviewport(float width, float height)
|
||||
{
|
||||
viewport.X = width;
|
||||
viewport.Y = height;
|
||||
updatematrix();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@@ -28,7 +28,7 @@ namespace Axios.Engine.Gleed2D
|
||||
base.load(cm, world, ref cache);
|
||||
|
||||
_body = BodyFactory.CreateCircle(world, Radius, 1f);
|
||||
_body.Position = Position;
|
||||
_body.Position = ConvertUnits.ToSimUnits(Position);
|
||||
_body.UserData = this;
|
||||
}
|
||||
|
||||
|
@@ -35,7 +35,7 @@ namespace Axios.Engine.Gleed2D
|
||||
v.Add(new Vector2(ConvertUnits.ToSimUnits(vec.X), ConvertUnits.ToSimUnits(vec.Y)));
|
||||
|
||||
_body = BodyFactory.CreateLoopShape(world, v);
|
||||
_body.Position = this.Position;
|
||||
_body.Position = ConvertUnits.ToSimUnits(this.Position);
|
||||
_body.UserData = this;
|
||||
}
|
||||
|
||||
|
@@ -29,7 +29,7 @@ namespace Axios.Engine.Gleed2D
|
||||
base.load(cm, world, ref cache);
|
||||
|
||||
_body = BodyFactory.CreateRectangle(world, Width, Height, 1f);
|
||||
_body.Position = Position;
|
||||
_body.Position = ConvertUnits.ToSimUnits(Position);
|
||||
_body.UserData = this;
|
||||
}
|
||||
}
|
||||
|
@@ -25,7 +25,7 @@ namespace Axios.Engine.Gleed2D
|
||||
/// <summary>
|
||||
/// The item's scale factor.
|
||||
/// </summary>
|
||||
public float Scale;
|
||||
public Vector2 Scale;
|
||||
|
||||
/// <summary>
|
||||
/// The color to tint the item's texture with (use white for no tint).
|
||||
|
Reference in New Issue
Block a user