Static is fun!
This commit is contained in:
@@ -22,7 +22,6 @@ namespace DepthsBelow
|
|||||||
public Camera camera;
|
public Camera camera;
|
||||||
MouseInput mouseInput;
|
MouseInput mouseInput;
|
||||||
public Soldier soldier;
|
public Soldier soldier;
|
||||||
public Grid GridChecker;
|
|
||||||
private Map map;
|
private Map map;
|
||||||
|
|
||||||
public Core()
|
public Core()
|
||||||
@@ -69,8 +68,6 @@ namespace DepthsBelow
|
|||||||
Soldier.LoadContent(this);
|
Soldier.LoadContent(this);
|
||||||
soldier = new Soldier(this);
|
soldier = new Soldier(this);
|
||||||
|
|
||||||
GridChecker = new Grid();
|
|
||||||
|
|
||||||
mouseInput = new MouseInput(this);
|
mouseInput = new MouseInput(this);
|
||||||
mouseInput.LoadContent();
|
mouseInput.LoadContent();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,33 +1,18 @@
|
|||||||
using System;
|
using Microsoft.Xna.Framework;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using Microsoft.Xna.Framework;
|
|
||||||
|
|
||||||
namespace DepthsBelow
|
namespace DepthsBelow
|
||||||
{
|
{
|
||||||
public class Grid
|
public static class Grid
|
||||||
{
|
{
|
||||||
public const int TilePixelSize = 32;
|
public const int TileSize = 32;
|
||||||
public int TileSize() { return TilePixelSize; }
|
|
||||||
/*public Vector2 GridToScreen(Vector2 gridPos);
|
|
||||||
public Vector2 ScreenToGrid(Vector2 screenPos);*/
|
|
||||||
|
|
||||||
public Vector2 GridToScreen;
|
public static Vector2 GridToScreen(Vector2 gridPos)
|
||||||
public Vector2 ScreenToGrid;
|
{
|
||||||
|
return gridPos * TileSize;
|
||||||
public Grid()
|
}
|
||||||
{
|
public static Vector2 ScreenToGrid(Vector2 screenPos)
|
||||||
|
{
|
||||||
}
|
return screenPos / TileSize;
|
||||||
|
}
|
||||||
public Vector2 FindScreenPos(Vector2 gridPos)
|
|
||||||
{
|
|
||||||
return gridPos * TileSize();
|
|
||||||
}
|
|
||||||
public Vector2 FindGridPos(Vector2 screenPos)
|
|
||||||
{
|
|
||||||
return screenPos / TileSize();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -66,11 +66,12 @@ namespace DepthsBelow
|
|||||||
|
|
||||||
selectionRectangle = Rectangle.Empty;
|
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.X = Convert.ToInt32(currentGrid.X);
|
||||||
currentGrid.Y = Convert.ToInt32(currentGrid.Y);
|
currentGrid.Y = Convert.ToInt32(currentGrid.Y);
|
||||||
Vector2 currentScreen = core.GridChecker.FindScreenPos(currentGrid);
|
Vector2 currentScreen = Grid.GridToScreen(currentGrid);
|
||||||
gridRectangle = new Rectangle((int)currentScreen.X, (int)currentScreen.Y, core.GridChecker.TileSize(), core.GridChecker.TileSize());
|
gridRectangle = new Rectangle((int)currentScreen.X, (int)currentScreen.Y, Grid.TileSize, Grid.TileSize;
|
||||||
|
|
||||||
lastMouseState = ms;
|
lastMouseState = ms;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user