Made lucas the Main character and also added collision
This commit is contained in:
17
Collector/src/Character/Collision.cs
Normal file
17
Collector/src/Character/Collision.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
|
||||
using Humper.Base;
|
||||
|
||||
namespace Collector.Character
|
||||
{
|
||||
public class Collision
|
||||
{
|
||||
private readonly int _tileWidth;
|
||||
public RectangleF Rectangle { get; private set; }
|
||||
|
||||
public Collision(int x, int y,int tileWidth)
|
||||
{
|
||||
_tileWidth = tileWidth;
|
||||
Rectangle = new RectangleF(x,y,tileWidth,tileWidth);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,20 +10,18 @@ namespace Collector.Character
|
||||
{
|
||||
public class InputController : IRestrictions
|
||||
{
|
||||
private readonly PlayerMouse _playerMouse;
|
||||
private readonly OrthographicCamera _cam;
|
||||
private readonly Dictionary<string, Rectangle[]> _animations;
|
||||
private readonly Texture2D _texture;
|
||||
private readonly SpriteBatch _spriteBatch;
|
||||
private string Input { get; set; }
|
||||
private int _frameNumber;
|
||||
private int _timeSinceLastFrame;
|
||||
private float _timeSinceLastFrame;
|
||||
|
||||
|
||||
public InputController(PlayerMouse playerMouse, OrthographicCamera cam, SpriteBatch spriteBatch, ContentManager contentManager)
|
||||
public InputController(OrthographicCamera cam, SpriteBatch spriteBatch, ContentManager contentManager)
|
||||
{
|
||||
Input = "Down";
|
||||
_playerMouse = playerMouse;
|
||||
_cam = cam;
|
||||
_spriteBatch = spriteBatch;
|
||||
_frameNumber = 0;
|
||||
@@ -31,128 +29,128 @@ namespace Collector.Character
|
||||
const int tileSize = 32;
|
||||
_animations = new Dictionary<string, Rectangle[]>
|
||||
{
|
||||
["Idle"] = new[]
|
||||
{
|
||||
new Rectangle((0 + 4)*tileSize, 0, tileSize, tileSize*2),
|
||||
new Rectangle((0 + 4)*tileSize, 0, tileSize, tileSize*2),
|
||||
new Rectangle((0 + 4)*tileSize, 0, tileSize, tileSize*2),
|
||||
new Rectangle((0 + 4)*tileSize, 0, tileSize, tileSize*2),
|
||||
},
|
||||
["Up"] = new[]
|
||||
{
|
||||
new Rectangle(0, 0, tileSize, tileSize),
|
||||
new Rectangle(1, 0, tileSize, tileSize),
|
||||
new Rectangle(2, 0, tileSize, tileSize),
|
||||
new Rectangle(3, 0, tileSize, tileSize)
|
||||
new Rectangle(0*tileSize, 0, tileSize, tileSize*2),
|
||||
new Rectangle(1*tileSize, 0, tileSize, tileSize*2),
|
||||
new Rectangle(2*tileSize, 0, tileSize, tileSize*2),
|
||||
new Rectangle(3*tileSize, 0, tileSize, tileSize*2)
|
||||
},
|
||||
["Right"] = new[]
|
||||
{
|
||||
new Rectangle(0 + 4, 1, tileSize, tileSize),
|
||||
new Rectangle(1 + 4, 1, tileSize, tileSize),
|
||||
new Rectangle(2 + 4, 1, tileSize, tileSize),
|
||||
new Rectangle(3 + 4, 1, tileSize, tileSize)
|
||||
new Rectangle((0 + 4)*tileSize, 2*tileSize, tileSize, tileSize*2),
|
||||
new Rectangle((1 + 4)*tileSize, 2*tileSize, tileSize, tileSize*2),
|
||||
new Rectangle((2 + 4)*tileSize, 2*tileSize, tileSize, tileSize*2),
|
||||
new Rectangle((3 + 4)*tileSize, 2*tileSize, tileSize, tileSize*2)
|
||||
},
|
||||
["UpRight"] = new[]
|
||||
{
|
||||
new Rectangle(0 + 4, 2, tileSize, tileSize),
|
||||
new Rectangle(1 + 4, 2, tileSize, tileSize),
|
||||
new Rectangle(2 + 4, 2, tileSize, tileSize),
|
||||
new Rectangle(3 + 4, 2, tileSize, tileSize)
|
||||
new Rectangle((0 + 4)*tileSize, 4*tileSize, tileSize, tileSize*2),
|
||||
new Rectangle((1 + 4)*tileSize, 4*tileSize, tileSize, tileSize*2),
|
||||
new Rectangle((2 + 4)*tileSize, 4*tileSize, tileSize, tileSize*2),
|
||||
new Rectangle((3 + 4)*tileSize, 4*tileSize, tileSize, tileSize*2)
|
||||
},
|
||||
["DownRight"] = new[]
|
||||
{
|
||||
new Rectangle(0 + 4, 3, tileSize, tileSize),
|
||||
new Rectangle(1 + 4, 3, tileSize, tileSize),
|
||||
new Rectangle(2 + 4, 3, tileSize, tileSize),
|
||||
new Rectangle(3 + 4, 3, tileSize, tileSize)
|
||||
new Rectangle((0 + 4)*tileSize, 6*tileSize, tileSize, tileSize*2),
|
||||
new Rectangle((1 + 4)*tileSize, 6*tileSize, tileSize, tileSize*2),
|
||||
new Rectangle((2 + 4)*tileSize, 6*tileSize, tileSize, tileSize*2),
|
||||
new Rectangle((3 + 4)*tileSize, 6*tileSize, tileSize, tileSize*2)
|
||||
},
|
||||
["Left"] = new[]
|
||||
{
|
||||
new Rectangle(0, 1, tileSize, tileSize),
|
||||
new Rectangle(1, 1, tileSize, tileSize),
|
||||
new Rectangle(2, 1, tileSize, tileSize),
|
||||
new Rectangle(3, 1, tileSize, tileSize)
|
||||
new Rectangle(0*tileSize, 2*tileSize, tileSize, tileSize*2),
|
||||
new Rectangle(1*tileSize, 2*tileSize, tileSize, tileSize*2),
|
||||
new Rectangle(2*tileSize, 2*tileSize, tileSize, tileSize*2),
|
||||
new Rectangle(3*tileSize, 2*tileSize, tileSize, tileSize*2)
|
||||
},
|
||||
["UpLeft"] = new[]
|
||||
{
|
||||
new Rectangle(0, 2, tileSize, tileSize),
|
||||
new Rectangle(1, 2, tileSize, tileSize),
|
||||
new Rectangle(2, 2, tileSize, tileSize),
|
||||
new Rectangle(3, 2, tileSize, tileSize)
|
||||
new Rectangle(0*tileSize, 4*tileSize, tileSize, tileSize*2),
|
||||
new Rectangle(1*tileSize, 4*tileSize, tileSize, tileSize*2),
|
||||
new Rectangle(2*tileSize, 4*tileSize, tileSize, tileSize*2),
|
||||
new Rectangle(3*tileSize, 4*tileSize, tileSize, tileSize*2)
|
||||
},
|
||||
["DownLeft"] = new[]
|
||||
{
|
||||
new Rectangle(0, 1, tileSize, tileSize),
|
||||
new Rectangle(1, 1, tileSize, tileSize),
|
||||
new Rectangle(2, 1, tileSize, tileSize),
|
||||
new Rectangle(3, 1, tileSize, tileSize)
|
||||
new Rectangle(0*tileSize, 6*tileSize, tileSize, tileSize*2),
|
||||
new Rectangle(1*tileSize, 6*tileSize, tileSize, tileSize*2),
|
||||
new Rectangle(2*tileSize, 6*tileSize, tileSize, tileSize*2),
|
||||
new Rectangle(3*tileSize, 6*tileSize, tileSize, tileSize*2)
|
||||
},
|
||||
["Down"] = new[]
|
||||
{
|
||||
new Rectangle(0 + 4, 0, tileSize, tileSize),
|
||||
new Rectangle(1 + 4, 0, tileSize, tileSize),
|
||||
new Rectangle(2 + 4, 0, tileSize, tileSize),
|
||||
new Rectangle(3 + 4, 0, tileSize, tileSize)
|
||||
new Rectangle((0 + 4)*tileSize, 0, tileSize, tileSize*2),
|
||||
new Rectangle((1 + 4)*tileSize, 0, tileSize, tileSize*2),
|
||||
new Rectangle((2 + 4)*tileSize, 0, tileSize, tileSize*2),
|
||||
new Rectangle((3 + 4)*tileSize, 0, tileSize, tileSize*2)
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
public void PlayerInput(Main main, PlayerMouse playerMouse, GameTime gameTime)
|
||||
public void PlayerInput(Main main, GameTime gameTime)
|
||||
{
|
||||
const int movementSpeed = IRestrictions.MovementSpeed;
|
||||
const float movementSpeed = IRestrictions.MovementSpeed;
|
||||
var keyboardState = Keyboard.GetState();
|
||||
var mouseState = Mouse.GetState();
|
||||
if (keyboardState.IsKeyDown(Keys.Escape))
|
||||
{
|
||||
Quit(main);
|
||||
}
|
||||
if (keyboardState.IsKeyUp(Keys.W) && keyboardState.IsKeyUp(Keys.A) && keyboardState.IsKeyUp(Keys.S) && keyboardState.IsKeyUp(Keys.D))
|
||||
{
|
||||
Input = Input.Contains("Right") ? "DownRight" : "DownLeft";
|
||||
|
||||
_frameNumber = 0;
|
||||
_playerMouse.Draw();
|
||||
if (keyboardState.IsKeyUp(Keys.W) && keyboardState.IsKeyUp(Keys.A) && keyboardState.IsKeyUp(Keys.S) &&
|
||||
keyboardState.IsKeyUp(Keys.D))
|
||||
{
|
||||
Input = "Idle";
|
||||
}
|
||||
UpdateAnimationFrame(gameTime);
|
||||
const float diagonalMovement = 0.707f;
|
||||
if (keyboardState.IsKeyDown(Keys.W) && keyboardState.IsKeyDown(Keys.D))
|
||||
{
|
||||
UpdateAnimationFrame(gameTime);
|
||||
Input = "UpRight";
|
||||
Player.Move(_cam,movementSpeed,-movementSpeed);
|
||||
Player.Move(_cam,movementSpeed*diagonalMovement,-movementSpeed*diagonalMovement);
|
||||
}
|
||||
else if (keyboardState.IsKeyDown(Keys.W) && keyboardState.IsKeyDown(Keys.A))
|
||||
{
|
||||
UpdateAnimationFrame(gameTime);
|
||||
Player.Move(_cam,-movementSpeed*diagonalMovement,-movementSpeed*diagonalMovement);
|
||||
Input = "UpLeft";
|
||||
Player.Move(_cam,-movementSpeed,-movementSpeed);
|
||||
}
|
||||
else if (keyboardState.IsKeyDown(Keys.S) && keyboardState.IsKeyDown(Keys.D))
|
||||
{
|
||||
UpdateAnimationFrame(gameTime);
|
||||
Input = "DownRight";
|
||||
Player.Move(_cam,movementSpeed,movementSpeed);
|
||||
Player.Move(_cam,movementSpeed*diagonalMovement,movementSpeed*diagonalMovement);
|
||||
}
|
||||
else if (keyboardState.IsKeyDown(Keys.S) && keyboardState.IsKeyDown(Keys.A))
|
||||
{
|
||||
UpdateAnimationFrame(gameTime);
|
||||
Input = "DownLeft";
|
||||
Player.Move(_cam,-movementSpeed,movementSpeed);
|
||||
Player.Move(_cam,-movementSpeed*diagonalMovement,movementSpeed*diagonalMovement);
|
||||
}
|
||||
else if (keyboardState.IsKeyDown(Keys.W))
|
||||
{
|
||||
UpdateAnimationFrame(gameTime);
|
||||
Input = "Up";
|
||||
Player.Move(_cam,0,-movementSpeed);
|
||||
}
|
||||
else if (keyboardState.IsKeyDown(Keys.A))
|
||||
{
|
||||
UpdateAnimationFrame(gameTime);
|
||||
Player.Move(_cam,-movementSpeed,0);
|
||||
Input = "Left";
|
||||
Player.Move(_cam,-movementSpeed,0);
|
||||
}
|
||||
else if (keyboardState.IsKeyDown(Keys.S))
|
||||
{
|
||||
UpdateAnimationFrame(gameTime);
|
||||
Player.Move(_cam,0,movementSpeed);
|
||||
Input = "Down";
|
||||
Player.Move(_cam,0,movementSpeed);
|
||||
}
|
||||
else if (keyboardState.IsKeyDown(Keys.D))
|
||||
{
|
||||
UpdateAnimationFrame(gameTime);
|
||||
Player.Move(_cam,movementSpeed,0);
|
||||
Input = "Right";
|
||||
Player.Move(_cam,movementSpeed,0);
|
||||
}
|
||||
if (keyboardState.IsKeyDown(Keys.Q))
|
||||
{
|
||||
@@ -162,7 +160,6 @@ namespace Collector.Character
|
||||
{
|
||||
_cam.ZoomOut(1f);
|
||||
}
|
||||
|
||||
if (mouseState.LeftButton == ButtonState.Pressed)
|
||||
{
|
||||
Chunks.RemoveBlock(PlayerMouse.GetSelectedX(),PlayerMouse.GetSelectedY());
|
||||
@@ -175,14 +172,11 @@ namespace Collector.Character
|
||||
|
||||
private void UpdateAnimationFrame(GameTime gameTime)
|
||||
{
|
||||
_timeSinceLastFrame += gameTime.ElapsedGameTime.Milliseconds;
|
||||
if (_timeSinceLastFrame <= 99) return;
|
||||
_timeSinceLastFrame += gameTime.GetElapsedSeconds();
|
||||
if (_timeSinceLastFrame <= IRestrictions.AnimationDuration) return;
|
||||
_frameNumber++;
|
||||
_timeSinceLastFrame = 0;
|
||||
if (_frameNumber > 3)
|
||||
{
|
||||
_frameNumber = 0;
|
||||
}
|
||||
if (_frameNumber > 3) _frameNumber = 0;
|
||||
}
|
||||
|
||||
private static void Quit(Game main)
|
||||
@@ -193,11 +187,14 @@ namespace Collector.Character
|
||||
public void Draw()
|
||||
{
|
||||
_spriteBatch.Draw(
|
||||
_texture
|
||||
,Player.PlayerBounds
|
||||
,_animations[Input][_frameNumber]
|
||||
,Color.White
|
||||
);
|
||||
_texture,
|
||||
new Vector2(Player.X,Player.Y),
|
||||
_animations[Input][_frameNumber],
|
||||
Color.White, 0f,
|
||||
Vector2.One,
|
||||
1/32f,
|
||||
SpriteEffects.None,
|
||||
1f);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,35 +1,44 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Collector.Dimension;
|
||||
using Humper;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Media;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using MonoGame.Extended;
|
||||
using MonoGame.Extended.Collections;
|
||||
using Collision = Collector.Dimension.Collision;
|
||||
using RectangleF = Humper.Base.RectangleF;
|
||||
using Vector2 = Microsoft.Xna.Framework.Vector2;
|
||||
|
||||
|
||||
namespace Collector.Character
|
||||
{
|
||||
public class Player : IRestrictions
|
||||
{
|
||||
public static int X { get; private set; }
|
||||
public static int Y { get; private set; }
|
||||
private static Dictionary<string, Rectangle> Animation { get; set; }
|
||||
public static Rectangle PlayerBounds;
|
||||
public static float X { get; private set; }
|
||||
public static float Y { get; private set; }
|
||||
|
||||
public static RectangleF PlayerBounds;
|
||||
|
||||
public Player(int x, int y)
|
||||
{
|
||||
PlayerBounds = new Rectangle(X,Y,IRestrictions.TileSize,IRestrictions.TileSize);
|
||||
X = x;
|
||||
Y = y;
|
||||
PlayerBounds = new RectangleF(x,y, IRestrictions.TileSize*0.5f, IRestrictions.TileSize*0.35f);
|
||||
}
|
||||
|
||||
public static void Move(OrthographicCamera cam, int x, int y)
|
||||
public static void Move(OrthographicCamera cam, float x, float y)
|
||||
{
|
||||
X += x;
|
||||
Y += y;
|
||||
cam.Move(new Vector2(x+IRestrictions.TileSize/2, y+IRestrictions.TileSize/2));
|
||||
PlayerBounds.Location = new Point(X,Y);
|
||||
PlayerBounds.X = X+0.2f;
|
||||
PlayerBounds.Y = Y+1.5f;
|
||||
|
||||
cam.Move(new Vector2(x, y));
|
||||
if (!Chunks.loadedCollisions.Values.Any(collisionsValue => collisionsValue.Rectangle.Intersects(PlayerBounds))) return;
|
||||
|
||||
X -= x;
|
||||
Y -= y;
|
||||
cam.Move(new Vector2(-x, -y));
|
||||
PlayerBounds.X -= X;
|
||||
PlayerBounds.Y -= Y;
|
||||
}
|
||||
}
|
||||
}
|
||||
7
Collector/src/Dimension/Autotiling.cs
Normal file
7
Collector/src/Dimension/Autotiling.cs
Normal file
@@ -0,0 +1,7 @@
|
||||
namespace Collector.Character
|
||||
{
|
||||
public class Autotiling
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,8 @@ using System.Collections.Generic;
|
||||
using Collector.ThirdPartyCode;
|
||||
using Humper;
|
||||
using Microsoft.Xna.Framework;
|
||||
using MonoGame.Extended;
|
||||
using Collision = Collector.Character.Collision;
|
||||
|
||||
namespace Collector.Dimension
|
||||
{
|
||||
@@ -13,7 +15,8 @@ namespace Collector.Dimension
|
||||
public static Dictionary<Tuple<int, int, int>, Blocks> LoadedChunks { get; } = new Dictionary<Tuple<int, int, int>, Blocks>();
|
||||
private static readonly Dictionary<Tuple<int, int, int>, Blocks> SavedChunks = new Dictionary<Tuple<int, int, int>, Blocks>();
|
||||
private static readonly Dictionary<Tuple<int, int>, Collision> savedCollisions = new Dictionary<Tuple<int, int>, Collision>();
|
||||
public static readonly Dictionary<Tuple<int,int>, Collision> loadedCollisions = new Dictionary<Tuple<int, int>, Collision>();
|
||||
public static readonly Dictionary<Tuple<int, int>, Collision> loadedCollisions = new Dictionary<Tuple<int, int>, Collision>();
|
||||
public static readonly List<Blocks> Impassable = new List<Blocks>();
|
||||
|
||||
|
||||
private static readonly OpenSimplexNoise Gen1 = new OpenSimplexNoise(IRestrictions.Seed+ 1);
|
||||
@@ -32,8 +35,8 @@ namespace Collector.Dimension
|
||||
var tuple = new Tuple<int, int, int>(x, y, z);
|
||||
var pair = new Tuple<int, int>(x, y);
|
||||
|
||||
loadedCollisions[pair] = new Collision(x,y,IRestrictions.TileSize,false);
|
||||
savedCollisions[pair] = new Collision(x,y,IRestrictions.TileSize,false);
|
||||
loadedCollisions[pair] = new Collision(x,y,IRestrictions.TileSize);
|
||||
savedCollisions[pair] = new Collision(x,y,IRestrictions.TileSize);
|
||||
LoadedChunks[tuple] = name;
|
||||
SavedChunks[tuple] = name;
|
||||
}
|
||||
@@ -55,16 +58,16 @@ namespace Collector.Dimension
|
||||
if (!LoadedChunks.ContainsKey(tuple)) return;
|
||||
if (LoadedChunks[tuple].Equals(Blocks.BlockAir)) return;
|
||||
|
||||
loadedCollisions[pair] = null;
|
||||
savedCollisions[pair] = null;
|
||||
loadedCollisions.Remove(pair);
|
||||
savedCollisions.Remove(pair);
|
||||
|
||||
LoadedChunks[tuple] = Blocks.BlockAir;
|
||||
SavedChunks[tuple] = Blocks.BlockAir;
|
||||
}
|
||||
|
||||
public static void UngenerateChunk(int x, int y) {
|
||||
var startX = x << IRestrictions.ChunkShift;
|
||||
var startY = y << IRestrictions.ChunkShift;
|
||||
public static void UngenerateChunk(float x, float y) {
|
||||
var startX = (int)x << IRestrictions.ChunkShift;
|
||||
var startY = (int)y << IRestrictions.ChunkShift;
|
||||
var endX = startX + IRestrictions.ChunkSize;
|
||||
var endY = startY + IRestrictions.ChunkSize;
|
||||
|
||||
@@ -83,9 +86,9 @@ namespace Collector.Dimension
|
||||
}
|
||||
}
|
||||
|
||||
public static void GenerateChunk(int x, int y) {
|
||||
var startX = x << IRestrictions.ChunkShift;
|
||||
var startY = y << IRestrictions.ChunkShift;
|
||||
public static void GenerateChunk(float x, float y) {
|
||||
var startX = (int)x << IRestrictions.ChunkShift;
|
||||
var startY = (int)y << IRestrictions.ChunkShift;
|
||||
var endX = startX + IRestrictions.ChunkSize;
|
||||
var endY = startY + IRestrictions.ChunkSize;
|
||||
|
||||
@@ -97,8 +100,16 @@ namespace Collector.Dimension
|
||||
LoadedChunks.Add(triple,SavedChunks[triple]);
|
||||
}
|
||||
else {
|
||||
LoadedChunks.Add(triple, GetTerrain(i, j));
|
||||
SavedChunks.Add(triple, GetTerrain(i,j));
|
||||
var terrain = GetTerrain(i, j);
|
||||
var pair = new Tuple<int, int>(i, j);
|
||||
if (Impassable.Contains(terrain))
|
||||
{
|
||||
loadedCollisions[pair] = new Collision(i,j,IRestrictions.TileSize);
|
||||
savedCollisions[pair] = new Collision(i,j,IRestrictions.TileSize);
|
||||
}
|
||||
|
||||
LoadedChunks.Add(triple, terrain);
|
||||
SavedChunks.Add(triple, terrain);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -147,7 +158,7 @@ namespace Collector.Dimension
|
||||
|
||||
return GetBiomeBlock(moisture, elevation);
|
||||
}
|
||||
|
||||
|
||||
private static Blocks GetBiomeBlock(double moisture, double elevation) {
|
||||
var biome = GetBiome(moisture, elevation);
|
||||
if (biome.Equals("Tundra")) return Blocks.BlockSnow;
|
||||
@@ -196,8 +207,8 @@ namespace Collector.Dimension
|
||||
return moisture < 0.66 ? "TropicalSeasonalForest" : "TropicalRainForest";
|
||||
}
|
||||
|
||||
public static bool IsEmpty(int x, int y){
|
||||
return !LoadedChunks.ContainsKey(new Tuple<int,int,int>(x * 8, y * 8,0));
|
||||
public static bool IsEmpty(float x, float y){
|
||||
return !LoadedChunks.ContainsKey(new Tuple<int,int,int>((int)x * 8, (int)y * 8,0));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
using Microsoft.Xna.Framework;
|
||||
|
||||
namespace Collector.Dimension
|
||||
{
|
||||
public class Collision
|
||||
{
|
||||
private readonly int _tileWidth;
|
||||
private bool _entity;
|
||||
public Rectangle Rectangle { get; private set; }
|
||||
|
||||
public Collision(int x, int y,int tileWidth, bool entity)
|
||||
{
|
||||
_entity = entity;
|
||||
_tileWidth = tileWidth;
|
||||
Rectangle = new Rectangle(x,y,tileWidth,tileWidth);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,14 +4,14 @@ using Collector.Character;
|
||||
namespace Collector.Dimension
|
||||
{
|
||||
public static class World {
|
||||
private static void GenerateWorld(int x, int y)
|
||||
private static void GenerateWorld(float x, float y)
|
||||
{
|
||||
if (Chunks.IsEmpty(x, y)) {
|
||||
Chunks.GenerateChunk(x, y);
|
||||
}
|
||||
}
|
||||
|
||||
private static void UngenerateWorld(int x, int y) {
|
||||
private static void UngenerateWorld(float x, float y) {
|
||||
if (!Chunks.IsEmpty(x, y)) {
|
||||
Chunks.UngenerateChunk(x, y);
|
||||
}
|
||||
@@ -34,22 +34,22 @@ namespace Collector.Dimension
|
||||
//Down
|
||||
UngenerateWorld(
|
||||
Player.X / (IRestrictions.SuperChunkSize * IRestrictions.ChunkSize)+i,
|
||||
(Player.Y / (IRestrictions.SuperChunkSize * IRestrictions.ChunkSize))+IRestrictions.RenderDistance
|
||||
Player.Y / (IRestrictions.SuperChunkSize * IRestrictions.ChunkSize)+IRestrictions.RenderDistance
|
||||
);
|
||||
//Up
|
||||
UngenerateWorld(
|
||||
Player.X / (IRestrictions.SuperChunkSize * IRestrictions.ChunkSize)+i,
|
||||
(Player.Y / (IRestrictions.SuperChunkSize * IRestrictions.ChunkSize))-IRestrictions.RenderDistance
|
||||
Player.Y / (IRestrictions.SuperChunkSize * IRestrictions.ChunkSize)-IRestrictions.RenderDistance
|
||||
);
|
||||
//Right
|
||||
UngenerateWorld(
|
||||
Player.X / (IRestrictions.SuperChunkSize * IRestrictions.ChunkSize)-IRestrictions.RenderDistance,
|
||||
(Player.Y / (IRestrictions.SuperChunkSize * IRestrictions.ChunkSize))+i
|
||||
Player.Y / (IRestrictions.SuperChunkSize * IRestrictions.ChunkSize)+i
|
||||
);
|
||||
//Left
|
||||
UngenerateWorld(
|
||||
Player.X / (IRestrictions.SuperChunkSize * IRestrictions.ChunkSize)+IRestrictions.RenderDistance,
|
||||
(Player.Y / (IRestrictions.SuperChunkSize * IRestrictions.ChunkSize))+i
|
||||
Player.Y / (IRestrictions.SuperChunkSize * IRestrictions.ChunkSize)+i
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,9 @@ namespace Collector.Dimension
|
||||
_inputController = inputController;
|
||||
_spriteBatch = spriteBatch;
|
||||
_main = main;
|
||||
Chunks.Impassable.Add(Blocks.BlockWater);
|
||||
Chunks.Impassable.Add(Blocks.BlockRoof);
|
||||
Chunks.Impassable.Add(Blocks.BlockWall);
|
||||
}
|
||||
|
||||
private static void DrawWorld(SpriteBatch batch, int layer)
|
||||
@@ -40,10 +43,11 @@ namespace Collector.Dimension
|
||||
{
|
||||
//Higher means draws in a lower layer
|
||||
DrawWorld(_spriteBatch,0);
|
||||
_playerMouse.Draw();
|
||||
DrawWorld(_spriteBatch,1);
|
||||
_inputController.Draw();
|
||||
_inputController.PlayerInput(_main,_playerMouse,gameTime);
|
||||
DrawWorld(_spriteBatch,2);
|
||||
_inputController.PlayerInput(_main,gameTime);
|
||||
//DrawWorld(_spriteBatch,2);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user