Added back the map, movement and zooming. Also changed all Textures to 32bit

This commit is contained in:
2020-04-21 13:39:42 -06:00
parent 2892570539
commit 85af72cfa1
56 changed files with 659 additions and 241 deletions

View File

@@ -1,4 +1,6 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation"> <wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:Boolean x:Key="/Default/UserDictionary/Words/=Biome/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/UserDictionary/Words/=Biome/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=chunkpair/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Crosshair/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Shrubland/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/UserDictionary/Words/=Shrubland/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Ungenerate/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary> <s:Boolean x:Key="/Default/UserDictionary/Words/=Ungenerate/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>

View File

@@ -12,6 +12,7 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="MonoGame.Content.Builder" Version="3.7.0.9" /> <PackageReference Include="MonoGame.Content.Builder" Version="3.7.0.9" />
<PackageReference Include="MonoGame.Extended" Version="3.7.0" />
<PackageReference Include="MonoGame.Framework.DesktopGL.Core" Version="3.8.0.13" /> <PackageReference Include="MonoGame.Framework.DesktopGL.Core" Version="3.8.0.13" />
</ItemGroup> </ItemGroup>

View File

@@ -73,6 +73,390 @@
/processorParam:TextureFormat=Color /processorParam:TextureFormat=Color
/build:man.png /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 #begin roof.png
/importer:TextureImporter /importer:TextureImporter
/processor:TextureProcessor /processor:TextureProcessor

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 248 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 262 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 268 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 285 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 268 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 281 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 268 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 280 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 248 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 259 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 248 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 263 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 248 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 246 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 262 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 246 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 260 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 268 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 279 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 268 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 285 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 268 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 281 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 263 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 268 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 280 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 267 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 281 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 267 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 283 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 268 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 279 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.9 KiB

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.9 KiB

After

Width:  |  Height:  |  Size: 3.1 KiB

View File

@@ -1,7 +1,11 @@
using Collector.Dimension; using Collector.Character;
using Collector.Dimension;
using Microsoft.Xna.Framework; using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input; using Microsoft.Xna.Framework.Input;
using MonoGame.Extended;
using MonoGame.Extended.ViewportAdapters;
using Mouse = Collector.Character.Mouse;
namespace Collector namespace Collector
{ {
@@ -10,9 +14,13 @@ namespace Collector
private GraphicsDeviceManager _graphics; private GraphicsDeviceManager _graphics;
private SpriteBatch _spriteBatch; private SpriteBatch _spriteBatch;
private InputController _inputController; private InputController _inputController;
private Player _player;
private Mouse _mouse;
private OrthographicCamera _cam;
private WorldRenderer WorldRenderer { get; set; }
public Main() public Main()
{ {
_graphics = new GraphicsDeviceManager(this); _graphics = new GraphicsDeviceManager(this);
Content.RootDirectory = "Content"; Content.RootDirectory = "Content";
IsMouseVisible = true; IsMouseVisible = true;
@@ -20,33 +28,38 @@ namespace Collector
protected override void Initialize() protected override void Initialize()
{// TODO: Add your initialization logic here {// TODO: Add your initialization logic here
base.Initialize(); base.Initialize();
BlockMaterials.Initialize(Content);
var viewportAdapter = new BoxingViewportAdapter(Window, GraphicsDevice, 800, 480);
_player = new Player(0,0);
_cam = new OrthographicCamera(viewportAdapter);
_cam.LookAt(new Vector2(Player.X,Player.Y));
_spriteBatch = new SpriteBatch(GraphicsDevice);
_mouse = new Mouse(Content,_spriteBatch);
_inputController = new InputController(_player,_mouse,_cam,_spriteBatch,Content);
WorldRenderer = new WorldRenderer(_mouse,_inputController,_player,_spriteBatch,this,_cam);
} }
protected override void LoadContent()
{// TODO: use this.Content to load your game content here
_spriteBatch = new SpriteBatch(GraphicsDevice);
BlockMaterials.LoadContent(Content);
}
protected override void Update(GameTime gameTime) protected override void Update(GameTime gameTime)
{// TODO: Add your update logic here/* {// TODO: Add your update logic here/*
_inputController.PlayerInput();
base.Update(gameTime); base.Update(gameTime);
_inputController.PlayerInput(this,_spriteBatch);
World.LoadChunks();
World.UnloadChunks();
} }
protected override void Draw(GameTime gameTime) protected override void Draw(GameTime gameTime)
{ {// TODO: Add your drawing code here
GraphicsDevice.Clear(Color.CornflowerBlue); var transformMatrix = _cam.GetViewMatrix();
// TODO: Add your drawing code here
base.Draw(gameTime); base.Draw(gameTime);
_spriteBatch.Begin(); GraphicsDevice.Clear(Color.CornflowerBlue);
BlockMaterials.Draw("grass",_spriteBatch,0,0); _spriteBatch.Begin(transformMatrix: transformMatrix);
_mouse.Draw();
WorldRenderer.Draw();
_spriteBatch.End(); _spriteBatch.End();
} }
} }

