Going to start using Wang tiles
This commit is contained in:
BIN
Collector/Content/31-8x.png
Normal file
BIN
Collector/Content/31-8x.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 260 B |
Binary file not shown.
|
Before Width: | Height: | Size: 2.4 KiB After Width: | Height: | Size: 445 B |
BIN
Collector/Content/BlockGrassBorder.png
Normal file
BIN
Collector/Content/BlockGrassBorder.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 186 B |
BIN
Collector/Content/Border.png
Normal file
BIN
Collector/Content/Border.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 96 B |
BIN
Collector/Content/Palette.aseprite
Normal file
BIN
Collector/Content/Palette.aseprite
Normal file
Binary file not shown.
BIN
Collector/Content/Wang/Grass.png
Normal file
BIN
Collector/Content/Wang/Grass.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 5.1 KiB |
BIN
Collector/Content/bkd32.ase
Normal file
BIN
Collector/Content/bkd32.ase
Normal file
Binary file not shown.
@@ -25,7 +25,7 @@ namespace Collector
|
||||
private int _virtualHeight;
|
||||
private readonly Desktop _desktop;
|
||||
private Gui _gui;
|
||||
private Chunks _chunks;
|
||||
private World _world;
|
||||
private WorldRenderer WorldRenderer { get; set; }
|
||||
public static Dictionary<Blocks, Texture2D> Materials { get; } = new Dictionary<Blocks, Texture2D>();
|
||||
|
||||
@@ -43,7 +43,6 @@ namespace Collector
|
||||
|
||||
protected override void Initialize()
|
||||
{
|
||||
// TODO: Add your initialization logic here
|
||||
_gui = new Gui(_desktop);
|
||||
|
||||
base.Initialize();
|
||||
@@ -57,16 +56,16 @@ namespace Collector
|
||||
_virtualHeight = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height;
|
||||
|
||||
var viewportAdapter = new BoxingViewportAdapter(Window, GraphicsDevice, _virtualWidth, _virtualHeight);
|
||||
_chunks = new Chunks();
|
||||
Player1 = new Player(0, 0, _chunks);
|
||||
_world = new World();
|
||||
Player1 = new Player(0, 0, _world);
|
||||
_cam = new OrthographicCamera(viewportAdapter);
|
||||
_cam.LookAt(new Vector2(Player.X, Player.Y));
|
||||
_cam.Zoom = IRestrictions.Zoom;
|
||||
|
||||
_spriteBatch = new SpriteBatch(GraphicsDevice);
|
||||
_playerMouse = new PlayerMouse(Content, _spriteBatch, _cam);
|
||||
_inputController = new InputController(_cam, _spriteBatch, Content, this,_chunks,Player1);
|
||||
WorldRenderer = new WorldRenderer(_playerMouse, _inputController, _spriteBatch, this,_chunks);
|
||||
_inputController = new InputController(_cam, _spriteBatch, Content, this,_world,Player1,_playerMouse);
|
||||
WorldRenderer = new WorldRenderer(_playerMouse, _inputController, _spriteBatch, this,_world);
|
||||
}
|
||||
|
||||
protected override void LoadContent()
|
||||
@@ -74,17 +73,16 @@ namespace Collector
|
||||
base.LoadContent();
|
||||
MyraEnvironment.Game = this;
|
||||
|
||||
_gui.LoadGUI();
|
||||
_gui.LoadGui();
|
||||
}
|
||||
|
||||
|
||||
protected override void Update(GameTime gameTime)
|
||||
{
|
||||
// TODO: Add your update logic here/*
|
||||
base.Update(gameTime);
|
||||
_chunks.LoadChunks();
|
||||
_chunks.UnloadChunks();
|
||||
_gui.Update();
|
||||
_world.LoadChunks();
|
||||
_world.UnloadChunks();
|
||||
Gui.Update();
|
||||
}
|
||||
|
||||
public void Quit()
|
||||
@@ -94,7 +92,6 @@ namespace Collector
|
||||
|
||||
protected override void Draw(GameTime gameTime)
|
||||
{
|
||||
// TODO: Add your drawing code here
|
||||
var transformMatrix = _cam.GetViewMatrix();
|
||||
base.Draw(gameTime);
|
||||
GraphicsDevice.Clear(Color.CornflowerBlue);
|
||||
|
||||
@@ -18,19 +18,20 @@ namespace Collector.Character
|
||||
private int _frameNumber;
|
||||
private float _timeSinceLastFrame;
|
||||
private readonly Main _main;
|
||||
private readonly Chunks _chunks;
|
||||
private readonly World _world;
|
||||
private readonly Player _player;
|
||||
private readonly PlayerMouse _playerMouse;
|
||||
|
||||
|
||||
|
||||
public InputController(OrthographicCamera cam, SpriteBatch spriteBatch, ContentManager contentManager, Main main, Chunks chunks, Player player)
|
||||
public InputController(OrthographicCamera cam, SpriteBatch spriteBatch, ContentManager contentManager, Main main, World world, Player player, PlayerMouse playerMouse)
|
||||
{
|
||||
Input = "Down";
|
||||
_cam = cam;
|
||||
_spriteBatch = spriteBatch;
|
||||
_main = main;
|
||||
_chunks = chunks;
|
||||
_world = world;
|
||||
_player = player;
|
||||
_playerMouse = playerMouse;
|
||||
_frameNumber = 0;
|
||||
_texture = contentManager.Load<Texture2D>("man");
|
||||
const int tileSize = 32;
|
||||
@@ -169,7 +170,7 @@ namespace Collector.Character
|
||||
}
|
||||
if (mouseState.LeftButton == ButtonState.Pressed)
|
||||
{
|
||||
_chunks.RemoveBlock(PlayerMouse.GetSelectedX(),PlayerMouse.GetSelectedY());
|
||||
_world.RemoveBlock(PlayerMouse.GetSelectedX(),PlayerMouse.GetSelectedY());
|
||||
}
|
||||
if (mouseState.RightButton == ButtonState.Pressed)
|
||||
{
|
||||
@@ -179,7 +180,7 @@ namespace Collector.Character
|
||||
|
||||
private void PlaceSelectedBlock(Blocks selectedItem)
|
||||
{
|
||||
_chunks.PlaceBlock(PlayerMouse.GetSelectedX(), PlayerMouse.GetSelectedY(), selectedItem);
|
||||
_world.PlaceBlock(PlayerMouse.GetSelectedX(), PlayerMouse.GetSelectedY(), selectedItem);
|
||||
}
|
||||
|
||||
private void UpdateAnimationFrame(GameTime gameTime)
|
||||
|
||||
@@ -8,7 +8,11 @@ public class Inventory {
|
||||
|
||||
public static Blocks GetSelectedItem()
|
||||
{
|
||||
return (Blocks) Gui._combo.SelectedIndex.Value;
|
||||
if (Gui._combo.SelectedIndex != null) return (Blocks) Gui._combo.SelectedIndex.Value;
|
||||
else
|
||||
{
|
||||
return Blocks.BlockAir;
|
||||
}
|
||||
}
|
||||
|
||||
public LinkedList<ItemStack> GetInventory() {
|
||||
|
||||
@@ -11,26 +11,26 @@ namespace Collector.Character
|
||||
public static float X { get; private set; }
|
||||
public static float Y { get; private set; }
|
||||
private RectangleF _playerBounds;
|
||||
private Chunks _chunks { get; }
|
||||
private World World { get; }
|
||||
|
||||
public Player(int x, int y, Chunks chunks)
|
||||
public Player(int x, int y, World world)
|
||||
{
|
||||
X = x;
|
||||
Y = y;
|
||||
_chunks = chunks;
|
||||
World = world;
|
||||
_playerBounds = new RectangleF(x, y, IRestrictions.TileSize * 0.5f, IRestrictions.TileSize * 0.35f);
|
||||
}
|
||||
|
||||
public void Move(OrthographicCamera cam, float x, float y)
|
||||
{
|
||||
Teleport(cam, x, 0);
|
||||
if (_chunks.LoadedCollisions.Values.Any(collisionsValue => collisionsValue.Rectangle.Intersects(_playerBounds)))
|
||||
if (World.LoadedCollisions.Values.Any(collisionsValue => collisionsValue.Rectangle.Intersects(_playerBounds)))
|
||||
{
|
||||
Teleport(cam, -x, 0);
|
||||
}
|
||||
|
||||
Teleport(cam, 0, y);
|
||||
if (_chunks.LoadedCollisions.Values.Any(collisionsValue => collisionsValue.Rectangle.Intersects(_playerBounds)))
|
||||
if (World.LoadedCollisions.Values.Any(collisionsValue => collisionsValue.Rectangle.Intersects(_playerBounds)))
|
||||
{
|
||||
Teleport(cam, 0, -y);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
namespace Collector.Dimension
|
||||
{
|
||||
public class Autotiling
|
||||
public class WangTile
|
||||
{
|
||||
|
||||
}
|
||||
@@ -7,7 +7,7 @@ using Collector.ThirdPartyCode;
|
||||
|
||||
namespace Collector.Dimension
|
||||
{
|
||||
public class Chunks
|
||||
public class World
|
||||
{
|
||||
public Dictionary<Tuple<int, int, int>, Blocks> LoadedChunks { get; } = new Dictionary<Tuple<int, int, int>, Blocks>();
|
||||
private readonly Dictionary<Tuple<int, int, int>, Blocks> _savedChunks = new Dictionary<Tuple<int, int, int>, Blocks>();
|
||||
@@ -66,13 +66,6 @@ namespace Collector.Dimension
|
||||
);
|
||||
}
|
||||
}
|
||||
public void CreateStructures() {
|
||||
const int i = 10;
|
||||
SetBlock(3 + i, 2,1,Blocks.BlockWall);
|
||||
SetBlock(4 + i, 2,1,Blocks.BlockWall);
|
||||
SetBlock(3 + i, 3,1, Blocks.BlockRoof);
|
||||
SetBlock(4 + i, 3,1,Blocks.BlockRoof);
|
||||
}
|
||||
|
||||
private void SetBlock(int x, int y, int z, Blocks name)
|
||||
{
|
||||
@@ -109,7 +102,7 @@ namespace Collector.Dimension
|
||||
_savedChunks[tuple] = Blocks.BlockAir;
|
||||
}
|
||||
|
||||
public void UngenerateChunk(float x, float y) {
|
||||
private void UngenerateChunk(float x, float y) {
|
||||
var startX = (int)x << IRestrictions.ChunkShift;
|
||||
var startY = (int)y << IRestrictions.ChunkShift;
|
||||
var endX = startX + IRestrictions.ChunkSize;
|
||||
@@ -125,7 +118,7 @@ namespace Collector.Dimension
|
||||
}
|
||||
}
|
||||
|
||||
public void GenerateChunk(float x, float y) {
|
||||
private void GenerateChunk(float x, float y) {
|
||||
var startX = (int)x << IRestrictions.ChunkShift;
|
||||
var startY = (int)y << IRestrictions.ChunkShift;
|
||||
var endX = startX + IRestrictions.ChunkSize;
|
||||
@@ -252,7 +245,7 @@ namespace Collector.Dimension
|
||||
return moisture < 0.66 ? "TropicalSeasonalForest" : "TropicalRainForest";
|
||||
}
|
||||
|
||||
public bool IsEmpty(float x, float y){
|
||||
private bool IsEmpty(float x, float y){
|
||||
return !LoadedChunks.ContainsKey(new Tuple<int,int,int>((int)x * 8, (int)y * 8,0));
|
||||
}
|
||||
}
|
||||
@@ -11,26 +11,26 @@ namespace Collector.Dimension
|
||||
private readonly InputController _inputController;
|
||||
private readonly SpriteBatch _spriteBatch;
|
||||
private readonly Main _main;
|
||||
private readonly Chunks _chunks;
|
||||
private readonly World _world;
|
||||
|
||||
public WorldRenderer(PlayerMouse playerMouse, InputController inputController, SpriteBatch spriteBatch, Main main, Chunks chunks)
|
||||
public WorldRenderer(PlayerMouse playerMouse, InputController inputController, SpriteBatch spriteBatch, Main main, World world)
|
||||
{
|
||||
_playerMouse = playerMouse;
|
||||
_inputController = inputController;
|
||||
_spriteBatch = spriteBatch;
|
||||
_main = main;
|
||||
_chunks = chunks;
|
||||
_chunks.Impassable.Add(Blocks.BlockWater);
|
||||
_chunks.Impassable.Add(Blocks.BlockRoof);
|
||||
_chunks.Impassable.Add(Blocks.BlockWall);
|
||||
_world = world;
|
||||
_world.Impassable.Add(Blocks.BlockWater);
|
||||
_world.Impassable.Add(Blocks.BlockRoof);
|
||||
_world.Impassable.Add(Blocks.BlockWall);
|
||||
}
|
||||
|
||||
private void DrawWorld(SpriteBatch batch, int layer)
|
||||
{
|
||||
foreach (var chunkpair in _chunks.LoadedChunks.Keys.Where(chunkpair => layer==chunkpair.Item3))
|
||||
foreach (var chunkpair in _world.LoadedChunks.Keys.Where(chunkpair => layer==chunkpair.Item3))
|
||||
{
|
||||
batch.Draw(
|
||||
Main.Materials[_chunks.LoadedChunks[chunkpair]],
|
||||
Main.Materials[_world.LoadedChunks[chunkpair]],
|
||||
new Rectangle(
|
||||
chunkpair.Item1,
|
||||
chunkpair.Item2,
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace Collector.UI
|
||||
_desktop = desktop;
|
||||
}
|
||||
|
||||
public void LoadGUI()
|
||||
public void LoadGui()
|
||||
{
|
||||
var grid = new Grid
|
||||
{
|
||||
@@ -49,6 +49,8 @@ namespace Collector.UI
|
||||
_combo.Items.Add(new ListItem(name.ToString(), Color.White));
|
||||
}
|
||||
|
||||
_combo.SelectedItem = _combo.Items[2];
|
||||
|
||||
grid.Widgets.Add(_combo);
|
||||
|
||||
|
||||
@@ -67,7 +69,7 @@ namespace Collector.UI
|
||||
};
|
||||
}
|
||||
|
||||
private Grid InventoryGrid()
|
||||
private static Grid InventoryGrid()
|
||||
{
|
||||
var textBox1 = new TextBox {AcceptsKeyboardFocus = true};
|
||||
var checkBox1 = new CheckBox {Text = "Item1", GridRow = 1, AcceptsKeyboardFocus = false};
|
||||
@@ -123,7 +125,7 @@ namespace Collector.UI
|
||||
return grid1;
|
||||
}
|
||||
|
||||
public void Update()
|
||||
public static void Update()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user