Added diagonal movement and figured out how to make spriteSheets work
@@ -61,402 +61,6 @@
|
||||
/processorParam:TextureFormat=Color
|
||||
/build:jungleGrass.png
|
||||
|
||||
#begin man.png
|
||||
/importer:TextureImporter
|
||||
/processor:TextureProcessor
|
||||
/processorParam:ColorKeyColor=255,0,255,255
|
||||
/processorParam:ColorKeyEnabled=True
|
||||
/processorParam:GenerateMipmaps=False
|
||||
/processorParam:PremultiplyAlpha=True
|
||||
/processorParam:ResizeToPowerOfTwo=False
|
||||
/processorParam:MakeSquare=False
|
||||
/processorParam:TextureFormat=Color
|
||||
/build:man.png
|
||||
|
||||
#begin man/man-0.png
|
||||
/importer:TextureImporter
|
||||
/processor:TextureProcessor
|
||||
/processorParam:ColorKeyColor=255,0,255,255
|
||||
/processorParam:ColorKeyEnabled=True
|
||||
/processorParam:GenerateMipmaps=False
|
||||
/processorParam:PremultiplyAlpha=True
|
||||
/processorParam:ResizeToPowerOfTwo=False
|
||||
/processorParam:MakeSquare=False
|
||||
/processorParam:TextureFormat=Color
|
||||
/build:man/man-0.png
|
||||
|
||||
#begin man/man-1.png
|
||||
/importer:TextureImporter
|
||||
/processor:TextureProcessor
|
||||
/processorParam:ColorKeyColor=255,0,255,255
|
||||
/processorParam:ColorKeyEnabled=True
|
||||
/processorParam:GenerateMipmaps=False
|
||||
/processorParam:PremultiplyAlpha=True
|
||||
/processorParam:ResizeToPowerOfTwo=False
|
||||
/processorParam:MakeSquare=False
|
||||
/processorParam:TextureFormat=Color
|
||||
/build:man/man-1.png
|
||||
|
||||
#begin man/man-10.png
|
||||
/importer:TextureImporter
|
||||
/processor:TextureProcessor
|
||||
/processorParam:ColorKeyColor=255,0,255,255
|
||||
/processorParam:ColorKeyEnabled=True
|
||||
/processorParam:GenerateMipmaps=False
|
||||
/processorParam:PremultiplyAlpha=True
|
||||
/processorParam:ResizeToPowerOfTwo=False
|
||||
/processorParam:MakeSquare=False
|
||||
/processorParam:TextureFormat=Color
|
||||
/build:man/man-10.png
|
||||
|
||||
#begin man/man-11.png
|
||||
/importer:TextureImporter
|
||||
/processor:TextureProcessor
|
||||
/processorParam:ColorKeyColor=255,0,255,255
|
||||
/processorParam:ColorKeyEnabled=True
|
||||
/processorParam:GenerateMipmaps=False
|
||||
/processorParam:PremultiplyAlpha=True
|
||||
/processorParam:ResizeToPowerOfTwo=False
|
||||
/processorParam:MakeSquare=False
|
||||
/processorParam:TextureFormat=Color
|
||||
/build:man/man-11.png
|
||||
|
||||
#begin man/man-12.png
|
||||
/importer:TextureImporter
|
||||
/processor:TextureProcessor
|
||||
/processorParam:ColorKeyColor=255,0,255,255
|
||||
/processorParam:ColorKeyEnabled=True
|
||||
/processorParam:GenerateMipmaps=False
|
||||
/processorParam:PremultiplyAlpha=True
|
||||
/processorParam:ResizeToPowerOfTwo=False
|
||||
/processorParam:MakeSquare=False
|
||||
/processorParam:TextureFormat=Color
|
||||
/build:man/man-12.png
|
||||
|
||||
#begin man/man-13.png
|
||||
/importer:TextureImporter
|
||||
/processor:TextureProcessor
|
||||
/processorParam:ColorKeyColor=255,0,255,255
|
||||
/processorParam:ColorKeyEnabled=True
|
||||
/processorParam:GenerateMipmaps=False
|
||||
/processorParam:PremultiplyAlpha=True
|
||||
/processorParam:ResizeToPowerOfTwo=False
|
||||
/processorParam:MakeSquare=False
|
||||
/processorParam:TextureFormat=Color
|
||||
/build:man/man-13.png
|
||||
|
||||
#begin man/man-14.png
|
||||
/importer:TextureImporter
|
||||
/processor:TextureProcessor
|
||||
/processorParam:ColorKeyColor=255,0,255,255
|
||||
/processorParam:ColorKeyEnabled=True
|
||||
/processorParam:GenerateMipmaps=False
|
||||
/processorParam:PremultiplyAlpha=True
|
||||
/processorParam:ResizeToPowerOfTwo=False
|
||||
/processorParam:MakeSquare=False
|
||||
/processorParam:TextureFormat=Color
|
||||
/build:man/man-14.png
|
||||
|
||||
#begin man/man-15.png
|
||||
/importer:TextureImporter
|
||||
/processor:TextureProcessor
|
||||
/processorParam:ColorKeyColor=255,0,255,255
|
||||
/processorParam:ColorKeyEnabled=True
|
||||
/processorParam:GenerateMipmaps=False
|
||||
/processorParam:PremultiplyAlpha=True
|
||||
/processorParam:ResizeToPowerOfTwo=False
|
||||
/processorParam:MakeSquare=False
|
||||
/processorParam:TextureFormat=Color
|
||||
/build:man/man-15.png
|
||||
|
||||
#begin man/man-16.png
|
||||
/importer:TextureImporter
|
||||
/processor:TextureProcessor
|
||||
/processorParam:ColorKeyColor=255,0,255,255
|
||||
/processorParam:ColorKeyEnabled=True
|
||||
/processorParam:GenerateMipmaps=False
|
||||
/processorParam:PremultiplyAlpha=True
|
||||
/processorParam:ResizeToPowerOfTwo=False
|
||||
/processorParam:MakeSquare=False
|
||||
/processorParam:TextureFormat=Color
|
||||
/build:man/man-16.png
|
||||
|
||||
#begin man/man-17.png
|
||||
/importer:TextureImporter
|
||||
/processor:TextureProcessor
|
||||
/processorParam:ColorKeyColor=255,0,255,255
|
||||
/processorParam:ColorKeyEnabled=True
|
||||
/processorParam:GenerateMipmaps=False
|
||||
/processorParam:PremultiplyAlpha=True
|
||||
/processorParam:ResizeToPowerOfTwo=False
|
||||
/processorParam:MakeSquare=False
|
||||
/processorParam:TextureFormat=Color
|
||||
/build:man/man-17.png
|
||||
|
||||
#begin man/man-18.png
|
||||
/importer:TextureImporter
|
||||
/processor:TextureProcessor
|
||||
/processorParam:ColorKeyColor=255,0,255,255
|
||||
/processorParam:ColorKeyEnabled=True
|
||||
/processorParam:GenerateMipmaps=False
|
||||
/processorParam:PremultiplyAlpha=True
|
||||
/processorParam:ResizeToPowerOfTwo=False
|
||||
/processorParam:MakeSquare=False
|
||||
/processorParam:TextureFormat=Color
|
||||
/build:man/man-18.png
|
||||
|
||||
#begin man/man-19.png
|
||||
/importer:TextureImporter
|
||||
/processor:TextureProcessor
|
||||
/processorParam:ColorKeyColor=255,0,255,255
|
||||
/processorParam:ColorKeyEnabled=True
|
||||
/processorParam:GenerateMipmaps=False
|
||||
/processorParam:PremultiplyAlpha=True
|
||||
/processorParam:ResizeToPowerOfTwo=False
|
||||
/processorParam:MakeSquare=False
|
||||
/processorParam:TextureFormat=Color
|
||||
/build:man/man-19.png
|
||||
|
||||
#begin man/man-2.png
|
||||
/importer:TextureImporter
|
||||
/processor:TextureProcessor
|
||||
/processorParam:ColorKeyColor=255,0,255,255
|
||||
/processorParam:ColorKeyEnabled=True
|
||||
/processorParam:GenerateMipmaps=False
|
||||
/processorParam:PremultiplyAlpha=True
|
||||
/processorParam:ResizeToPowerOfTwo=False
|
||||
/processorParam:MakeSquare=False
|
||||
/processorParam:TextureFormat=Color
|
||||
/build:man/man-2.png
|
||||
|
||||
#begin man/man-20.png
|
||||
/importer:TextureImporter
|
||||
/processor:TextureProcessor
|
||||
/processorParam:ColorKeyColor=255,0,255,255
|
||||
/processorParam:ColorKeyEnabled=True
|
||||
/processorParam:GenerateMipmaps=False
|
||||
/processorParam:PremultiplyAlpha=True
|
||||
/processorParam:ResizeToPowerOfTwo=False
|
||||
/processorParam:MakeSquare=False
|
||||
/processorParam:TextureFormat=Color
|
||||
/build:man/man-20.png
|
||||
|
||||
#begin man/man-21.png
|
||||
/importer:TextureImporter
|
||||
/processor:TextureProcessor
|
||||
/processorParam:ColorKeyColor=255,0,255,255
|
||||
/processorParam:ColorKeyEnabled=True
|
||||
/processorParam:GenerateMipmaps=False
|
||||
/processorParam:PremultiplyAlpha=True
|
||||
/processorParam:ResizeToPowerOfTwo=False
|
||||
/processorParam:MakeSquare=False
|
||||
/processorParam:TextureFormat=Color
|
||||
/build:man/man-21.png
|
||||
|
||||
#begin man/man-22.png
|
||||
/importer:TextureImporter
|
||||
/processor:TextureProcessor
|
||||
/processorParam:ColorKeyColor=255,0,255,255
|
||||
/processorParam:ColorKeyEnabled=True
|
||||
/processorParam:GenerateMipmaps=False
|
||||
/processorParam:PremultiplyAlpha=True
|
||||
/processorParam:ResizeToPowerOfTwo=False
|
||||
/processorParam:MakeSquare=False
|
||||
/processorParam:TextureFormat=Color
|
||||
/build:man/man-22.png
|
||||
|
||||
#begin man/man-23.png
|
||||
/importer:TextureImporter
|
||||
/processor:TextureProcessor
|
||||
/processorParam:ColorKeyColor=255,0,255,255
|
||||
/processorParam:ColorKeyEnabled=True
|
||||
/processorParam:GenerateMipmaps=False
|
||||
/processorParam:PremultiplyAlpha=True
|
||||
/processorParam:ResizeToPowerOfTwo=False
|
||||
/processorParam:MakeSquare=False
|
||||
/processorParam:TextureFormat=Color
|
||||
/build:man/man-23.png
|
||||
|
||||
#begin man/man-24.png
|
||||
/importer:TextureImporter
|
||||
/processor:TextureProcessor
|
||||
/processorParam:ColorKeyColor=255,0,255,255
|
||||
/processorParam:ColorKeyEnabled=True
|
||||
/processorParam:GenerateMipmaps=False
|
||||
/processorParam:PremultiplyAlpha=True
|
||||
/processorParam:ResizeToPowerOfTwo=False
|
||||
/processorParam:MakeSquare=False
|
||||
/processorParam:TextureFormat=Color
|
||||
/build:man/man-24.png
|
||||
|
||||
#begin man/man-25.png
|
||||
/importer:TextureImporter
|
||||
/processor:TextureProcessor
|
||||
/processorParam:ColorKeyColor=255,0,255,255
|
||||
/processorParam:ColorKeyEnabled=True
|
||||
/processorParam:GenerateMipmaps=False
|
||||
/processorParam:PremultiplyAlpha=True
|
||||
/processorParam:ResizeToPowerOfTwo=False
|
||||
/processorParam:MakeSquare=False
|
||||
/processorParam:TextureFormat=Color
|
||||
/build:man/man-25.png
|
||||
|
||||
#begin man/man-26.png
|
||||
/importer:TextureImporter
|
||||
/processor:TextureProcessor
|
||||
/processorParam:ColorKeyColor=255,0,255,255
|
||||
/processorParam:ColorKeyEnabled=True
|
||||
/processorParam:GenerateMipmaps=False
|
||||
/processorParam:PremultiplyAlpha=True
|
||||
/processorParam:ResizeToPowerOfTwo=False
|
||||
/processorParam:MakeSquare=False
|
||||
/processorParam:TextureFormat=Color
|
||||
/build:man/man-26.png
|
||||
|
||||
#begin man/man-27.png
|
||||
/importer:TextureImporter
|
||||
/processor:TextureProcessor
|
||||
/processorParam:ColorKeyColor=255,0,255,255
|
||||
/processorParam:ColorKeyEnabled=True
|
||||
/processorParam:GenerateMipmaps=False
|
||||
/processorParam:PremultiplyAlpha=True
|
||||
/processorParam:ResizeToPowerOfTwo=False
|
||||
/processorParam:MakeSquare=False
|
||||
/processorParam:TextureFormat=Color
|
||||
/build:man/man-27.png
|
||||
|
||||
#begin man/man-28.png
|
||||
/importer:TextureImporter
|
||||
/processor:TextureProcessor
|
||||
/processorParam:ColorKeyColor=255,0,255,255
|
||||
/processorParam:ColorKeyEnabled=True
|
||||
/processorParam:GenerateMipmaps=False
|
||||
/processorParam:PremultiplyAlpha=True
|
||||
/processorParam:ResizeToPowerOfTwo=False
|
||||
/processorParam:MakeSquare=False
|
||||
/processorParam:TextureFormat=Color
|
||||
/build:man/man-28.png
|
||||
|
||||
#begin man/man-29.png
|
||||
/importer:TextureImporter
|
||||
/processor:TextureProcessor
|
||||
/processorParam:ColorKeyColor=255,0,255,255
|
||||
/processorParam:ColorKeyEnabled=True
|
||||
/processorParam:GenerateMipmaps=False
|
||||
/processorParam:PremultiplyAlpha=True
|
||||
/processorParam:ResizeToPowerOfTwo=False
|
||||
/processorParam:MakeSquare=False
|
||||
/processorParam:TextureFormat=Color
|
||||
/build:man/man-29.png
|
||||
|
||||
#begin man/man-3.png
|
||||
/importer:TextureImporter
|
||||
/processor:TextureProcessor
|
||||
/processorParam:ColorKeyColor=255,0,255,255
|
||||
/processorParam:ColorKeyEnabled=True
|
||||
/processorParam:GenerateMipmaps=False
|
||||
/processorParam:PremultiplyAlpha=True
|
||||
/processorParam:ResizeToPowerOfTwo=False
|
||||
/processorParam:MakeSquare=False
|
||||
/processorParam:TextureFormat=Color
|
||||
/build:man/man-3.png
|
||||
|
||||
#begin man/man-30.png
|
||||
/importer:TextureImporter
|
||||
/processor:TextureProcessor
|
||||
/processorParam:ColorKeyColor=255,0,255,255
|
||||
/processorParam:ColorKeyEnabled=True
|
||||
/processorParam:GenerateMipmaps=False
|
||||
/processorParam:PremultiplyAlpha=True
|
||||
/processorParam:ResizeToPowerOfTwo=False
|
||||
/processorParam:MakeSquare=False
|
||||
/processorParam:TextureFormat=Color
|
||||
/build:man/man-30.png
|
||||
|
||||
#begin man/man-31.png
|
||||
/importer:TextureImporter
|
||||
/processor:TextureProcessor
|
||||
/processorParam:ColorKeyColor=255,0,255,255
|
||||
/processorParam:ColorKeyEnabled=True
|
||||
/processorParam:GenerateMipmaps=False
|
||||
/processorParam:PremultiplyAlpha=True
|
||||
/processorParam:ResizeToPowerOfTwo=False
|
||||
/processorParam:MakeSquare=False
|
||||
/processorParam:TextureFormat=Color
|
||||
/build:man/man-31.png
|
||||
|
||||
#begin man/man-4.png
|
||||
/importer:TextureImporter
|
||||
/processor:TextureProcessor
|
||||
/processorParam:ColorKeyColor=255,0,255,255
|
||||
/processorParam:ColorKeyEnabled=True
|
||||
/processorParam:GenerateMipmaps=False
|
||||
/processorParam:PremultiplyAlpha=True
|
||||
/processorParam:ResizeToPowerOfTwo=False
|
||||
/processorParam:MakeSquare=False
|
||||
/processorParam:TextureFormat=Color
|
||||
/build:man/man-4.png
|
||||
|
||||
#begin man/man-5.png
|
||||
/importer:TextureImporter
|
||||
/processor:TextureProcessor
|
||||
/processorParam:ColorKeyColor=255,0,255,255
|
||||
/processorParam:ColorKeyEnabled=True
|
||||
/processorParam:GenerateMipmaps=False
|
||||
/processorParam:PremultiplyAlpha=True
|
||||
/processorParam:ResizeToPowerOfTwo=False
|
||||
/processorParam:MakeSquare=False
|
||||
/processorParam:TextureFormat=Color
|
||||
/build:man/man-5.png
|
||||
|
||||
#begin man/man-6.png
|
||||
/importer:TextureImporter
|
||||
/processor:TextureProcessor
|
||||
/processorParam:ColorKeyColor=255,0,255,255
|
||||
/processorParam:ColorKeyEnabled=True
|
||||
/processorParam:GenerateMipmaps=False
|
||||
/processorParam:PremultiplyAlpha=True
|
||||
/processorParam:ResizeToPowerOfTwo=False
|
||||
/processorParam:MakeSquare=False
|
||||
/processorParam:TextureFormat=Color
|
||||
/build:man/man-6.png
|
||||
|
||||
#begin man/man-7.png
|
||||
/importer:TextureImporter
|
||||
/processor:TextureProcessor
|
||||
/processorParam:ColorKeyColor=255,0,255,255
|
||||
/processorParam:ColorKeyEnabled=True
|
||||
/processorParam:GenerateMipmaps=False
|
||||
/processorParam:PremultiplyAlpha=True
|
||||
/processorParam:ResizeToPowerOfTwo=False
|
||||
/processorParam:MakeSquare=False
|
||||
/processorParam:TextureFormat=Color
|
||||
/build:man/man-7.png
|
||||
|
||||
#begin man/man-8.png
|
||||
/importer:TextureImporter
|
||||
/processor:TextureProcessor
|
||||
/processorParam:ColorKeyColor=255,0,255,255
|
||||
/processorParam:ColorKeyEnabled=True
|
||||
/processorParam:GenerateMipmaps=False
|
||||
/processorParam:PremultiplyAlpha=True
|
||||
/processorParam:ResizeToPowerOfTwo=False
|
||||
/processorParam:MakeSquare=False
|
||||
/processorParam:TextureFormat=Color
|
||||
/build:man/man-8.png
|
||||
|
||||
#begin man/man-9.png
|
||||
/importer:TextureImporter
|
||||
/processor:TextureProcessor
|
||||
/processorParam:ColorKeyColor=255,0,255,255
|
||||
/processorParam:ColorKeyEnabled=True
|
||||
/processorParam:GenerateMipmaps=False
|
||||
/processorParam:PremultiplyAlpha=True
|
||||
/processorParam:ResizeToPowerOfTwo=False
|
||||
/processorParam:MakeSquare=False
|
||||
/processorParam:TextureFormat=Color
|
||||
/build:man/man-9.png
|
||||
|
||||
#begin roof.png
|
||||
/importer:TextureImporter
|
||||
/processor:TextureProcessor
|
||||
|
||||
|
Before Width: | Height: | Size: 248 B |
|
Before Width: | Height: | Size: 262 B |
|
Before Width: | Height: | Size: 268 B |
|
Before Width: | Height: | Size: 285 B |
|
Before Width: | Height: | Size: 268 B |
|
Before Width: | Height: | Size: 281 B |
|
Before Width: | Height: | Size: 268 B |
|
Before Width: | Height: | Size: 280 B |
|
Before Width: | Height: | Size: 248 B |
|
Before Width: | Height: | Size: 259 B |
|
Before Width: | Height: | Size: 248 B |
|
Before Width: | Height: | Size: 263 B |
|
Before Width: | Height: | Size: 248 B |
|
Before Width: | Height: | Size: 246 B |
|
Before Width: | Height: | Size: 262 B |
|
Before Width: | Height: | Size: 246 B |
|
Before Width: | Height: | Size: 260 B |
|
Before Width: | Height: | Size: 268 B |
|
Before Width: | Height: | Size: 279 B |
|
Before Width: | Height: | Size: 268 B |
|
Before Width: | Height: | Size: 285 B |
|
Before Width: | Height: | Size: 268 B |
|
Before Width: | Height: | Size: 281 B |
|
Before Width: | Height: | Size: 263 B |
|
Before Width: | Height: | Size: 268 B |
|
Before Width: | Height: | Size: 280 B |
|
Before Width: | Height: | Size: 267 B |
|
Before Width: | Height: | Size: 281 B |
|
Before Width: | Height: | Size: 267 B |
|
Before Width: | Height: | Size: 283 B |
|
Before Width: | Height: | Size: 268 B |
|
Before Width: | Height: | Size: 279 B |
@@ -1,4 +1,6 @@
|
||||
using Collector.Character;
|
||||
using System;
|
||||
using System.IO;
|
||||
using Collector.Character;
|
||||
using Collector.Dimension;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
@@ -20,34 +22,35 @@ namespace Collector
|
||||
private WorldRenderer WorldRenderer { get; set; }
|
||||
|
||||
public Main()
|
||||
{
|
||||
{
|
||||
_graphics = new GraphicsDeviceManager(this);
|
||||
Content.RootDirectory = "Content";
|
||||
IsMouseVisible = true;
|
||||
}
|
||||
|
||||
protected override void Initialize()
|
||||
{// TODO: Add your initialization logic here
|
||||
{
|
||||
// TODO: Add your initialization logic here
|
||||
base.Initialize();
|
||||
|
||||
BlockMaterials.Initialize(Content);
|
||||
|
||||
var viewportAdapter = new BoxingViewportAdapter(Window, GraphicsDevice, 800, 480);
|
||||
_player = new Player(0,0);
|
||||
_player = new Player(0, 0);
|
||||
_cam = new OrthographicCamera(viewportAdapter);
|
||||
_cam.LookAt(new Vector2(Player.X,Player.Y));
|
||||
_cam.LookAt(new Vector2(Player.X, Player.Y));
|
||||
|
||||
_spriteBatch = new SpriteBatch(GraphicsDevice);
|
||||
_mouse = new Mouse(Content,_spriteBatch,_cam);
|
||||
_inputController = new InputController(_player,_mouse,_cam,_spriteBatch,Content);
|
||||
WorldRenderer = new WorldRenderer(_mouse,_inputController,_player,_spriteBatch,this,_cam);
|
||||
_mouse = new Mouse(Content, _spriteBatch, _cam);
|
||||
_inputController = new InputController(_player, _mouse, _cam, _spriteBatch, Content);
|
||||
WorldRenderer = new WorldRenderer(_mouse, _inputController, _player, _spriteBatch, this, _cam);
|
||||
}
|
||||
|
||||
protected override void Update(GameTime gameTime)
|
||||
{// TODO: Add your update logic here/*
|
||||
{
|
||||
// TODO: Add your update logic here/*
|
||||
base.Update(gameTime);
|
||||
_inputController.PlayerInput(this,_spriteBatch);
|
||||
|
||||
|
||||
World.LoadChunks();
|
||||
World.UnloadChunks();
|
||||
}
|
||||
@@ -59,7 +62,7 @@ namespace Collector
|
||||
GraphicsDevice.Clear(Color.CornflowerBlue);
|
||||
_spriteBatch.Begin(transformMatrix: transformMatrix);
|
||||
_mouse.Draw();
|
||||
WorldRenderer.Draw();
|
||||
WorldRenderer.Draw(gameTime);
|
||||
_spriteBatch.End();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,35 +9,93 @@ using Microsoft.Xna.Framework.Input;
|
||||
using MonoGame.Extended;
|
||||
using Mouse = Collector.Character.Mouse;
|
||||
|
||||
public class InputController : IRestrictions {
|
||||
|
||||
public class InputController : IRestrictions
|
||||
{
|
||||
private Player _player;
|
||||
private Mouse _mouse;
|
||||
private OrthographicCamera _cam;
|
||||
private Dictionary<string, Rectangle> animations;
|
||||
public string Input { get; set; }
|
||||
private SpriteBatch _spriteBatch;
|
||||
private ContentManager _content;
|
||||
private Dictionary<string, Rectangle[]> _animations;
|
||||
private string Input { get; set; }
|
||||
private readonly SpriteBatch _spriteBatch;
|
||||
private readonly Texture2D _texture;
|
||||
private int frameNumber;
|
||||
private int timeSinceLastFrame;
|
||||
|
||||
public InputController(Player player, Mouse mouse, OrthographicCamera cam, SpriteBatch spriteBatch, ContentManager contentManager)
|
||||
|
||||
public InputController(Player player, Mouse mouse, OrthographicCamera cam, SpriteBatch spriteBatch,
|
||||
ContentManager contentManager)
|
||||
{
|
||||
_player = player;
|
||||
_mouse = mouse;
|
||||
_cam = cam;
|
||||
_spriteBatch = spriteBatch;
|
||||
_content = contentManager;
|
||||
frameNumber = 0;
|
||||
_texture = contentManager.Load<Texture2D>("man");
|
||||
Input = "Down";
|
||||
|
||||
animations = new Dictionary<string, Rectangle>
|
||||
|
||||
_animations = new Dictionary<string, Rectangle[]>
|
||||
{
|
||||
["Up"] = new Rectangle(0, 0, 32, 32),
|
||||
["Right"] = new Rectangle(0, 0, 32, 32),
|
||||
["Left"] = new Rectangle(0, 0, 32, 32),
|
||||
["Right"] = new Rectangle(0, 0, 32, 32)
|
||||
["Up"] = new Rectangle[4]
|
||||
{
|
||||
new Rectangle(32*0, 0, 32, 32),
|
||||
new Rectangle(32*1, 0, 32, 32),
|
||||
new Rectangle(32*2, 0, 32, 32),
|
||||
new Rectangle(32*3, 0, 32, 32)
|
||||
},
|
||||
["Right"] = new Rectangle[4]
|
||||
{
|
||||
new Rectangle(32*0 + 32*4, 32, 32, 32),
|
||||
new Rectangle(32*1 + 32*4, 32, 32, 32),
|
||||
new Rectangle(32*2 + 32*4, 32, 32, 32),
|
||||
new Rectangle(32*3 + 32*4, 32, 32, 32)
|
||||
},
|
||||
["UpRight"] = new Rectangle[4]
|
||||
{
|
||||
new Rectangle(32*0 + 32*4, 32*2, 32, 32),
|
||||
new Rectangle(32*1 + 32*4, 32*2, 32, 32),
|
||||
new Rectangle(32*2 + 32*4, 32*2, 32, 32),
|
||||
new Rectangle(32*3 + 32*4, 32*2, 32, 32)
|
||||
},
|
||||
["DownRight"] = new Rectangle[4]
|
||||
{
|
||||
new Rectangle(32*0 + 32*4, 32*3, 32, 32),
|
||||
new Rectangle(32*1 + 32*4, 32*3, 32, 32),
|
||||
new Rectangle(32*2 + 32*4, 32*3, 32, 32),
|
||||
new Rectangle(32*3 + 32*4, 32*3, 32, 32)
|
||||
},
|
||||
["Left"] = new Rectangle[4]
|
||||
{
|
||||
new Rectangle(32*0, 32, 32, 32),
|
||||
new Rectangle(32*1, 32, 32, 32),
|
||||
new Rectangle(32*2, 32, 32, 32),
|
||||
new Rectangle(32*3, 32, 32, 32)
|
||||
},
|
||||
["UpLeft"] = new Rectangle[4]
|
||||
{
|
||||
new Rectangle(32*0, 32*2, 32, 32),
|
||||
new Rectangle(32*1, 32*2, 32, 32),
|
||||
new Rectangle(32*2, 32*2, 32, 32),
|
||||
new Rectangle(32*3, 32*2, 32, 32)
|
||||
},
|
||||
["DownLeft"] = new Rectangle[4]
|
||||
{
|
||||
new Rectangle(32*0, 32, 32, 32),
|
||||
new Rectangle(32*1, 32, 32, 32),
|
||||
new Rectangle(32*2, 32, 32, 32),
|
||||
new Rectangle(32*3, 32, 32, 32)
|
||||
},
|
||||
["Down"] = new Rectangle[4]
|
||||
{
|
||||
new Rectangle(32*0 + 32*4, 0, 32, 32),
|
||||
new Rectangle(32*1 + 32*4, 0, 32, 32),
|
||||
new Rectangle(32*2 + 32*4, 0, 32, 32),
|
||||
new Rectangle(32*3 + 32*4, 0, 32, 32)
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
public void PlayerInput(Main main, SpriteBatch spriteBatch)
|
||||
public void PlayerInput(Main main, Mouse mouse, GameTime gameTime)
|
||||
{
|
||||
var keyboardState = Keyboard.GetState();
|
||||
const int movementSpeed = IRestrictions.MovementSpeed;
|
||||
@@ -45,135 +103,105 @@ public class InputController : IRestrictions {
|
||||
{
|
||||
Quit(main);
|
||||
}
|
||||
if (keyboardState.IsKeyDown(Keys.W))
|
||||
|
||||
if (keyboardState.IsKeyUp(Keys.W) && keyboardState.IsKeyUp(Keys.A) && keyboardState.IsKeyUp(Keys.S) && keyboardState.IsKeyUp(Keys.D))
|
||||
{
|
||||
Input = "Up";
|
||||
Player.Y += -movementSpeed;
|
||||
_cam.Move(new Vector2(0,-movementSpeed));
|
||||
}
|
||||
if (keyboardState.IsKeyDown(Keys.A))
|
||||
{
|
||||
Player.X += -movementSpeed;
|
||||
_cam.Move(new Vector2(-movementSpeed,0));
|
||||
Input = "Left";
|
||||
}
|
||||
if (keyboardState.IsKeyDown(Keys.S))
|
||||
{
|
||||
Player.Y += movementSpeed;
|
||||
_cam.Move(new Vector2(0,movementSpeed));
|
||||
Input = "Down";
|
||||
frameNumber = 0;
|
||||
_mouse.Draw();
|
||||
}
|
||||
|
||||
if (keyboardState.IsKeyDown(Keys.D))
|
||||
if (keyboardState.IsKeyDown(Keys.W) && keyboardState.IsKeyDown(Keys.D))
|
||||
{
|
||||
updateAnimationFrame(gameTime);
|
||||
Input = "UpRight";
|
||||
Player.Y += -movementSpeed;
|
||||
Player.X += movementSpeed;
|
||||
_cam.Move(new Vector2(movementSpeed, -movementSpeed));
|
||||
}
|
||||
|
||||
else if (keyboardState.IsKeyDown(Keys.W) && keyboardState.IsKeyDown(Keys.A))
|
||||
{
|
||||
updateAnimationFrame(gameTime);
|
||||
Input = "UpLeft";
|
||||
Player.Y += -movementSpeed;
|
||||
Player.X += -movementSpeed;
|
||||
_cam.Move(new Vector2(-movementSpeed, -movementSpeed));
|
||||
}
|
||||
|
||||
else if (keyboardState.IsKeyDown(Keys.S) && keyboardState.IsKeyDown(Keys.D))
|
||||
{
|
||||
updateAnimationFrame(gameTime);
|
||||
Input = "DownRight";
|
||||
Player.Y += movementSpeed;
|
||||
Player.X += movementSpeed;
|
||||
_cam.Move(new Vector2(movementSpeed, movementSpeed));
|
||||
}
|
||||
else if (keyboardState.IsKeyDown(Keys.S) && keyboardState.IsKeyDown(Keys.A))
|
||||
{
|
||||
updateAnimationFrame(gameTime);
|
||||
Input = "DownLeft";
|
||||
Player.Y += movementSpeed;
|
||||
Player.X += -movementSpeed;
|
||||
_cam.Move(new Vector2(-movementSpeed, movementSpeed));
|
||||
}
|
||||
else if (keyboardState.IsKeyDown(Keys.W))
|
||||
{
|
||||
updateAnimationFrame(gameTime);
|
||||
Input = "Up";
|
||||
Player.Y += -movementSpeed;
|
||||
_cam.Move(new Vector2(0, -movementSpeed));
|
||||
}
|
||||
else if (keyboardState.IsKeyDown(Keys.A))
|
||||
{
|
||||
updateAnimationFrame(gameTime);
|
||||
Player.X += -movementSpeed;
|
||||
_cam.Move(new Vector2(-movementSpeed, 0));
|
||||
Input = "Left";
|
||||
}
|
||||
else if (keyboardState.IsKeyDown(Keys.S))
|
||||
{
|
||||
updateAnimationFrame(gameTime);
|
||||
Player.Y += movementSpeed;
|
||||
_cam.Move(new Vector2(0, movementSpeed));
|
||||
Input = "Down";
|
||||
}
|
||||
else if (keyboardState.IsKeyDown(Keys.D))
|
||||
{
|
||||
updateAnimationFrame(gameTime);
|
||||
Player.X += movementSpeed;
|
||||
_cam.Move(new Vector2(movementSpeed, 0));
|
||||
Input = "Right";
|
||||
}
|
||||
|
||||
if (keyboardState.IsKeyDown(Keys.Q))
|
||||
{
|
||||
_cam.ZoomIn(0.01f);
|
||||
}
|
||||
|
||||
if (keyboardState.IsKeyDown(Keys.E))
|
||||
{
|
||||
_cam.ZoomOut(0.01f);
|
||||
}
|
||||
}
|
||||
|
||||
private void updateAnimationFrame(GameTime gameTime)
|
||||
{
|
||||
timeSinceLastFrame += gameTime.ElapsedGameTime.Milliseconds;
|
||||
if (timeSinceLastFrame <= 99) return;
|
||||
frameNumber++;
|
||||
timeSinceLastFrame = 0;
|
||||
if (frameNumber > 3)
|
||||
{
|
||||
frameNumber = 0;
|
||||
}
|
||||
}
|
||||
|
||||
private static void Quit(Game main)
|
||||
{
|
||||
main.Exit();
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
public void handleInput() {
|
||||
i++;
|
||||
if (Gdx.input.isKeyPressed(Input.Keys.Q)) {
|
||||
Main.cam.zoom += 5;
|
||||
}
|
||||
if (Gdx.input.isKeyPressed(Input.Keys.E)) {
|
||||
Main.cam.zoom -= 5;
|
||||
}
|
||||
if ((Gdx.input.isButtonJustPressed(Input.Buttons.LEFT) || Gdx.input.isButtonJustPressed(Input.Buttons.RIGHT) )&& i > KEY_DELAY) {
|
||||
Vector3 mousePos = new Vector3(Gdx.input.getX(), Gdx.input.getY(), 0);
|
||||
Main.cam.unproject(mousePos);
|
||||
int x = mouse.getSelectedX(mousePos) >> TILE_SHIFT;
|
||||
int y = mouse.getSelectedY(mousePos) >> TILE_SHIFT;
|
||||
if(Gdx.input.isButtonJustPressed(Input.Buttons.LEFT)) {
|
||||
i = 0;
|
||||
Chunks.placeBlock(x, y, "wood");
|
||||
}
|
||||
if (Gdx.input.isButtonJustPressed(Input.Buttons.RIGHT)) {
|
||||
i = 0;
|
||||
Chunks.removeBlock(x,y);
|
||||
}
|
||||
}
|
||||
|
||||
if (Gdx.input.isKeyPressed(Input.Keys.W) && Gdx.input.isKeyPressed(Input.Keys.A) && i > KEY_DELAY) {
|
||||
i = 0;
|
||||
player.setAnimation(animations.get("UpLeft"));
|
||||
Player.addX(-MOVEMENT_SPEED);
|
||||
Player.addY(MOVEMENT_SPEED);
|
||||
Main.cam.translate(-MOVEMENT_SPEED, MOVEMENT_SPEED);
|
||||
}
|
||||
else if (Gdx.input.isKeyPressed(Input.Keys.W) && Gdx.input.isKeyPressed(Input.Keys.D) && i > KEY_DELAY) {
|
||||
i = 0;
|
||||
player.setAnimation(animations.get("UpRight"));
|
||||
Player.addX(MOVEMENT_SPEED);
|
||||
Player.addY(MOVEMENT_SPEED);
|
||||
Main.cam.translate(MOVEMENT_SPEED, MOVEMENT_SPEED);
|
||||
}
|
||||
else if (Gdx.input.isKeyPressed(Input.Keys.S) && Gdx.input.isKeyPressed(Input.Keys.A) && i > KEY_DELAY) {
|
||||
i = 0;
|
||||
player.setAnimation(animations.get("DownLeft"));
|
||||
Player.addX(-MOVEMENT_SPEED);
|
||||
Player.addY(-MOVEMENT_SPEED);
|
||||
Main.cam.translate(-MOVEMENT_SPEED, -MOVEMENT_SPEED);
|
||||
}
|
||||
else if (Gdx.input.isKeyPressed(Input.Keys.S) && Gdx.input.isKeyPressed(Input.Keys.D) && i > KEY_DELAY) {
|
||||
i = 0;
|
||||
player.setAnimation(animations.get("DownRight"));
|
||||
Player.addX(MOVEMENT_SPEED);
|
||||
Player.addY(-MOVEMENT_SPEED);
|
||||
|
||||
Main.cam.translate(MOVEMENT_SPEED, -MOVEMENT_SPEED);
|
||||
}
|
||||
else if (Gdx.input.isKeyPressed(Input.Keys.A) && i > KEY_DELAY) {
|
||||
i = 0;
|
||||
player.setAnimation(animations.get("Left"));
|
||||
Player.addX(-MOVEMENT_SPEED);
|
||||
Main.cam.translate(-MOVEMENT_SPEED, 0);
|
||||
}
|
||||
else if (Gdx.input.isKeyPressed(Input.Keys.D) && i > KEY_DELAY) {
|
||||
i = 0;
|
||||
player.setAnimation(animations.get("Right"));
|
||||
Player.addX(MOVEMENT_SPEED);
|
||||
Main.cam.translate(MOVEMENT_SPEED, 0);
|
||||
}
|
||||
else if (Gdx.input.isKeyPressed(Input.Keys.S) && i > KEY_DELAY) {
|
||||
i = 0;
|
||||
player.setAnimation(animations.get("Down"));
|
||||
Player.addY(-MOVEMENT_SPEED);
|
||||
Main.cam.translate(0, -MOVEMENT_SPEED);
|
||||
}
|
||||
if (Gdx.input.isKeyPressed(Input.Keys.W) && i > KEY_DELAY) {
|
||||
i = 0;
|
||||
player.setAnimation(animations.get("Up"));
|
||||
Player.addY(MOVEMENT_SPEED);
|
||||
Main.cam.translate(0, MOVEMENT_SPEED);
|
||||
}
|
||||
Main.cam.update();
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
public void Draw()
|
||||
{
|
||||
var texture = _content.Load<Texture2D>("man/man-0");
|
||||
_spriteBatch.Draw(texture,new Vector2(Player.X,Player.Y),Color.White);
|
||||
_spriteBatch.Draw(_texture, new Vector2(Player.X, Player.Y), _animations[Input][frameNumber], Color.White);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,12 +5,12 @@ using Microsoft.Xna.Framework.Graphics;
|
||||
|
||||
namespace Collector.Dimension
|
||||
{
|
||||
public class BlockMaterials {
|
||||
public static Dictionary<string,Block> Materials = new Dictionary<string, Block>();
|
||||
public static Dictionary<string,Texture2D> Textures = new Dictionary<string, Texture2D>();
|
||||
public static class BlockMaterials {
|
||||
public static readonly Dictionary<string,Block> Materials = new Dictionary<string, Block>();
|
||||
public static readonly Dictionary<string,Texture2D> Textures = new Dictionary<string, Texture2D>();
|
||||
|
||||
//Private so the singleton can't be instantiated
|
||||
internal BlockMaterials() {}
|
||||
static BlockMaterials() {}
|
||||
|
||||
public static void Initialize(ContentManager content){
|
||||
Materials.Add("grass",new Block("grass"));
|
||||
@@ -27,11 +27,6 @@ namespace Collector.Dimension
|
||||
{
|
||||
Textures.Add(name,content.Load<Texture2D>(name));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void Draw(string name,SpriteBatch _spriteBatch,int x, int y)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,8 +15,10 @@ namespace Collector.Dimension
|
||||
private SpriteBatch _spriteBatch;
|
||||
private Main _main;
|
||||
private OrthographicCamera _orthographicCamera;
|
||||
private double _elapsedTime;
|
||||
|
||||
public WorldRenderer(Mouse mouse, InputController inputController, Player player, SpriteBatch spriteBatch, Main main, OrthographicCamera orthographicCamera)
|
||||
public WorldRenderer(Mouse mouse, InputController inputController, Player player, SpriteBatch spriteBatch,
|
||||
Main main, OrthographicCamera orthographicCamera)
|
||||
{
|
||||
_mouse = mouse;
|
||||
_inputController = inputController;
|
||||
@@ -24,6 +26,7 @@ namespace Collector.Dimension
|
||||
_spriteBatch = spriteBatch;
|
||||
_main = main;
|
||||
_orthographicCamera = orthographicCamera;
|
||||
_elapsedTime = 0;
|
||||
}
|
||||
|
||||
private static void DrawWorld(SpriteBatch batch, int layer)
|
||||
@@ -53,14 +56,13 @@ namespace Collector.Dimension
|
||||
}
|
||||
*/
|
||||
|
||||
public void Draw()
|
||||
public void Draw(GameTime gameTime)
|
||||
{
|
||||
//Higher means draws in a lower layer
|
||||
DrawWorld(_spriteBatch, 0);
|
||||
_inputController.Draw();
|
||||
_inputController.PlayerInput(_main,_mouse,gameTime);
|
||||
DrawWorld(_spriteBatch, 1);
|
||||
_mouse.Draw();
|
||||
_inputController.PlayerInput(_main,_spriteBatch);
|
||||
}
|
||||
}
|
||||
}
|
||||