View File

@@ -11,7 +11,7 @@ namespace Collector
public const int MovementSpeed = 16; public const int MovementSpeed = 16;
public const int FreeSpeed = 2; public const int FreeSpeed = 2;
public const int KeyDelay = 0; public const int KeyDelay = 0;
public const int TileSize = 16; public const int TileSize = 32;
public const int ChunkSize = 8; public const int ChunkSize = 8;
public const int SuperChunkSize = 1; public const int SuperChunkSize = 1;
public const int TileShift = 5; public const int TileShift = 5;

View File

@@ -1,59 +1,91 @@
using System.Collections.Generic; using System.Collections.Generic;
using Collector; using Collector;
using Collector.Character;
using Collector.Dimension; using Collector.Dimension;
using Microsoft.Xna.Framework; using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input; 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 Player _player;
private Mouse mouse; private Mouse _mouse;
//private Dictionary<string, Animation<TextureAtlas.AtlasRegion>> animations; private OrthographicCamera _cam;
int i = 0; 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; _player = player;
this.mouse = mouse; _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() { public void PlayerInput(Main main, SpriteBatch spriteBatch)
/*
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()
{ {
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);
}
} }

View File

@@ -1,25 +1,33 @@
package Collector.Character; using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
import Collector.Restrictions; namespace Collector.Character
import com.badlogic.gdx.graphics.Texture; {
import com.badlogic.gdx.math.Vector3; public class Mouse : IRestrictions {
private SpriteBatch _spriteBatch;
private ContentManager _contentManager;
private Texture2D Crosshair { get; set; }
public class Mouse implements Restrictions { public Mouse(ContentManager contentManager, SpriteBatch spriteBatch)
Texture crosshair; {
_spriteBatch = spriteBatch;
_contentManager = contentManager;
Crosshair = _contentManager.Load<Texture2D>("crosshair");
}
public Mouse() { public void Draw()
this.crosshair = new Texture("assets/crosshair.png"); {
} _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) { public int GetSelectedY(Vector3 mousePos) {
return ((int)(mousePos.x)>>4)<<4; return ((int)(mousePos.Y)>>4)<<4;
} }
public int getSelectedY(Vector3 mousePos) {
return ((int)(mousePos.y)>>4)<<4;
} }
} }

View File

@@ -1,62 +1,19 @@
using Collector; using System.Collections.Generic;
using Microsoft.Xna.Framework;
public class Player : IRestrictions { namespace Collector.Character
private static int X; {
private static int Y; public class Player : IRestrictions
private string SpriteName; {
private Inventory playerInventory; 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) { public Player(int x, int y) {
//Player location X = x<<IRestrictions.TileShift;
X = x<<IRestrictions.TileShift; Y = y<<IRestrictions.TileShift;
Y = y<<IRestrictions.TileShift; //PlayerInventory = new Inventory();
}
//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 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;
}
*/
} }

