Added back the crosshair
This commit is contained in:
@@ -38,7 +38,7 @@ namespace Collector
|
||||
_cam.LookAt(new Vector2(Player.X,Player.Y));
|
||||
|
||||
_spriteBatch = new SpriteBatch(GraphicsDevice);
|
||||
_mouse = new Mouse(Content,_spriteBatch);
|
||||
_mouse = new Mouse(Content,_spriteBatch,_cam);
|
||||
_inputController = new InputController(_player,_mouse,_cam,_spriteBatch,Content);
|
||||
WorldRenderer = new WorldRenderer(_mouse,_inputController,_player,_spriteBatch,this,_cam);
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ public interface Restrictions {
|
||||
int FREE_SPEED = 2;
|
||||
int KEY_DELAY = 0;
|
||||
|
||||
int TILE_SIZE = 16;
|
||||
int TILE_SIZE = 32;
|
||||
int CHUNK_SIZE = 8;
|
||||
int SUPER_CHUNK_SIZE = 1;
|
||||
|
||||
|
||||
@@ -73,12 +73,12 @@ public class InputController : IRestrictions {
|
||||
|
||||
if (keyboardState.IsKeyDown(Keys.Q))
|
||||
{
|
||||
_cam.ZoomIn(0.05f);
|
||||
_cam.ZoomIn(0.01f);
|
||||
}
|
||||
|
||||
if (keyboardState.IsKeyDown(Keys.E))
|
||||
{
|
||||
_cam.ZoomOut(0.05f);
|
||||
_cam.ZoomOut(0.01f);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,33 +1,47 @@
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Content;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Microsoft.Xna.Framework.Input;
|
||||
using MonoGame.Extended;
|
||||
|
||||
namespace Collector.Character
|
||||
{
|
||||
public class Mouse : IRestrictions {
|
||||
public class Mouse : IRestrictions
|
||||
{
|
||||
private SpriteBatch _spriteBatch;
|
||||
private ContentManager _contentManager;
|
||||
private OrthographicCamera _cam;
|
||||
private Texture2D Crosshair { get; set; }
|
||||
|
||||
public Mouse(ContentManager contentManager, SpriteBatch spriteBatch)
|
||||
public Mouse(ContentManager contentManager, SpriteBatch spriteBatch, OrthographicCamera cam)
|
||||
{
|
||||
_spriteBatch = spriteBatch;
|
||||
_cam = cam;
|
||||
_contentManager = contentManager;
|
||||
Crosshair = _contentManager.Load<Texture2D>("crosshair");
|
||||
}
|
||||
|
||||
public void Draw()
|
||||
{
|
||||
_spriteBatch.Draw(Crosshair, new Vector2(Player.X, Player.Y),Color.Aqua);
|
||||
_spriteBatch.Draw(
|
||||
Crosshair,
|
||||
new Vector2(
|
||||
GetSelectedX(Microsoft.Xna.Framework.Input.Mouse.GetState().X-(IRestrictions.TileSize/2f)) + (_cam.Position.X)+(IRestrictions.TileSize/2f),
|
||||
GetSelectedY(Microsoft.Xna.Framework.Input.Mouse.GetState().Y-(IRestrictions.TileSize/2f)) + (_cam.Position.Y)+(IRestrictions.TileSize/2f)
|
||||
),
|
||||
Color.White
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
public int GetSelectedX(Vector3 mousePos) {
|
||||
return ((int)(mousePos.X)>>4)<<4;
|
||||
private static int GetSelectedX(float x)
|
||||
{
|
||||
return ((int) x >> 5) << 5;
|
||||
}
|
||||
|
||||
public int GetSelectedY(Vector3 mousePos) {
|
||||
return ((int)(mousePos.Y)>>4)<<4;
|
||||
private static int GetSelectedY(float y)
|
||||
{
|
||||
return ((int) y >> 5) << 5;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -59,7 +59,7 @@ namespace Collector.Dimension
|
||||
DrawWorld(_spriteBatch, 0);
|
||||
_inputController.Draw();
|
||||
DrawWorld(_spriteBatch, 1);
|
||||
//mouseCrosshair(batch);
|
||||
_mouse.Draw();
|
||||
_inputController.PlayerInput(_main,_spriteBatch);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user