Added back the map, movement and zooming. Also changed all Textures to 32bit
This commit is contained in:
@@ -1,59 +1,91 @@
|
||||
using System.Collections.Generic;
|
||||
using Collector;
|
||||
using Collector.Character;
|
||||
using Collector.Dimension;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Content;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Microsoft.Xna.Framework.Input;
|
||||
using MonoGame.Extended;
|
||||
using Mouse = Collector.Character.Mouse;
|
||||
|
||||
public class InputController : IRestrictions {
|
||||
|
||||
private Player player;
|
||||
private Mouse mouse;
|
||||
//private Dictionary<string, Animation<TextureAtlas.AtlasRegion>> animations;
|
||||
int i = 0;
|
||||
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;
|
||||
|
||||
public InputController(Player player, Mouse mouse)
|
||||
public InputController(Player player, Mouse mouse, OrthographicCamera cam, SpriteBatch spriteBatch, ContentManager contentManager)
|
||||
{
|
||||
this.player = player;
|
||||
this.mouse = mouse;
|
||||
_player = player;
|
||||
_mouse = mouse;
|
||||
_cam = cam;
|
||||
_spriteBatch = spriteBatch;
|
||||
_content = contentManager;
|
||||
Input = "Down";
|
||||
|
||||
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)
|
||||
};
|
||||
}
|
||||
|
||||
public InputController() {
|
||||
|
||||
/*
|
||||
animations = new HashMap<>();
|
||||
animations.put("Up", new Animation<>(1 / 4f, player.getTextureAtlas().findRegions(player.getSpriteName() + "_" + "Up")));
|
||||
animations.put("UpRight", new Animation<>(1 / 4f, player.getTextureAtlas().findRegions(player.getSpriteName() + "_" + "UpRight")));
|
||||
animations.put("UpLeft", new Animation<>(1 / 4f, player.getTextureAtlas().findRegions(player.getSpriteName() + "_" + "UpLeft")));
|
||||
animations.put("Down", new Animation<>(1 / 4f, player.getTextureAtlas().findRegions(player.getSpriteName() + "_" + "Down")));
|
||||
animations.put("DownRight", new Animation<>(1 / 4f, player.getTextureAtlas().findRegions(player.getSpriteName() + "_" + "DownRight")));
|
||||
animations.put("DownLeft", new Animation<>(1 / 4f, player.getTextureAtlas().findRegions(player.getSpriteName() + "_" + "DownLeft")));
|
||||
animations.put("Left", new Animation<>(1 / 4f, player.getTextureAtlas().findRegions(player.getSpriteName() + "_" + "Left")));
|
||||
animations.put("Right", new Animation<>(1 / 4f, player.getTextureAtlas().findRegions(player.getSpriteName() + "_" + "Right")));
|
||||
*/
|
||||
}
|
||||
|
||||
private void PlayerInput()
|
||||
public void PlayerInput(Main main, SpriteBatch spriteBatch)
|
||||
{
|
||||
if (Keyboard.GetState().IsKeyDown(Keys.Escape))
|
||||
var keyboardState = Keyboard.GetState();
|
||||
const int movementSpeed = IRestrictions.MovementSpeed;
|
||||
if (keyboardState.IsKeyDown(Keys.Escape))
|
||||
{
|
||||
Exit();
|
||||
Quit(main);
|
||||
}
|
||||
else if(Keyboard.GetState().IsKeyDown(Keys.W))
|
||||
if (keyboardState.IsKeyDown(Keys.W))
|
||||
{
|
||||
|
||||
Input = "Up";
|
||||
Player.Y += -movementSpeed;
|
||||
_cam.Move(new Vector2(0,-movementSpeed));
|
||||
}
|
||||
else if(Keyboard.GetState().IsKeyDown(Keys.A))
|
||||
if (keyboardState.IsKeyDown(Keys.A))
|
||||
{
|
||||
|
||||
Player.X += -movementSpeed;
|
||||
_cam.Move(new Vector2(-movementSpeed,0));
|
||||
Input = "Left";
|
||||
}
|
||||
else if(Keyboard.GetState().IsKeyDown(Keys.S))
|
||||
if (keyboardState.IsKeyDown(Keys.S))
|
||||
{
|
||||
|
||||
Player.Y += movementSpeed;
|
||||
_cam.Move(new Vector2(0,movementSpeed));
|
||||
Input = "Down";
|
||||
}
|
||||
else if(Keyboard.GetState().IsKeyDown(Keys.D))
|
||||
|
||||
if (keyboardState.IsKeyDown(Keys.D))
|
||||
{
|
||||
|
||||
Player.X += movementSpeed;
|
||||
_cam.Move(new Vector2(movementSpeed, 0));
|
||||
Input = "Right";
|
||||
}
|
||||
|
||||
if (keyboardState.IsKeyDown(Keys.Q))
|
||||
{
|
||||
_cam.ZoomIn(0.05f);
|
||||
}
|
||||
|
||||
if (keyboardState.IsKeyDown(Keys.E))
|
||||
{
|
||||
_cam.ZoomOut(0.05f);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static void Quit(Game main)
|
||||
{
|
||||
main.Exit();
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -138,5 +170,10 @@ public void handleInput() {
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
public void Draw()
|
||||
{
|
||||
var texture = _content.Load<Texture2D>("man/man-0");
|
||||
_spriteBatch.Draw(texture,new Vector2(Player.X,Player.Y),Color.White);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,25 +1,33 @@
|
||||
package Collector.Character;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Content;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
|
||||
import Collector.Restrictions;
|
||||
import com.badlogic.gdx.graphics.Texture;
|
||||
import com.badlogic.gdx.math.Vector3;
|
||||
namespace Collector.Character
|
||||
{
|
||||
public class Mouse : IRestrictions {
|
||||
private SpriteBatch _spriteBatch;
|
||||
private ContentManager _contentManager;
|
||||
private Texture2D Crosshair { get; set; }
|
||||
|
||||
public class Mouse implements Restrictions {
|
||||
Texture crosshair;
|
||||
public Mouse(ContentManager contentManager, SpriteBatch spriteBatch)
|
||||
{
|
||||
_spriteBatch = spriteBatch;
|
||||
_contentManager = contentManager;
|
||||
Crosshair = _contentManager.Load<Texture2D>("crosshair");
|
||||
}
|
||||
|
||||
public Mouse() {
|
||||
this.crosshair = new Texture("assets/crosshair.png");
|
||||
}
|
||||
public void Draw()
|
||||
{
|
||||
_spriteBatch.Draw(Crosshair, new Vector2(Player.X, Player.Y),Color.Aqua);
|
||||
}
|
||||
|
||||
public Texture getCrosshair() {
|
||||
return crosshair;
|
||||
}
|
||||
|
||||
public int GetSelectedX(Vector3 mousePos) {
|
||||
return ((int)(mousePos.X)>>4)<<4;
|
||||
}
|
||||
|
||||
public int getSelectedX(Vector3 mousePos) {
|
||||
return ((int)(mousePos.x)>>4)<<4;
|
||||
}
|
||||
|
||||
public int getSelectedY(Vector3 mousePos) {
|
||||
return ((int)(mousePos.y)>>4)<<4;
|
||||
public int GetSelectedY(Vector3 mousePos) {
|
||||
return ((int)(mousePos.Y)>>4)<<4;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,62 +1,19 @@
|
||||
using Collector;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.Xna.Framework;
|
||||
|
||||
public class Player : IRestrictions {
|
||||
private static int X;
|
||||
private static int Y;
|
||||
private string SpriteName;
|
||||
private Inventory playerInventory;
|
||||
namespace Collector.Character
|
||||
{
|
||||
public class Player : IRestrictions
|
||||
{
|
||||
public static int X { get; set; }
|
||||
public static int Y { get; set; }
|
||||
public Dictionary<string,Rectangle> Animation { get; set; }
|
||||
//private Inventory PlayerInventory { get; }
|
||||
|
||||
public Player(int x, int y) {
|
||||
//Player location
|
||||
X = x<<IRestrictions.TileShift;
|
||||
Y = y<<IRestrictions.TileShift;
|
||||
|
||||
//Player Inventory
|
||||
playerInventory = new Inventory();
|
||||
|
||||
//Player animation
|
||||
//spriteName = "man";
|
||||
//textureAtlas = new TextureAtlas("man.atlas");
|
||||
//Array<TextureAtlas.AtlasRegion> keyFrames = textureAtlas.findRegions(spriteName + "_Down");
|
||||
//float frameDuration = 1 / 4f;
|
||||
//animation = new Animation<>(frameDuration, keyFrames);
|
||||
public Player(int x, int y) {
|
||||
X = x<<IRestrictions.TileShift;
|
||||
Y = y<<IRestrictions.TileShift;
|
||||
//PlayerInventory = new Inventory();
|
||||
}
|
||||
}
|
||||
|
||||
public static int getX() {
|
||||
return X;
|
||||
}
|
||||
|
||||
public static int getY() {
|
||||
return Y;
|
||||
}
|
||||
|
||||
public static void addX(int x){
|
||||
X += x;
|
||||
}
|
||||
|
||||
public static void addY(int y){
|
||||
Y += y;
|
||||
}
|
||||
|
||||
/*
|
||||
public String getSpriteName() {
|
||||
return spriteName;
|
||||
}
|
||||
|
||||
public Animation<TextureAtlas.AtlasRegion> getAnimation() {
|
||||
return animation;
|
||||
}
|
||||
|
||||
public void setAnimation(Animation<TextureAtlas.AtlasRegion> animationTemp) {
|
||||
animation = animationTemp;
|
||||
}
|
||||
|
||||
public void dispose(){
|
||||
//textureAtlas.dispose();
|
||||
}
|
||||
|
||||
public TextureAtlas getTextureAtlas() {
|
||||
return textureAtlas;
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
@@ -1,12 +1,8 @@
|
||||
|
||||
public class Block {
|
||||
private string name = null;
|
||||
public string Name { get; }
|
||||
|
||||
public Block(string name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public string getName() {
|
||||
return name;
|
||||
Name = name;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace Collector.Dimension
|
||||
//Private so the singleton can't be instantiated
|
||||
internal BlockMaterials() {}
|
||||
|
||||
public static void LoadContent(ContentManager content){
|
||||
public static void Initialize(ContentManager content){
|
||||
Materials.Add("grass",new Block("grass"));
|
||||
Materials.Add("wood",new Block("wood"));
|
||||
Materials.Add("water",new Block("water"));
|
||||
@@ -27,11 +27,11 @@ namespace Collector.Dimension
|
||||
{
|
||||
Textures.Add(name,content.Load<Texture2D>(name));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void Draw(string name,SpriteBatch _spriteBatch,int x, int y)
|
||||
{
|
||||
_spriteBatch.Draw(Textures[name],new Vector2(x, y),Color.Aqua);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,36 +7,38 @@ using Collector.ThirdPartyCode;
|
||||
namespace Collector.Dimension
|
||||
{
|
||||
public class Chunks: IRestrictions {
|
||||
public static Dictionary<Tuple<int, int, int>, Block> LoadedChunks = new Dictionary<Tuple<int, int, int>, Block>();
|
||||
public static Dictionary<Tuple<int, int, int>, Block> SavedChunks = new Dictionary<Tuple<int, int, int>, Block>();
|
||||
public static OpenSimplexNoise Gen1 = new OpenSimplexNoise(IRestrictions.Seed+ 1);
|
||||
public static OpenSimplexNoise Gen2 = new OpenSimplexNoise(IRestrictions.Seed);
|
||||
public static Dictionary<Tuple<int, int, int>, Block> LoadedChunks { get; } =
|
||||
new Dictionary<Tuple<int, int, int>, Block>();
|
||||
|
||||
private static readonly Dictionary<Tuple<int, int, int>, Block> SavedChunks = new Dictionary<Tuple<int, int, int>, Block>();
|
||||
private static readonly OpenSimplexNoise _gen1 = new OpenSimplexNoise(IRestrictions.Seed+ 1);
|
||||
private static readonly OpenSimplexNoise _gen2 = new OpenSimplexNoise(IRestrictions.Seed);
|
||||
|
||||
public static void CreateStructures() {
|
||||
var i = 10;
|
||||
const int i = 10;
|
||||
SetBlock(3 + i, 2,1,"wall");
|
||||
SetBlock(4 + i, 2,1,"wall");
|
||||
SetBlock(3 + i, 3,1, "roof");
|
||||
SetBlock(4 + i, 3,1,"roof");
|
||||
}
|
||||
|
||||
public static void SetBlock(int x, int y,int z, String name) {
|
||||
public static void SetBlock(int x, int y,int z, string name) {
|
||||
LoadedChunks.Add(new Tuple<int,int,int>(x, y, z), BlockMaterials.Materials[name]);
|
||||
SavedChunks.Add(new Tuple<int,int,int>(x, y, z), BlockMaterials.Materials[name]);
|
||||
}
|
||||
|
||||
public static void PlaceBlock(int x, int y, String name){
|
||||
public static void PlaceBlock(int x, int y, string name){
|
||||
var triple = new Tuple<int, int, int>(x, y, 1);
|
||||
if (!Chunks.LoadedChunks[triple].getName().Equals("air")) return;
|
||||
Chunks.LoadedChunks[triple] = BlockMaterials.Materials[name];
|
||||
Chunks.SavedChunks[triple] = BlockMaterials.Materials[name];
|
||||
if (!LoadedChunks[triple].Name.Equals("air")) return;
|
||||
LoadedChunks[triple] = BlockMaterials.Materials[name];
|
||||
SavedChunks[triple] = BlockMaterials.Materials[name];
|
||||
}
|
||||
|
||||
public static void RemoveBlock(int x, int y){
|
||||
var triple = new Tuple<int, int, int>(x, y, 1);
|
||||
if (Chunks.LoadedChunks[triple].getName().Equals("air")) return;
|
||||
Chunks.LoadedChunks[triple] = BlockMaterials.Materials["air"];
|
||||
Chunks.SavedChunks[triple] = BlockMaterials.Materials["air"];
|
||||
if (LoadedChunks[triple].Name.Equals("air")) return;
|
||||
LoadedChunks[triple] = BlockMaterials.Materials["air"];
|
||||
SavedChunks[triple] = BlockMaterials.Materials["air"];
|
||||
}
|
||||
|
||||
public static void UngenerateChunk(int x, int y) {
|
||||
@@ -70,7 +72,7 @@ namespace Collector.Dimension
|
||||
for (var i = startX; i != endX; i++) {
|
||||
for (var j = startY; j != endY; j++) {
|
||||
var triple = new Tuple<int, int, int>(i, j, 0);
|
||||
if(SavedChunks[triple] != null){
|
||||
if(SavedChunks.ContainsKey(triple)){
|
||||
LoadedChunks.Add(triple,SavedChunks[triple]);
|
||||
}
|
||||
else {
|
||||
@@ -84,8 +86,8 @@ namespace Collector.Dimension
|
||||
for (var i = startX; i != endX; i++){
|
||||
for (var j = startY; j != endY; j++) {
|
||||
var triple = new Tuple<int, int, int>(i, j,1);
|
||||
LoadedChunks.Add(triple, GetBlocks(i,j,1));
|
||||
SavedChunks.Add(triple, GetBlocks(i,j,1));
|
||||
LoadedChunks[triple] = GetBlocks(i,j,1);
|
||||
SavedChunks[triple] = GetBlocks(i,j,1);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -95,11 +97,11 @@ namespace Collector.Dimension
|
||||
}
|
||||
|
||||
private static double Noise1(double nx, double ny) {
|
||||
return Gen1.Evaluate(nx, ny) / 2 + 0.5;
|
||||
return _gen1.Evaluate(nx, ny) / 2 + 0.5;
|
||||
}
|
||||
|
||||
private static double Noise2(double nx, double ny) {
|
||||
return Gen2.Evaluate(nx, ny) / 2 + 0.5;
|
||||
return _gen2.Evaluate(nx, ny) / 2 + 0.5;
|
||||
}
|
||||
|
||||
private static Block GetTerrain(int x, int y) {
|
||||
@@ -174,7 +176,7 @@ namespace Collector.Dimension
|
||||
}
|
||||
|
||||
public static bool IsEmpty(int x, int y){
|
||||
return LoadedChunks[new Tuple<int,int,int>(x * 8, y * 8,0)] == null;
|
||||
return !LoadedChunks.ContainsKey(new Tuple<int,int,int>(x * 8, y * 8,0));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,53 +1,56 @@
|
||||
using Collector;
|
||||
using Collector.Dimension;
|
||||
using System;
|
||||
using Collector.Character;
|
||||
|
||||
public class World {
|
||||
public static void generateWorld(int x, int y) {
|
||||
if (Chunks.IsEmpty(x, y)) {
|
||||
Chunks.GenerateChunk(x, y);
|
||||
namespace Collector.Dimension
|
||||
{
|
||||
public static class World {
|
||||
private static void GenerateWorld(int x, int y) {
|
||||
if (Chunks.IsEmpty(x, y)) {
|
||||
Chunks.GenerateChunk(x, y);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void ungenerateWorld(int x, int y) {
|
||||
if (!Chunks.IsEmpty(x, y)) {
|
||||
Chunks.UngenerateChunk(x, y);
|
||||
private static void UngenerateWorld(int x, int y) {
|
||||
if (!Chunks.IsEmpty(x, y)) {
|
||||
Chunks.UngenerateChunk(x, y);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void loadChunks() {
|
||||
for (var i = -(IRestrictions.RenderDistance); i < IRestrictions.RenderDistance; i++) {
|
||||
for (var j = -(IRestrictions.RenderDistance); j < IRestrictions.RenderDistance; j++) {
|
||||
generateWorld(
|
||||
i + Player.getX() / (IRestrictions.TileSize * IRestrictions.SuperChunkSize * IRestrictions.ChunkSize),
|
||||
j + Player.getY() / (IRestrictions.TileSize * IRestrictions.SuperChunkSize * IRestrictions.ChunkSize)
|
||||
public static void LoadChunks()
|
||||
{
|
||||
for (var i = -(IRestrictions.RenderDistance); i < IRestrictions.RenderDistance; i++) {
|
||||
for (var j = -(IRestrictions.RenderDistance); j < IRestrictions.RenderDistance; j++) {
|
||||
GenerateWorld(
|
||||
i + Player.X / (IRestrictions.TileSize * IRestrictions.SuperChunkSize * IRestrictions.ChunkSize),
|
||||
j + Player.Y / (IRestrictions.TileSize * IRestrictions.SuperChunkSize * IRestrictions.ChunkSize)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void UnloadChunks() {
|
||||
for (var i = -IRestrictions.RenderDistance; i < IRestrictions.RenderDistance+1; i++) {
|
||||
//Down
|
||||
UngenerateWorld(
|
||||
Player.X / (IRestrictions.TileSize * IRestrictions.SuperChunkSize * IRestrictions.ChunkSize)+i,
|
||||
(Player.Y / (IRestrictions.TileSize * IRestrictions.SuperChunkSize * IRestrictions.ChunkSize))+3
|
||||
);
|
||||
//Up
|
||||
UngenerateWorld(
|
||||
Player.X / (IRestrictions.TileSize * IRestrictions.SuperChunkSize * IRestrictions.ChunkSize)+i-1,
|
||||
(Player.Y / (IRestrictions.TileSize * IRestrictions.SuperChunkSize * IRestrictions.ChunkSize))-4
|
||||
);
|
||||
//Right
|
||||
UngenerateWorld(
|
||||
Player.X / (IRestrictions.TileSize * IRestrictions.SuperChunkSize * IRestrictions.ChunkSize)-4,
|
||||
(Player.Y / (IRestrictions.TileSize * IRestrictions.SuperChunkSize * IRestrictions.ChunkSize))+i
|
||||
);
|
||||
//Left
|
||||
UngenerateWorld(
|
||||
Player.X / (IRestrictions.TileSize * IRestrictions.SuperChunkSize * IRestrictions.ChunkSize)+3,
|
||||
(Player.Y / (IRestrictions.TileSize * IRestrictions.SuperChunkSize * IRestrictions.ChunkSize))+i
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void unloadChunks() {
|
||||
for (var i = -IRestrictions.RenderDistance; i < IRestrictions.RenderDistance+1; i++) {
|
||||
//Down
|
||||
ungenerateWorld(
|
||||
Player.getX() / (IRestrictions.TileSize * IRestrictions.SuperChunkSize * IRestrictions.ChunkSize)+i,
|
||||
(Player.getY() / (IRestrictions.TileSize * IRestrictions.SuperChunkSize * IRestrictions.ChunkSize))+3
|
||||
);
|
||||
//Up
|
||||
ungenerateWorld(
|
||||
Player.getX() / (IRestrictions.TileSize * IRestrictions.SuperChunkSize * IRestrictions.ChunkSize)+i-1,
|
||||
(Player.getY() / (IRestrictions.TileSize * IRestrictions.SuperChunkSize * IRestrictions.ChunkSize))-4
|
||||
);
|
||||
//Right
|
||||
ungenerateWorld(
|
||||
Player.getX() / (IRestrictions.TileSize * IRestrictions.SuperChunkSize * IRestrictions.ChunkSize)-4,
|
||||
(Player.getY() / (IRestrictions.TileSize * IRestrictions.SuperChunkSize * IRestrictions.ChunkSize))+i
|
||||
);
|
||||
//Left
|
||||
ungenerateWorld(
|
||||
Player.getX() / (IRestrictions.TileSize * IRestrictions.SuperChunkSize * IRestrictions.ChunkSize)+3,
|
||||
(Player.getY() / (IRestrictions.TileSize * IRestrictions.SuperChunkSize * IRestrictions.ChunkSize))+i
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,51 +1,66 @@
|
||||
using System.Linq;
|
||||
using Collector.Character;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Content;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using MonoGame.Extended;
|
||||
|
||||
namespace Collector.Dimension
|
||||
{
|
||||
public class WorldRenderer : IRestrictions {
|
||||
//private Mouse mouse;
|
||||
//private InputController inputController;
|
||||
//private Player _player;
|
||||
public class WorldRenderer : IRestrictions
|
||||
{
|
||||
private Mouse _mouse;
|
||||
private InputController _inputController;
|
||||
private Player _player;
|
||||
private SpriteBatch _spriteBatch;
|
||||
private Main _main;
|
||||
private OrthographicCamera _orthographicCamera;
|
||||
|
||||
/*
|
||||
public WorldRenderer(InputController inputController, Mouse mouse, Player player) {
|
||||
this.inputController = inputController;
|
||||
this.mouse = mouse;
|
||||
this.player = player;
|
||||
}
|
||||
*/
|
||||
public void DrawWorld(SpriteBatch batch, int layer)
|
||||
public WorldRenderer(Mouse mouse, InputController inputController, Player player, SpriteBatch spriteBatch, Main main, OrthographicCamera orthographicCamera)
|
||||
{
|
||||
/*
|
||||
foreach (var chunkpair in Chunks.LoadedChunks.Keys.Where(chunkpair => chunkpair.Item3 == layer))
|
||||
_mouse = mouse;
|
||||
_inputController = inputController;
|
||||
_player = player;
|
||||
_spriteBatch = spriteBatch;
|
||||
_main = main;
|
||||
_orthographicCamera = orthographicCamera;
|
||||
}
|
||||
|
||||
private static void DrawWorld(SpriteBatch batch, int layer)
|
||||
{
|
||||
batch.draw(
|
||||
//BlockMaterials.Textures[Chunks.LoadedChunks[chunkpair].getName()],
|
||||
chunkpair.Item1 << IRestrictions.TileShift,
|
||||
chunkpair.Item2 << IRestrictions.TileShift
|
||||
);
|
||||
foreach (var chunkpair in Chunks.LoadedChunks.Keys.Where(chunkpair => chunkpair.Item3 == layer))
|
||||
{
|
||||
batch.Draw(
|
||||
BlockMaterials.Textures[Chunks.LoadedChunks[chunkpair].Name],
|
||||
new Rectangle(
|
||||
chunkpair.Item1 << IRestrictions.TileShift,
|
||||
chunkpair.Item2 << IRestrictions.TileShift,
|
||||
IRestrictions.TileSize, IRestrictions.TileSize
|
||||
),
|
||||
Color.White
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
private void mouseCrosshair(SpriteBatch batch)
|
||||
{
|
||||
Vector3 mousePos = new Vector3(Gdx.input.getX(), Gdx.input.getY(), 0);
|
||||
Main.cam.unproject(mousePos);
|
||||
int x = mouse.getSelectedX(mousePos);
|
||||
int y = mouse.getSelectedY(mousePos);
|
||||
batch.draw(mouse.getCrosshair(), x, y);
|
||||
}
|
||||
*/
|
||||
|
||||
public void Draw()
|
||||
{
|
||||
//Higher means draws in a lower layer
|
||||
DrawWorld(_spriteBatch, 0);
|
||||
_inputController.Draw();
|
||||
DrawWorld(_spriteBatch, 1);
|
||||
//mouseCrosshair(batch);
|
||||
_inputController.PlayerInput(_main,_spriteBatch);
|
||||
}
|
||||
|
||||
/*
|
||||
private void mouseCrosshair(SpriteBatch batch) {
|
||||
Vector3 mousePos = new Vector3(Gdx.input.getX(), Gdx.input.getY(), 0);
|
||||
Main.cam.unproject(mousePos);
|
||||
int x = mouse.getSelectedX(mousePos);
|
||||
int y = mouse.getSelectedY(mousePos);
|
||||
batch.draw(mouse.getCrosshair(), x, y);
|
||||
}
|
||||
|
||||
public void render(SpriteBatch batch, float timeSinceLastUpdate) {
|
||||
//Higher means draws in a lower layer
|
||||
drawWorld(batch,0);
|
||||
batch.draw(player.getAnimation().getKeyFrame(timeSinceLastUpdate, true), Player.x, Player.y,TILE_SIZE,TILE_SIZE);
|
||||
drawWorld(batch,1);
|
||||
mouseCrosshair(batch);
|
||||
inputController.handleInput();
|
||||
batch.setProjectionMatrix(Main.cam.combined);
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user