View File

@@ -1,12 +1,8 @@
public class Block { public class Block {
private string name = null; public string Name { get; }
public Block(string name) { public Block(string name) {
this.name = name; Name = name;
}
public string getName() {
return name;
} }
} }

View File

@@ -12,7 +12,7 @@ namespace Collector.Dimension
//Private so the singleton can't be instantiated //Private so the singleton can't be instantiated
internal BlockMaterials() {} internal BlockMaterials() {}
public static void LoadContent(ContentManager content){ public static void Initialize(ContentManager content){
Materials.Add("grass",new Block("grass")); Materials.Add("grass",new Block("grass"));
Materials.Add("wood",new Block("wood")); Materials.Add("wood",new Block("wood"));
Materials.Add("water",new Block("water")); Materials.Add("water",new Block("water"));
@@ -27,11 +27,11 @@ namespace Collector.Dimension
{ {
Textures.Add(name,content.Load<Texture2D>(name)); Textures.Add(name,content.Load<Texture2D>(name));
} }
} }
public static void Draw(string name,SpriteBatch _spriteBatch,int x, int y) public static void Draw(string name,SpriteBatch _spriteBatch,int x, int y)
{ {
_spriteBatch.Draw(Textures[name],new Vector2(x, y),Color.Aqua);
} }
} }
} }

View File

