diff -r 8687559a9f72f1bf9ca9656e9f0d1b6c04f69986 -r 4ddbdd33fc18a3ee330d3b15b1eb298562c76e06 axios/Axios_WP7.csproj
--- a/axios/Axios_WP7.csproj Sat May 12 18:49:22 2012 -0500
+++ b/axios/Axios_WP7.csproj Sat May 12 22:02:23 2012 -0500
@@ -172,6 +172,7 @@
+
diff -r 8687559a9f72f1bf9ca9656e9f0d1b6c04f69986 -r 4ddbdd33fc18a3ee330d3b15b1eb298562c76e06 axios/Axios_Windows.csproj
--- a/axios/Axios_Windows.csproj Sat May 12 18:49:22 2012 -0500
+++ b/axios/Axios_Windows.csproj Sat May 12 22:02:23 2012 -0500
@@ -215,6 +215,7 @@
+
diff -r 8687559a9f72f1bf9ca9656e9f0d1b6c04f69986 -r 4ddbdd33fc18a3ee330d3b15b1eb298562c76e06 axios/Axios_Xbox_360.csproj
--- a/axios/Axios_Xbox_360.csproj Sat May 12 18:49:22 2012 -0500
+++ b/axios/Axios_Xbox_360.csproj Sat May 12 22:02:23 2012 -0500
@@ -165,6 +165,7 @@
+
diff -r 8687559a9f72f1bf9ca9656e9f0d1b6c04f69986 -r 4ddbdd33fc18a3ee330d3b15b1eb298562c76e06 axios/Axios_settings.cs
--- a/axios/Axios_settings.cs Sat May 12 18:49:22 2012 -0500
+++ b/axios/Axios_settings.cs Sat May 12 22:02:23 2012 -0500
@@ -74,6 +74,8 @@
* - Adding a cache for loading in textures for Gleed2D
* - Adding GetStream(FileMode) to get the stream of a file
* - Adding support to load a Gleed2D level from a stream
+ * - Adjusting units for Gleed2D position for Farseer bodies
+ * - Modfying draw method in AxiosGameScreen to draw Gleed2D textures
*
*/
diff -r 8687559a9f72f1bf9ca9656e9f0d1b6c04f69986 -r 4ddbdd33fc18a3ee330d3b15b1eb298562c76e06 axios/Engine/AxiosGameScreen.cs
--- a/axios/Engine/AxiosGameScreen.cs Sat May 12 18:49:22 2012 -0500
+++ b/axios/Engine/AxiosGameScreen.cs Sat May 12 22:02:23 2012 -0500
@@ -11,6 +11,7 @@
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using GameStateManagement;
+using Axios.Engine.Gleed2D;
namespace Axios.Engine
{
@@ -36,6 +37,10 @@
private AxiosUIObject prevuiobj;
private AxiosUIObject prevuifocusobj;
+ protected Level Level;
+
+ private Camera camera;
+
public AxiosGameScreen()
: base()
{
@@ -46,6 +51,7 @@
this._uiobjects = new List();
prevuiobj = null;
prevuifocusobj = null;
+
}
/*public void AddGameObject(T gameobject)
@@ -163,6 +169,7 @@
public override void Activate(bool instancePreserved)
{
base.Activate(instancePreserved);
+
#if DEBUG
if (!Axios.Settings.ScreenSaver)
@@ -171,17 +178,36 @@
this.DebugSpriteFont = man.Load(this.DebugTextFont);
}
#endif
+ camera = new Camera(ScreenManager.GraphicsDevice.Viewport.Width, ScreenManager.GraphicsDevice.Viewport.Height);
}
public override void Draw(GameTime gameTime)
{
base.Draw(gameTime);
+ if (Level != null)
+ {
+ foreach (Layer layer in Level.Layers)
+ {
+ Vector2 oldcameraposition = camera.Position;
+ camera.Position *= layer.ScrollSpeed;
+
+ ScreenManager.SpriteBatch.Begin(0, null, null, null, null, null, camera.matrix);
+ layer.draw(ScreenManager.SpriteBatch);
+ ScreenManager.SpriteBatch.End();
+
+ camera.Position = oldcameraposition;
+ }
+ }
+
foreach (AxiosGameObject g in (from x in (from i in _gameObjects where i is IDrawableAxiosGameObject select (IDrawableAxiosGameObject)i) orderby x.DrawOrder select x))
((IDrawableAxiosGameObject)g).Draw(this, gameTime);
foreach(AxiosUIObject g in (from x in _uiobjects orderby x.DrawOrder select x))
((IDrawableAxiosGameObject)g).Draw(this, gameTime);
+
+ //System.Diagnostics.Debugger.Break();
+
}
public override void Update(GameTime gameTime, bool otherScreenHasFocus, bool coveredByOtherScreen)
diff -r 8687559a9f72f1bf9ca9656e9f0d1b6c04f69986 -r 4ddbdd33fc18a3ee330d3b15b1eb298562c76e06 axios/Engine/Gleed2D/Camera.cs
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/axios/Engine/Gleed2D/Camera.cs Sat May 12 22:02:23 2012 -0500
@@ -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();
+ }
+
+ }
+}
diff -r 8687559a9f72f1bf9ca9656e9f0d1b6c04f69986 -r 4ddbdd33fc18a3ee330d3b15b1eb298562c76e06 axios/Engine/Gleed2D/CircleItem.cs
--- a/axios/Engine/Gleed2D/CircleItem.cs Sat May 12 18:49:22 2012 -0500
+++ b/axios/Engine/Gleed2D/CircleItem.cs Sat May 12 22:02:23 2012 -0500
@@ -28,7 +28,7 @@
base.load(cm, world, ref cache);
_body = BodyFactory.CreateCircle(world, Radius, 1f);
- _body.Position = Position;
+ _body.Position = ConvertUnits.ToSimUnits(Position);
_body.UserData = this;
}
diff -r 8687559a9f72f1bf9ca9656e9f0d1b6c04f69986 -r 4ddbdd33fc18a3ee330d3b15b1eb298562c76e06 axios/Engine/Gleed2D/PathItem.cs
--- a/axios/Engine/Gleed2D/PathItem.cs Sat May 12 18:49:22 2012 -0500
+++ b/axios/Engine/Gleed2D/PathItem.cs Sat May 12 22:02:23 2012 -0500
@@ -35,7 +35,7 @@
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;
}
diff -r 8687559a9f72f1bf9ca9656e9f0d1b6c04f69986 -r 4ddbdd33fc18a3ee330d3b15b1eb298562c76e06 axios/Engine/Gleed2D/RectangleItem.cs
--- a/axios/Engine/Gleed2D/RectangleItem.cs Sat May 12 18:49:22 2012 -0500
+++ b/axios/Engine/Gleed2D/RectangleItem.cs Sat May 12 22:02:23 2012 -0500
@@ -29,7 +29,7 @@
base.load(cm, world, ref cache);
_body = BodyFactory.CreateRectangle(world, Width, Height, 1f);
- _body.Position = Position;
+ _body.Position = ConvertUnits.ToSimUnits(Position);
_body.UserData = this;
}
}
diff -r 8687559a9f72f1bf9ca9656e9f0d1b6c04f69986 -r 4ddbdd33fc18a3ee330d3b15b1eb298562c76e06 axios/Engine/Gleed2D/TextureItem.cs
--- a/axios/Engine/Gleed2D/TextureItem.cs Sat May 12 18:49:22 2012 -0500
+++ b/axios/Engine/Gleed2D/TextureItem.cs Sat May 12 22:02:23 2012 -0500
@@ -25,7 +25,7 @@
///
/// The item's scale factor.
///
- public float Scale;
+ public Vector2 Scale;
///
/// The color to tint the item's texture with (use white for no tint).