Changeset 4535
- Timestamp:
- 2013-07-22 22:52:24 (10 years ago)
- Location:
- 2013/30/DenisZ/CastleMaster/CastleMaster
- Files:
-
- 15 added
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
2013/30/DenisZ/CastleMaster/CastleMaster/CastleMaster/CastleMaster.csproj
r4521 r4535 19 19 <ApplicationIcon>Game.ico</ApplicationIcon> 20 20 <Thumbnail>GameThumbnail.png</Thumbnail> 21 <IsWebBootstrapper>false</IsWebBootstrapper> 21 22 <PublishUrl>publish\</PublishUrl> 22 23 <Install>true</Install> … … 31 32 <ApplicationRevision>0</ApplicationRevision> 32 33 <ApplicationVersion>1.0.0.%2a</ApplicationVersion> 33 <IsWebBootstrapper>false</IsWebBootstrapper>34 34 <UseApplicationTrust>false</UseApplicationTrust> 35 35 <BootstrapperEnabled>true</BootstrapperEnabled> … … 74 74 </ItemGroup> 75 75 <ItemGroup> 76 <Compile Include="Entities\Entity.cs" /> 77 <Compile Include="Entities\TileEntities\TileEntity.cs" /> 78 <Compile Include="Entities\TileEntities\TileEntityBlock.cs" /> 79 <Compile Include="Graphics\AnimationHelper.cs" /> 76 80 <Compile Include="Graphics\Camera.cs" /> 77 81 <Compile Include="Graphics\RenderHelper.cs" /> … … 80 84 <Compile Include="Graphics\Viewport.cs" /> 81 85 <Compile Include="Input\InputHandler.cs" /> 86 <Compile Include="MathHelpers\FastFunctions.cs" /> 87 <Compile Include="MathHelpers\FastRandom.cs" /> 88 <Compile Include="Physics\BoundingRectangle.cs" /> 89 <Compile Include="Physics\BoundingRectangleOwner.cs" /> 82 90 <Compile Include="Properties\AssemblyInfo.cs" /> 83 91 <Compile Include="Program.cs" /> 84 92 <Compile Include="Game.cs" /> 85 93 <Compile Include="World\Level.cs" /> 94 <Compile Include="World\LevelBuilder.cs" /> 86 95 <Compile Include="World\LevelTest.cs" /> 87 96 <Compile Include="World\Tiles\Tile.cs" /> 88 97 <Compile Include="World\Tiles\TileFloor.cs" /> 98 <Compile Include="World\Tiles\TileWater.cs" /> 89 99 </ItemGroup> 90 100 <ItemGroup> -
2013/30/DenisZ/CastleMaster/CastleMaster/CastleMaster/Game.cs
r4521 r4535 1 using CastleMaster.Graphics; 2 using CastleMaster.Input; 3 using CastleMaster.World; 4 using Microsoft.Xna.Framework; 5 using Microsoft.Xna.Framework.Graphics; 6 using SharpNeatLib.Maths; 1 7 using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using Microsoft.Xna.Framework; 5 using Microsoft.Xna.Framework.Audio; 6 using Microsoft.Xna.Framework.Content; 7 using Microsoft.Xna.Framework.GamerServices; 8 using Microsoft.Xna.Framework.Graphics; 9 using Microsoft.Xna.Framework.Input; 10 using Microsoft.Xna.Framework.Media; 11 using CastleMaster.Input; 8 using System.Text; 9 using System.Windows.Forms; 12 10 using Keys = System.Windows.Forms.Keys; 13 11 using Viewport = CastleMaster.Graphics.Viewport; 14 using System.Text;15 using CastleMaster.Graphics;16 using CastleMaster.World;17 12 18 13 namespace CastleMaster … … 44 39 #endregion 45 40 41 public static FastRandom Random { get; private set; } 42 46 43 public Game() 47 44 { … … 49 46 Content.RootDirectory = "Content"; 50 47 input = new InputHandler(Window); 48 Random = new FastRandom(); 51 49 } 52 50 … … 61 59 graphics.PreferredBackBufferWidth = WIDTH; 62 60 graphics.PreferredBackBufferHeight = HEIGHT; 63 graphics.SynchronizeWithVerticalRetrace = true;61 graphics.SynchronizeWithVerticalRetrace = false; 64 62 graphics.ApplyChanges(); 65 63 Window.Title = TITLE; 66 IsMouseVisible = true;67 64 68 65 InitializeInput(); … … 80 77 input.RegisterKeyboardKey(Keys.Z); 81 78 input.RegisterKeyboardKey(Keys.X); 79 input.RegisterKeyboardKey(Keys.F4); 80 81 input.RegisterMouseKey(MouseButtons.Middle); 82 82 } 83 83 … … 107 107 base.BeginRun(); 108 108 109 camera = new Camera();110 level = new LevelTest(128, 128);109 level = new LevelTest(Resources.LEVEL_TEST); 110 camera = new Camera(level); 111 111 } 112 112 … … 121 121 camera.Update(); 122 122 123 if (InputHandler.HasKeyBeenPressed(Keys.F4)) 124 IsFixedTimeStep = !IsFixedTimeStep; 125 123 126 if (InputHandler.HasKeyBeenPressed(Keys.Escape)) 124 127 this.Exit(); … … 131 134 if (InputHandler.IsKeyDown(Keys.D)) 132 135 camera.XLeft += cameraSpeed; 133 if (InputHandler.HasKeyBeenPressed(Keys.Z)) 134 Viewport.ZOOM += Viewport.ZOOM_STEP; 135 if (InputHandler.HasKeyBeenPressed(Keys.X)) 136 Viewport.ZOOM -= Viewport.ZOOM_STEP; 136 137 if (InputHandler.MouseScrollDelta > 1) 138 camera.Zoom(Viewport.ZOOM_STEP); 139 else if (InputHandler.MouseScrollDelta < 0) 140 camera.Zoom(-Viewport.ZOOM_STEP); 141 142 level.Update(); 137 143 138 144 updates++; … … 159 165 160 166 level.RenderBackground(camera, renderer); 167 camera.RenderSelelctor(renderer); 168 level.RenderEntities(camera, renderer); 161 169 170 camera.RenderCursor(renderer); 162 171 renderer.EndRender(); 163 172 -
2013/30/DenisZ/CastleMaster/CastleMaster/CastleMaster/Graphics/Camera.cs
r4521 r4535 1 using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using System.Text; 1 using CastleMaster.Input; 2 using CastleMaster.World; 5 3 using Microsoft.Xna.Framework; 6 using CastleMaster.Input;4 using System.Windows.Forms; 7 5 8 6 namespace CastleMaster.Graphics … … 11 9 { 12 10 private int xOffs = 0, yOffs = 0; 13 private Vector2 mouseWorldPos = Vector2.Zero; 14 private Point oldMousePos = Point.Zero; 11 private Vector2 mouseWorldPos, selectorPos, selectorPosZoomed; 12 private Point mouseTilePos, oldMousePos; 13 private Level level; 14 private bool moveWorldWithMouse = false; 15 15 16 public Camera( )16 public Camera(Level level) 17 17 { 18 this.level = level; 19 mouseWorldPos = Vector2.Zero; 20 selectorPos = Vector2.Zero; 21 selectorPosZoomed = Vector2.Zero; 22 mouseTilePos = Point.Zero; 23 oldMousePos = Point.Zero; 18 24 } 19 25 … … 46 52 public void Update() 47 53 { 54 if (InputHandler.HasMouseButtonBeenPressed(MouseButtons.Middle) || moveWorldWithMouse) 55 { 56 if (!moveWorldWithMouse) 57 { 58 moveWorldWithMouse = true; 59 oldMousePos = InputHandler.MousePos; 60 } 61 62 if (InputHandler.IsMouseButtonDown(MouseButtons.Middle)) 63 { 64 xOffs -= (InputHandler.MousePos.X - oldMousePos.X); 65 yOffs -= (InputHandler.MousePos.Y - oldMousePos.Y); 66 67 oldMousePos = InputHandler.MousePos; 68 } 69 else moveWorldWithMouse = false; 70 } 71 48 72 mouseWorldPos = Viewport.ScreenToWorld(InputHandler.MouseX + xOffs, InputHandler.MouseY + yOffs); 73 int xTile = (int)(mouseWorldPos.X / Viewport.TILESIZE); 74 int zTile = (int)(mouseWorldPos.Y / Viewport.TILESIZE); 75 if (xTile < 0) xTile = 0; 76 else if (xTile >= level.Width) xTile = level.Width - 1; 77 if (zTile < 0) zTile = 0; 78 else if (zTile >= level.Height) zTile = level.Height - 1; 79 80 if (xTile != mouseTilePos.X || zTile != mouseTilePos.Y) 81 { 82 mouseTilePos.X = xTile; 83 mouseTilePos.Y = zTile; 84 selectorPos.X = (xTile - zTile) * Viewport.X_STEP; 85 selectorPos.Y = (xTile + zTile) * Viewport.Y_STEP + Viewport.Y_STEP; 86 selectorPosZoomed = selectorPos * Viewport.ZOOM; 87 } 88 89 49 90 } 50 91 … … 53 94 Viewport.ZOOM += factor; 54 95 55 xOffs = (int)((mouseWorldPos.X - mouseWorldPos.Y) * Viewport.X_SCALE_ZOOMED); 56 yOffs = (int)((mouseWorldPos.X + mouseWorldPos.Y) * Viewport.Y_SCALE_ZOOMED); 96 xOffs = (int)((mouseWorldPos.X - mouseWorldPos.Y + Viewport.TILESIZE) * Viewport.X_SCALE_ZOOMED) - InputHandler.MouseX; 97 yOffs = (int)((mouseWorldPos.X + mouseWorldPos.Y + Viewport.TILESIZE) * Viewport.Y_SCALE_ZOOMED) - InputHandler.MouseY; 98 selectorPosZoomed = selectorPos * Viewport.ZOOM; 99 } 100 101 public void CenterOn(float x, float z) 102 { 103 xOffs = (int)((x - z + Viewport.TILESIZE) * Viewport.X_SCALE_ZOOMED) - Game.WIDTH / 2; 104 yOffs = (int)((x + z + Viewport.TILESIZE) * Viewport.Y_SCALE_ZOOMED) - Game.HEIGHT / 2; 105 } 106 107 public void RenderSelelctor(RenderHelper renderer) 108 { 109 renderer.SetOffset(this); 110 renderer.Render(selectorPosZoomed, 3, 1, Resources.SPRITESHEET_TILES, Viewport.ZOOM); 111 renderer.SetOffset(); 112 } 113 114 public void RenderCursor(RenderHelper renderer) 115 { 116 renderer.Render(InputHandler.MouseX, InputHandler.MouseY, 0, 0, Resources.SPRITESHEET_ICONS, Color.White, 3.0F); 57 117 } 58 118 } -
2013/30/DenisZ/CastleMaster/CastleMaster/CastleMaster/Graphics/RenderHelper.cs
r4512 r4535 1 using System; 1 using Microsoft.Xna.Framework; 2 using Microsoft.Xna.Framework.Graphics; 2 3 using System.Collections.Generic; 3 using System.Linq;4 using System.Text;5 using Microsoft.Xna.Framework.Graphics;6 using Microsoft.Xna.Framework;7 4 8 5 namespace CastleMaster.Graphics -
2013/30/DenisZ/CastleMaster/CastleMaster/CastleMaster/Graphics/Resources.cs
r4512 r4535 1 using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using System.Text; 5 using Microsoft.Xna.Framework.Content; 1 using Microsoft.Xna.Framework.Content; 6 2 using Microsoft.Xna.Framework.Graphics; 7 3 … … 11 7 { 12 8 public static int SPRITESHEET_TILES { get; private set; } 9 public static int SPRITESHEET_ICONS { get; private set; } 10 public static Texture2D LEVEL_TEST { get; private set; } 13 11 14 12 public static void LoadResources(ContentManager cm, RenderHelper renderer) 15 13 { 16 14 SPRITESHEET_TILES = renderer.RegisterSpriteSheet(new SpriteSheet(cm.Load<Texture2D>("tiles/tilesheet"), 32, 32)); 15 SPRITESHEET_ICONS = renderer.RegisterSpriteSheet(new SpriteSheet(cm.Load<Texture2D>("misc/icons"), 16, 16)); 16 LEVEL_TEST = cm.Load<Texture2D>("levels/levelTest"); 17 17 } 18 18 } -
2013/30/DenisZ/CastleMaster/CastleMaster/CastleMaster/Graphics/SpriteSheet.cs
r4508 r4535 1 using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using System.Text; 1 using Microsoft.Xna.Framework; 5 2 using Microsoft.Xna.Framework.Graphics; 6 using Microsoft.Xna.Framework;7 3 8 4 namespace CastleMaster.Graphics -
2013/30/DenisZ/CastleMaster/CastleMaster/CastleMaster/Graphics/Viewport.cs
r4512 r4535 1 using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using System.Text; 5 using Microsoft.Xna.Framework; 1 using Microsoft.Xna.Framework; 6 2 7 3 namespace CastleMaster.Graphics … … 49 45 float yRegion = (y / ZOOM) / Y_SCALE; 50 46 51 return new Vector2((xRegion + yRegion) / 2 , (yRegion - xRegion) / 2);47 return new Vector2((xRegion + yRegion) / 2 - Viewport.TILESIZE, (yRegion - xRegion) / 2); 52 48 } 53 49 } -
2013/30/DenisZ/CastleMaster/CastleMaster/CastleMaster/Input/InputHandler.cs
r4508 r4535 1 using System; 1 using Microsoft.Xna.Framework; 2 using Microsoft.Xna.Framework.Input; 2 3 using System.Collections.Generic; 3 using System.Linq;4 using System.Text;5 4 using System.Windows.Forms; 6 using Microsoft.Xna.Framework;7 using Microsoft.Xna.Framework.Input;8 9 5 using Keys = System.Windows.Forms.Keys; 10 6 … … 41 37 private static Dictionary<Keys, Key> registeredKeys; 42 38 private static Dictionary<MouseButtons, Key> registeredMouseButtons; 43 private static int x, y; 39 private static int oldMouseScroll = 0, mouseScrollDelta; 40 private static Point mousePos = Point.Zero; 44 41 45 42 private Control windowControl; … … 87 84 88 85 MouseState state = Mouse.GetState(); 89 x = state.X; 90 y = state.Y; 86 mousePos.X = state.X; 87 mousePos.Y = state.Y; 88 mouseScrollDelta = state.ScrollWheelValue - oldMouseScroll; 89 oldMouseScroll = state.ScrollWheelValue; 91 90 92 91 foreach (Key k in registeredMouseButtons.Values) … … 137 136 } 138 137 139 public static int MouseX { get { return x; } }138 public static int MouseX { get { return mousePos.X; } } 140 139 141 public static int MouseY { get { return y; } } 140 public static int MouseY { get { return mousePos.Y; } } 141 142 public static int MouseScrollDelta { get { return mouseScrollDelta; } } 143 144 public static Point MousePos { get { return mousePos; } } 142 145 } 143 146 } -
2013/30/DenisZ/CastleMaster/CastleMaster/CastleMaster/Program.cs
r4508 r4535 1 using System;2 1 3 2 namespace CastleMaster -
2013/30/DenisZ/CastleMaster/CastleMaster/CastleMaster/Properties/AssemblyInfo.cs
r4508 r4535 1 1 using System.Reflection; 2 using System.Runtime.CompilerServices;3 2 using System.Runtime.InteropServices; 4 3 -
2013/30/DenisZ/CastleMaster/CastleMaster/CastleMaster/World/Level.cs
r4521 r4535 1 using System; 1 using CastleMaster.Entities; 2 using CastleMaster.Entities.TileEntities; 3 using CastleMaster.Graphics; 4 using CastleMaster.Physics; 5 using CastleMaster.World.Tiles; 6 using Microsoft.Xna.Framework; 7 using Microsoft.Xna.Framework.Graphics; 2 8 using System.Collections.Generic; 3 using System.Linq; 4 using System.Text; 5 using CastleMaster.World.Tiles; 6 using CastleMaster.Graphics; 7 using Microsoft.Xna.Framework; 9 using Viewport = CastleMaster.Graphics.Viewport; 8 10 9 11 namespace CastleMaster.World 10 12 { 13 14 public class EntityComprarer : Comparer<Entity> 15 { 16 /// <summary> 17 /// Compares entities between them. 18 /// </summary> 19 /// <param name="e1">Entity 1.</param> 20 /// <param name="e2">Entity 2.</param> 21 /// <returns>-1 = e1 render before e2 (e1 -> e2). +1 = e1 render after e2 (e2 -> e1).</returns> 22 public override int Compare(Entity e1, Entity e2) 23 { 24 BoundingRectangle br1 = e1.BoundingRectangle; 25 BoundingRectangle br2 = e2.BoundingRectangle; 26 27 if (br1.ZFar >= br2.ZNear) 28 { 29 if ((e1.Z + e1.X - e1.RenderOffset.Y) - e1.RenderOffset.Y < (e2.Z + e2.X - e2.RenderOffset.Y) - e2.RenderOffset.Y) return -1; 30 return +1; 31 } 32 if (br1.ZNear <= br2.ZFar) 33 return -1; 34 if (br1.XRight <= br2.XLeft) 35 return -1; 36 if (br1.XLeft >= br2.XRight) 37 return +1; 38 39 return 0; 40 } 41 } 42 11 43 public class Level 12 44 { 13 45 public const int TILE_VOID = 0; 46 public const int UPDATES_IN_TICK = 50; 14 47 protected List<Tile> registeredTiles; 15 48 protected int[] tiles; 16 49 protected byte[] data; 50 51 private List<Entity> entities; 52 private List<TileEntity> tileEntities; 53 private List<Entity>[] entitiesInTiles; 54 private SortedSet<Entity> entitesToRender; 17 55 private int width, height; 18 19 public Level(int width, int height) 20 { 21 this.width = width; 22 this.height = height; 56 protected Texture2D tileMap; 57 private EntityComprarer comparer = new EntityComprarer(); 58 private AnimationHelper waterAnimation = new AnimationHelper(10, 2); 59 60 public Level(Texture2D tileMap) 61 { 62 this.tileMap = tileMap; 63 width = tileMap.Width; 64 height = tileMap.Height; 23 65 24 66 tiles = new int[width * height]; … … 29 71 InitTiles(); 30 72 73 entities = new List<Entity>(); 74 tileEntities = new List<TileEntity>(); 75 entitiesInTiles = new List<Entity>[width * height]; 76 for (int i = 0; i < width * height; i++) 77 entitiesInTiles[i] = new List<Entity>(); 78 entitesToRender = new SortedSet<Entity>(comparer); 79 31 80 InitLevel(); 32 81 } … … 37 86 38 87 public List<Tile> RegisteredTiles { get { return registeredTiles; } } 88 89 public int WaterTimer { get { return waterAnimation.CurrentFrame; } } 39 90 40 91 protected virtual void InitTiles() { } … … 66 117 Tile t = registeredTiles[tiles[tp]]; 67 118 if (t.ID != TILE_VOID) 68 t.Render(renderer, new Vector2((x * Viewport.FLOOR_TILE_WIDTH + (y & 1) * Viewport.X_STEP) * Viewport.ZOOM, (y * Viewport.Y_STEP + Viewport.Y_STEP) * Viewport.ZOOM), xTile, zTile, data[tp]); 119 t.Render(renderer, this, new Vector2((x * Viewport.FLOOR_TILE_WIDTH + (y & 1) * Viewport.X_STEP) * Viewport.ZOOM, (y * Viewport.Y_STEP + Viewport.Y_STEP) * Viewport.ZOOM), xTile, zTile, data[tp]); 120 entitiesInTiles[tp].ForEach(ent => entitesToRender.Add(ent)); 69 121 } 70 122 } … … 74 126 } 75 127 128 public void RenderEntities(Camera camera, RenderHelper renderer) 129 { 130 if (entitesToRender.Count > 0) 131 { 132 renderer.SetOffset(camera); 133 134 foreach (Entity ent in entitesToRender) 135 ent.Render(renderer); 136 137 renderer.SetOffset(); 138 139 entitesToRender.Clear(); 140 } 141 } 142 143 public void Update() 144 { 145 waterAnimation.UpdateStep(); 146 147 for (int i = 0; i < UPDATES_IN_TICK; i++) 148 { 149 int xTile = Game.Random.Next(width); 150 int zTile = Game.Random.Next(height); 151 152 registeredTiles[tiles[xTile + zTile * width]].Update(this, xTile, zTile); 153 154 if (tileEntities.Count > 0) 155 tileEntities[Game.Random.Next(tileEntities.Count)].Update(); 156 } 157 158 foreach (Entity ent in entities) 159 { 160 int xTile_old = (int)(ent.X / Viewport.TILESIZE); 161 int zTile_old = (int)(ent.Z / Viewport.TILESIZE); 162 163 ent.Update(); 164 165 if (ent.Removed) 166 { 167 RemoveEntity(ent); 168 TakeEntity(ent, xTile_old, zTile_old); 169 continue; 170 } 171 172 int xTile = (int)(ent.X / Viewport.TILESIZE); 173 int zTile = (int)(ent.Z / Viewport.TILESIZE); 174 175 if (xTile != xTile_old || zTile != zTile_old) 176 { 177 TakeEntity(ent, xTile_old, zTile_old); 178 InsertEntity(ent, xTile, zTile); 179 } 180 } 181 } 182 76 183 public void SetTile(int tileX, int tileZ, int tileID) 77 184 { … … 96 203 } 97 204 205 public void AddEntity(Entity ent, float xPos, float zPos) 206 { 207 int xTile = (int)(xPos / Viewport.TILESIZE); 208 int zTile = (int)(zPos / Viewport.TILESIZE); 209 210 if (!IsValidPos(xTile, zTile)) return; 211 212 ent.X = xPos; 213 ent.Z = zPos; 214 215 ent.Init(); 216 217 if (typeof(TileEntity).IsAssignableFrom(ent.GetType())) 218 tileEntities.Add((TileEntity)ent); 219 else 220 entities.Add(ent); 221 222 InsertEntity(ent, xTile, zTile); 223 } 224 225 private void InsertEntity(Entity ent, int xTile, int zTile) 226 { 227 entitiesInTiles[xTile + zTile * width].Add(ent); 228 } 229 230 private void TakeEntity(Entity ent, int xTile, int zTile) 231 { 232 entitiesInTiles[xTile + zTile * width].Remove(ent); 233 } 234 235 private void RemoveEntity(Entity ent) 236 { 237 ent.OnRemoved(); 238 239 entities.Remove(ent); 240 241 TakeEntity(ent, (int)(ent.X / Viewport.TILESIZE), (int)(ent.Z / Viewport.TILESIZE)); 242 } 243 98 244 private bool IsValidPos(int tileX, int tileZ) 99 245 { -
2013/30/DenisZ/CastleMaster/CastleMaster/CastleMaster/World/LevelTest.cs
r4521 r4535 1 using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using System.Text; 1 using CastleMaster.Entities.TileEntities; 5 2 using CastleMaster.World.Tiles; 3 using Microsoft.Xna.Framework.Graphics; 6 4 7 5 namespace CastleMaster.World … … 9 7 public class LevelTest : Level 10 8 { 11 private int TILE_ GRASS;9 private int TILE_FLOOR, TILE_WATER; 12 10 13 public LevelTest( int width, int height)14 : base( width, height)11 public LevelTest(Texture2D tileMap) 12 : base(tileMap) 15 13 { 16 14 } … … 18 16 protected override void InitTiles() 19 17 { 20 TILE_GRASS = new TileFloor(this).ID; 18 TILE_FLOOR = new TileFloor(this).ID; 19 TILE_WATER = new TileWater(this).ID; 21 20 } 22 21 23 22 protected override void InitLevel() 24 23 { 25 for (int i = 0; i < Width * Height; i++) 26 tiles[i] = TILE_GRASS; 24 LevelBuilder lb = new LevelBuilder(this, tileMap); 25 26 lb.AddTile(0xFF404040, TILE_FLOOR); 27 lb.AddTile(0xFF0094FF, TILE_WATER); 28 lb.AddTile(0xFF808080, TILE_FLOOR, 1); 29 lb.AddTile(0xFF303030, TILE_FLOOR, 2); 30 lb.AddTile(0xFF202020, TILE_FLOOR, 4); 31 lb.AddTile(0xFF202021, TILE_FLOOR, 5); 32 lb.AddTile(0xFF101010, TILE_FLOOR, 3); 33 lb.AddTile(0xFF0094FF, TILE_WATER, 8); 34 lb.AddTile(0xFF00B200, TILE_FLOOR, 6); 35 lb.AddTile(0xFF00CC00, TILE_FLOOR, 6); 36 lb.AddTile(0xFFFF0000, TILE_FLOOR); 37 lb.AddTile(0xFFFF0001, TILE_FLOOR); 38 lb.AddEntity(0xFFFF6A00, typeof(TileEntityBlock), 0.0F, 0.0F, this, 0, 0); 39 lb.AddEntity(0xFFE55B00, typeof(TileEntityBlock), 0.0F, 0.0F, this, 4, 1); 40 lb.AddEntity(0xFF00B200, typeof(TileEntityBlock), 0.0F, 0.0F, this, 2, 2); 41 lb.AddEntity(0xFF00CC00, typeof(TileEntityBlock), 0.0F, 0.0F, this, 1, 2); 42 lb.AddEntity(0xFF00E500, typeof(TileEntityBlock), 0.0F, 0.0F, this, 0, 2); 43 lb.AddEntity(0xFF00FF00, typeof(TileEntityBlock), 0.0F, 0.0F, this, 6, 0); 44 45 lb.BuildLevel(); 27 46 } 28 47 } -
2013/30/DenisZ/CastleMaster/CastleMaster/CastleMaster/World/Tiles/Tile.cs
r4512 r4535 1 using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using System.Text; 5 using CastleMaster.Graphics; 1 using CastleMaster.Graphics; 6 2 using Microsoft.Xna.Framework; 7 3 … … 22 18 public virtual void Update(Level level, int tileX, int tileZ) { } 23 19 24 public virtual void Render(RenderHelper renderer, Vector2 screenPos, int tileX, int tileZ, byte dataVal) { }20 public virtual void Render(RenderHelper renderer, Level level, Vector2 screenPos, int tileX, int tileZ, byte dataVal) { } 25 21 } 26 22 } -
2013/30/DenisZ/CastleMaster/CastleMaster/CastleMaster/World/Tiles/TileFloor.cs
r4521 r4535 1 using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using System.Text; 5 using CastleMaster.Graphics; 1 using CastleMaster.Graphics; 6 2 using Microsoft.Xna.Framework; 7 3 … … 15 11 } 16 12 17 public override void Render(RenderHelper renderer, Vector2 screenPos, int tileX, int tileZ, byte dataVal)13 public override void Render(RenderHelper renderer, Level level, Vector2 screenPos, int tileX, int tileZ, byte dataVal) 18 14 { 19 renderer.Render(screenPos, 0, 0, Resources.SPRITESHEET_TILES, Viewport.ZOOM);15 renderer.Render(screenPos, dataVal % 8, dataVal / 8, Resources.SPRITESHEET_TILES, Viewport.ZOOM); 20 16 } 21 17 } -
2013/30/DenisZ/CastleMaster/CastleMaster/CastleMasterContent/CastleMasterContent.contentproj
r4508 r4535 137 137 </Compile> 138 138 </ItemGroup> 139 <ItemGroup> 140 <Compile Include="levels\levelTest.png"> 141 <Name>levelTest</Name> 142 <Importer>TextureImporter</Importer> 143 <Processor>TextureProcessor</Processor> 144 </Compile> 145 </ItemGroup> 139 146 <Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\$(XnaFrameworkVersion)\Microsoft.Xna.GameStudio.ContentPipeline.targets" /> 140 147 <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Note: See TracChangeset
for help on using the changeset viewer.