@@ -7,36 +7,38 @@ using Collector.ThirdPartyCode;
namespace Collector.Dimension namespace Collector.Dimension
{ {
public class Chunks: IRestrictions { 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> LoadedChunks { get; } =
public static Dictionary<Tuple<int, int, int>, Block> SavedChunks = new Dictionary<Tuple<int, int, int>, Block>(); new Dictionary<Tuple<int, int, int>, Block>();
public static OpenSimplexNoise Gen1 = new OpenSimplexNoise(IRestrictions.Seed+ 1);
public static OpenSimplexNoise Gen2 = new OpenSimplexNoise(IRestrictions.Seed); 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() { public static void CreateStructures() {
var i = 10; const int i = 10;
SetBlock(3 + i, 2,1,"wall"); SetBlock(3 + i, 2,1,"wall");
SetBlock(4 + i, 2,1,"wall"); SetBlock(4 + i, 2,1,"wall");
SetBlock(3 + i, 3,1, "roof"); SetBlock(3 + i, 3,1, "roof");
SetBlock(4 + 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]); 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]); 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); var triple = new Tuple<int, int, int>(x, y, 1);
if (!Chunks.LoadedChunks[triple].getName().Equals("air")) return; if (!LoadedChunks[triple].Name.Equals("air")) return;
Chunks.LoadedChunks[triple] = BlockMaterials.Materials[name]; LoadedChunks[triple] = BlockMaterials.Materials[name];
Chunks.SavedChunks[triple] = BlockMaterials.Materials[name]; SavedChunks[triple] = BlockMaterials.Materials[name];
} }
public static void RemoveBlock(int x, int y){ public static void RemoveBlock(int x, int y){
var triple = new Tuple<int, int, int>(x, y, 1); var triple = new Tuple<int, int, int>(x, y, 1);
if (Chunks.LoadedChunks[triple].getName().Equals("air")) return; if (LoadedChunks[triple].Name.Equals("air")) return;
Chunks.LoadedChunks[triple] = BlockMaterials.Materials["air"]; LoadedChunks[triple] = BlockMaterials.Materials["air"];
Chunks.SavedChunks[triple] = BlockMaterials.Materials["air"]; SavedChunks[triple] = BlockMaterials.Materials["air"];
} }
public static void UngenerateChunk(int x, int y) { public static void UngenerateChunk(int x, int y) {
@@ -70,7 +72,7 @@ namespace Collector.Dimension
for (var i = startX; i != endX; i++) { for (var i = startX; i != endX; i++) {
for (var j = startY; j != endY; j++) { for (var j = startY; j != endY; j++) {
var triple = new Tuple<int, int, int>(i, j, 0); var triple = new Tuple<int, int, int>(i, j, 0);
if(SavedChunks[triple] != null){ if(SavedChunks.ContainsKey(triple)){
LoadedChunks.Add(triple,SavedChunks[triple]); LoadedChunks.Add(triple,SavedChunks[triple]);
} }
else { else {
@@ -84,8 +86,8 @@ namespace Collector.Dimension
for (var i = startX; i != endX; i++){ for (var i = startX; i != endX; i++){
for (var j = startY; j != endY; j++) { for (var j = startY; j != endY; j++) {
var triple = new Tuple<int, int, int>(i, j,1); var triple = new Tuple<int, int, int>(i, j,1);
LoadedChunks.Add(triple, GetBlocks(i,j,1)); LoadedChunks[triple] = GetBlocks(i,j,1);
SavedChunks.Add(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) { 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) { 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) { private static Block GetTerrain(int x, int y) {
@@ -174,7 +176,7 @@ namespace Collector.Dimension
} }
public static bool IsEmpty(int x, int y){ 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));
} }
} }
} }

View File

@@ -1,53 +1,56 @@
using Collector; using System;
using Collector.Dimension; using Collector.Character;
public class World { namespace Collector.Dimension
public static void generateWorld(int x, int y) { {
if (Chunks.IsEmpty(x, y)) { public static class World {
Chunks.GenerateChunk(x, y); 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) { private static void UngenerateWorld(int x, int y) {
if (!Chunks.IsEmpty(x, y)) { if (!Chunks.IsEmpty(x, y)) {
Chunks.UngenerateChunk(x, y); Chunks.UngenerateChunk(x, y);
}
} }
}
public static void loadChunks() { public static void LoadChunks()
for (var i = -(IRestrictions.RenderDistance); i < IRestrictions.RenderDistance; i++) { {
for (var j = -(IRestrictions.RenderDistance); j < IRestrictions.RenderDistance; j++) { for (var i = -(IRestrictions.RenderDistance); i < IRestrictions.RenderDistance; i++) {
generateWorld( for (var j = -(IRestrictions.RenderDistance); j < IRestrictions.RenderDistance; j++) {
i + Player.getX() / (IRestrictions.TileSize * IRestrictions.SuperChunkSize * IRestrictions.ChunkSize), GenerateWorld(
j + Player.getY() / (IRestrictions.TileSize * IRestrictions.SuperChunkSize * IRestrictions.ChunkSize) 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
);
}
}
} }

View File

@@ -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 Microsoft.Xna.Framework.Graphics;
using MonoGame.Extended;
namespace Collector.Dimension namespace Collector.Dimension
{ {
public class WorldRenderer : IRestrictions { public class WorldRenderer : IRestrictions
//private Mouse mouse; {
//private InputController inputController; private Mouse _mouse;
//private Player _player; private InputController _inputController;
private Player _player;
private SpriteBatch _spriteBatch;
private Main _main;
private OrthographicCamera _orthographicCamera;
/* public WorldRenderer(Mouse mouse, InputController inputController, Player player, SpriteBatch spriteBatch, Main main, 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)
{ {
/* _mouse = mouse;
foreach (var chunkpair in Chunks.LoadedChunks.Keys.Where(chunkpair => chunkpair.Item3 == layer)) _inputController = inputController;
_player = player;
_spriteBatch = spriteBatch;
_main = main;
_orthographicCamera = orthographicCamera;
}
private static void DrawWorld(SpriteBatch batch, int layer)
{ {
batch.draw( foreach (var chunkpair in Chunks.LoadedChunks.Keys.Where(chunkpair => chunkpair.Item3 == layer))
//BlockMaterials.Textures[Chunks.LoadedChunks[chunkpair].getName()], {
chunkpair.Item1 << IRestrictions.TileShift, batch.Draw(
chunkpair.Item2 << IRestrictions.TileShift 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);
}
*/
}
}