diff --git a/Jumpy.Shared/JumpyGame.cs b/Jumpy.Shared/JumpyGame.cs index eb4b9a6..36d3474 100644 --- a/Jumpy.Shared/JumpyGame.cs +++ b/Jumpy.Shared/JumpyGame.cs @@ -54,6 +54,7 @@ namespace Jumpy { // Called once per game. Loads all game content. protected override void LoadContent() { + Console.WriteLine("LoadContent()"); spriteBatch = new SpriteBatch(GraphicsDevice); font = Content.Load("font"); // TODO: decouple things like Player and World from their textures. @@ -86,6 +87,7 @@ namespace Jumpy { display.SetFullScreen(fullScreen); } + List collisionTargets = world.CollisionTargets(); player.Update(gameTime, gamePad); base.Update(gameTime); @@ -132,6 +134,11 @@ namespace Jumpy { // Draw foreground tiles. world.Draw(spriteBatch); + // Draw debug rects. + foreach (var rect in world.CollisionTargets()) { + DrawRect(spriteBatch, rect, Color.Yellow); + } + // Aaaaand we're done. spriteBatch.End(); diff --git a/Jumpy.Shared/World.cs b/Jumpy.Shared/World.cs index 9dd61f4..8a363fc 100644 --- a/Jumpy.Shared/World.cs +++ b/Jumpy.Shared/World.cs @@ -1,5 +1,6 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using System; using System.Collections.Generic; namespace Jumpy { @@ -20,8 +21,8 @@ namespace Jumpy { this.position = position; } - public Rectangle Position { get; } - public Terrain Terrain { get; } + public Rectangle Position { get { return position; } } + public Terrain Terrain { get { return terrain; } } public void Draw(SpriteBatch spriteBatch) { int size = World.TileSize; @@ -84,5 +85,18 @@ namespace Jumpy { } } } + + public List CollisionTargets() { + var result = new List(); + for (int j = 0; j < height; j++) { + for (int i = 0; i < width; i++) { + var t = tiles[i, j]; + if (t.Terrain != Terrain.Empty) { + result.Add(t.Position); + } + } + } + return result; + } } }