Added diagonal movement and figured out how to make spriteSheets work

This commit is contained in:
2020-04-22 17:44:03 -06:00
parent 042d350877
commit 0af73bf27d
37 changed files with 171 additions and 539 deletions

View File

@@ -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)
{
}
}
}

View File

@@ -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);
}
}
}