diff --git a/DepthsBelow/DepthsBelow/Core.cs b/DepthsBelow/DepthsBelow/Core.cs index 5f538a6..752f8e9 100644 --- a/DepthsBelow/DepthsBelow/Core.cs +++ b/DepthsBelow/DepthsBelow/Core.cs @@ -22,7 +22,6 @@ namespace DepthsBelow public Camera camera; MouseInput mouseInput; public Soldier soldier; - public Grid GridChecker; private Map map; public Core() @@ -69,8 +68,6 @@ namespace DepthsBelow Soldier.LoadContent(this); soldier = new Soldier(this); - GridChecker = new Grid(); - mouseInput = new MouseInput(this); mouseInput.LoadContent(); } diff --git a/DepthsBelow/DepthsBelow/Grid.cs b/DepthsBelow/DepthsBelow/Grid.cs index 2fc0fce..48ebde3 100644 --- a/DepthsBelow/DepthsBelow/Grid.cs +++ b/DepthsBelow/DepthsBelow/Grid.cs @@ -1,33 +1,18 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; namespace DepthsBelow { - public class Grid + public static class Grid { - public const int TilePixelSize = 32; - public int TileSize() { return TilePixelSize; } - /*public Vector2 GridToScreen(Vector2 gridPos); - public Vector2 ScreenToGrid(Vector2 screenPos);*/ + public const int TileSize = 32; - public Vector2 GridToScreen; - public Vector2 ScreenToGrid; - - public Grid() - { - - } - - public Vector2 FindScreenPos(Vector2 gridPos) - { - return gridPos * TileSize(); - } - public Vector2 FindGridPos(Vector2 screenPos) - { - return screenPos / TileSize(); - } + public static Vector2 GridToScreen(Vector2 gridPos) + { + return gridPos * TileSize; + } + public static Vector2 ScreenToGrid(Vector2 screenPos) + { + return screenPos / TileSize; + } } } diff --git a/DepthsBelow/DepthsBelow/MouseInput.cs b/DepthsBelow/DepthsBelow/MouseInput.cs index b207ee0..55eba13 100644 --- a/DepthsBelow/DepthsBelow/MouseInput.cs +++ b/DepthsBelow/DepthsBelow/MouseInput.cs @@ -66,11 +66,12 @@ namespace DepthsBelow selectionRectangle = Rectangle.Empty; } - Vector2 currentGrid = core.GridChecker.FindGridPos(new Vector2(ms.X + core.camera.Position.X - core.GridChecker.TileSize() / 2, ms.Y + core.camera.Position.Y - core.GridChecker.TileSize() / 2)); + + Vector2 currentGrid = Grid.ScreenToGrid(new Vector2(ms.X + core.camera.Position.X - Grid.TileSize / 2, ms.Y + core.camera.Position.Y - Grid.TileSize / 2)); currentGrid.X = Convert.ToInt32(currentGrid.X); currentGrid.Y = Convert.ToInt32(currentGrid.Y); - Vector2 currentScreen = core.GridChecker.FindScreenPos(currentGrid); - gridRectangle = new Rectangle((int)currentScreen.X, (int)currentScreen.Y, core.GridChecker.TileSize(), core.GridChecker.TileSize()); + Vector2 currentScreen = Grid.GridToScreen(currentGrid); + gridRectangle = new Rectangle((int)currentScreen.X, (int)currentScreen.Y, Grid.TileSize, Grid.TileSize; lastMouseState = ms; }