diff --git a/MLEM.Extended/Tiled/TiledExtensions.cs b/MLEM.Extended/Tiled/TiledExtensions.cs
index dbb5dae..bcc5375 100644
--- a/MLEM.Extended/Tiled/TiledExtensions.cs
+++ b/MLEM.Extended/Tiled/TiledExtensions.cs
@@ -54,9 +54,13 @@ namespace MLEM.Extended.Tiled {
}
public static RectangleF GetArea(this TiledMapObject obj, TiledMap map, Vector2 position) {
- var tileSize = new Vector2(map.TileWidth, map.TileHeight);
+ var tileSize = map.GetTileSize();
return new RectangleF(obj.Position / tileSize + position, new Size2(obj.Size.Width, obj.Size.Height) / tileSize);
}
+ public static Vector2 GetTileSize(this TiledMap map) {
+ return new Vector2(map.TileWidth, map.TileHeight);
+ }
+
}
}
\ No newline at end of file
diff --git a/MLEM.sln b/MLEM.sln
index 65fb658..59de1c2 100644
--- a/MLEM.sln
+++ b/MLEM.sln
@@ -14,6 +14,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Demos.DesktopGL", "Demos.De
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Demos.Android", "Demos.Android\Demos.Android.csproj", "{410C0262-131C-4D0E-910D-D01B4F7143E0}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sandbox", "Sandbox\Sandbox.csproj", "{289ABC96-7A0B-4EB9-A0BE-75C807C09F74}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -48,5 +50,9 @@ Global
{410C0262-131C-4D0E-910D-D01B4F7143E0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{410C0262-131C-4D0E-910D-D01B4F7143E0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{410C0262-131C-4D0E-910D-D01B4F7143E0}.Release|Any CPU.Build.0 = Release|Any CPU
+ {289ABC96-7A0B-4EB9-A0BE-75C807C09F74}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {289ABC96-7A0B-4EB9-A0BE-75C807C09F74}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {289ABC96-7A0B-4EB9-A0BE-75C807C09F74}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {289ABC96-7A0B-4EB9-A0BE-75C807C09F74}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal
diff --git a/MLEM/Cameras/Camera.cs b/MLEM/Cameras/Camera.cs
index 0c2a850..71c667e 100644
--- a/MLEM/Cameras/Camera.cs
+++ b/MLEM/Cameras/Camera.cs
@@ -7,7 +7,7 @@ namespace MLEM.Cameras {
public class Camera {
public Vector2 Position;
- public float Scale;
+ public float Scale = 1;
public bool AutoScaleWithScreen;
public Point AutoScaleReferenceSize;
public float ActualScale {
diff --git a/Sandbox/Content/Content.mgcb b/Sandbox/Content/Content.mgcb
new file mode 100644
index 0000000..60ef567
--- /dev/null
+++ b/Sandbox/Content/Content.mgcb
@@ -0,0 +1,26 @@
+
+#----------------------------- Global Properties ----------------------------#
+
+/outputDir:bin
+/intermediateDir:obj
+/platform:Windows
+/config:
+/profile:Reach
+/compress:False
+
+#-------------------------------- References --------------------------------#
+
+/reference:..\bin\Debug\net462\MonoGame.Extended.Content.Pipeline.dll
+
+#---------------------------------- Content ---------------------------------#
+
+#begin Tiled/Map.tmx
+/importer:TiledMapImporter
+/processor:TiledMapProcessor
+/build:Tiled/Map.tmx
+
+#begin Tiled/Tileset.tsx
+/importer:TiledMapTilesetImporter
+/processor:TiledMapTilesetProcessor
+/build:Tiled/Tileset.tsx
+
diff --git a/Sandbox/Content/Tiled/Map.tmx b/Sandbox/Content/Tiled/Map.tmx
new file mode 100644
index 0000000..684e5dd
--- /dev/null
+++ b/Sandbox/Content/Tiled/Map.tmx
@@ -0,0 +1,274 @@
+
+
diff --git a/Sandbox/Content/Tiled/Tiles.png b/Sandbox/Content/Tiled/Tiles.png
new file mode 100644
index 0000000..16894a8
Binary files /dev/null and b/Sandbox/Content/Tiled/Tiles.png differ
diff --git a/Sandbox/Content/Tiled/Tileset.tsx b/Sandbox/Content/Tiled/Tileset.tsx
new file mode 100644
index 0000000..4109ccb
--- /dev/null
+++ b/Sandbox/Content/Tiled/Tileset.tsx
@@ -0,0 +1,108 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Sandbox/GameImpl.cs b/Sandbox/GameImpl.cs
new file mode 100644
index 0000000..150725c
--- /dev/null
+++ b/Sandbox/GameImpl.cs
@@ -0,0 +1,42 @@
+using Microsoft.Xna.Framework;
+using Microsoft.Xna.Framework.Graphics;
+using MLEM.Cameras;
+using MLEM.Extended.Extensions;
+using MLEM.Extended.Tiled;
+using MLEM.Startup;
+using MonoGame.Extended.Tiled;
+
+namespace Sandbox {
+ public class GameImpl : MlemGame {
+
+ private Camera camera;
+ private TiledMap map;
+ private IndividualTiledMapRenderer mapRenderer;
+
+ public GameImpl() {
+ this.IsMouseVisible = true;
+ }
+
+ protected override void LoadContent() {
+ base.LoadContent();
+
+ this.map = LoadContent("Tiled/Map");
+ this.mapRenderer = new IndividualTiledMapRenderer(this.map);
+
+ this.camera = new Camera(this.GraphicsDevice) {
+ AutoScaleWithScreen = true,
+ Scale = 2,
+ LookingPosition = new Vector2(25, 25) * this.map.GetTileSize()
+ };
+ }
+
+ protected override void DoDraw(GameTime gameTime) {
+ this.GraphicsDevice.Clear(Color.Black);
+ this.SpriteBatch.Begin(SpriteSortMode.Deferred, null, SamplerState.PointClamp, null, null, null, this.camera.ViewMatrix);
+ this.mapRenderer.Draw(this.SpriteBatch, this.camera.GetVisibleRectangle());
+ this.SpriteBatch.End();
+ base.DoDraw(gameTime);
+ }
+
+ }
+}
\ No newline at end of file
diff --git a/Sandbox/Program.cs b/Sandbox/Program.cs
new file mode 100644
index 0000000..5f7b7fa
--- /dev/null
+++ b/Sandbox/Program.cs
@@ -0,0 +1,10 @@
+namespace Sandbox {
+ internal static class Program {
+
+ private static void Main() {
+ using (var game = new GameImpl())
+ game.Run();
+ }
+
+ }
+}
\ No newline at end of file
diff --git a/Sandbox/Sandbox.csproj b/Sandbox/Sandbox.csproj
new file mode 100644
index 0000000..75b58ad
--- /dev/null
+++ b/Sandbox/Sandbox.csproj
@@ -0,0 +1,27 @@
+
+
+
+ Exe
+ net462
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+