From fd6fa4e5cebbe3edb65d50c78dcc8a97ce98ce64 Mon Sep 17 00:00:00 2001 From: aldrikboy Date: Mon, 11 Dec 2017 22:02:13 +0100 Subject: First commit --- Penguloon/Levels/Map.cs | 63 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 Penguloon/Levels/Map.cs (limited to 'Penguloon/Levels/Map.cs') diff --git a/Penguloon/Levels/Map.cs b/Penguloon/Levels/Map.cs new file mode 100644 index 0000000..384d011 --- /dev/null +++ b/Penguloon/Levels/Map.cs @@ -0,0 +1,63 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Penguloon.Scenes; + +namespace Penguloon.Levels +{ + public class Map + { + // 18 x 12 + public Tile[,] TileMap { get; set; } + + public int MapWidth { get; private set; } + public int MapHeight { get; private set; } + + public int TileWidth { get; private set; } + public int TileHeight { get; private set; } + + public SceneBase ParentScene { get; set; } + + public Map(SceneBase parentScene) + { + this.ParentScene = parentScene; + + MapWidth = (int)StaticUIValues.ScreenViewport.X - StaticUIValues.IngameUIWidth; + MapHeight = (int)StaticUIValues.ScreenViewport.Y; + + TileWidth = MapWidth / 18; + TileHeight = MapHeight / 12; + } + + public void Draw(float deltaTime) + { + for(int y = 0; y < TileMap.GetLength(0); y++) + { + for (int x = 0; x < TileMap.GetLength(1); x++) + { + Texture2D tileTexture = ContentManager.GetTileTextureByType(TileMap[y, x].Type); + + ParentScene.Main.SpriteBatch.Draw(tileTexture, + destinationRectangle: new Rectangle(x * TileWidth, y * TileHeight, TileWidth, TileHeight)); + } + } + } + + public void Update(float deltaTime) + { + + } + } + + public class Tile + { + public int Type { get; set; } + + public Direction Direction { get; set; } + + public Tile(int type, Direction direction) + { + this.Type = type; + this.Direction = direction; + } + } +} \ No newline at end of file -- cgit v1.2.3-70-g09d2