# HG changeset patch # User alys # Date 2021-04-01 02:12:39 # Node ID ada0c9356941a095b5916556e311e24530ca53de # Parent e7d4484700c1dfb304ead79a65fbf564a5a26bc8 Add Edge drawing functions (from last night). diff --git a/isometric-park-fna/FNAGame.cs b/isometric-park-fna/FNAGame.cs --- a/isometric-park-fna/FNAGame.cs +++ b/isometric-park-fna/FNAGame.cs @@ -738,6 +738,10 @@ Tile.OutlineSquare(batch, 3, 1, Color.Blue, 2); Tile.OutlineSquare(batch, 5, 1, Color.Green, 2); Tile.OutlineSquare(batch, 7, 1, Color.Orange, 2); + Tile.OutlineSquare(batch, 9, 1, Color.Orange, 3); + Tile.OutlineSquare2(batch, 12, 1, Color.Orange, 2); + + Tile.drawEdge(batch, new Edge {Start=new Vector2(14, 1), End= new Vector2(15, 1)}, Color.Orange); #endif diff --git a/isometric-park-fna/Tile.cs b/isometric-park-fna/Tile.cs --- a/isometric-park-fna/Tile.cs +++ b/isometric-park-fna/Tile.cs @@ -5,6 +5,12 @@ namespace isometricparkfna { + + public struct Edge { + public Vector2 Start; + public Vector2 End; + + } public class Tile { //blatantly stolen from XNA resources.com @@ -79,13 +85,79 @@ } + static public void OutlineSquare2(SpriteBatch batch, float x, float y, Color color, int size) + { + Vector2 adjust2 = new Vector2(Tile.TileSpriteWidth / 2, Tile.TileSpriteHeight); //TODO figure out why this second value shouldn't be halved + + //Upper right + //float x = this.mouseGrid.X; + //float y = this.mouseGrid.Y; + // + int size_less_one = size - 1; + + Line.drawLine(batch, + new Vector2(((x - y) * Tile.TileSpriteWidth / 2), (x + y) * Tile.TileSpriteHeight / 2) + adjust2, + //new Vector2(this.squaresAcross * Tile.TileSpriteWidth, (y+1) * Tile.TileSpriteHeight), + new Vector2(((x - y + size_less_one) * Tile.TileSpriteWidth / 2), (x + y + size_less_one) * Tile.TileSpriteHeight / 2) + adjust2, + color, 0.79f); + + //Bottom right + Line.drawLine(batch, + new Vector2(((x + size - y) * Tile.TileSpriteWidth / 2), (x + size_less_one + y) * Tile.TileSpriteHeight / 2) + adjust2, + //new Vector2(this.squaresAcross * Tile.TileSpriteWidth, (y+1) * Tile.TileSpriteHeight), + new Vector2(((x + size - (y + size)) * Tile.TileSpriteWidth / 2), (x + size_less_one + (y + size_less_one)) * Tile.TileSpriteHeight / 2) + adjust2, + color, 0.79f); + //Bottom left + Line.drawLine(batch, + new Vector2(((x - (y + size)) * Tile.TileSpriteWidth / 2), (x + y + size) * Tile.TileSpriteHeight / 2) + adjust2, + //new Vector2(this.squaresAcross * Tile.TileSpriteWidth, (y+1) * Tile.TileSpriteHeight), + new Vector2(((x + size - (y + size)) * Tile.TileSpriteWidth / 2), (x + size + (y + size)) * Tile.TileSpriteHeight / 2) + adjust2, + color, 0.79f); + //Upper left + Line.drawLine(batch, + new Vector2(((x - y) * Tile.TileSpriteWidth / 2), (x + y) * Tile.TileSpriteHeight / 2) + adjust2, + //new Vector2(this.squaresAcross * Tile.TileSpriteWidth, (y+1) * Tile.TileSpriteHeight), + new Vector2(((x - (y + size)) * Tile.TileSpriteWidth / 2), (x + (y + size)) * Tile.TileSpriteHeight / 2) + adjust2, + color, 0.79f); + } + + public static void drawOutline(SpriteBatch batch, Color color) { + Vector2[] squares = {new Vector2(15, 1), new Vector2(15,2)}; + + foreach (Vector2 square in squares) { + } + } + + public static void drawEdge(SpriteBatch batch, Edge edge, Color color) { + + //x = edge.Start.X + //y = edge.Start.y + //y + size = edge.End.y + //x + size = edge.End.x + + Vector2 adjust2 = new Vector2(Tile.TileSpriteWidth / 2, Tile.TileSpriteHeight); //TODO figure out why this second value shouldn't be halved + + Line.drawLine(batch, + new Vector2(((edge.Start.X - edge.Start.Y) * Tile.TileSpriteWidth / 2), (edge.Start.X + edge.Start.Y) * Tile.TileSpriteHeight / 2) + adjust2, + //new Vector2(this.squaresAcross * Tile.TileSpriteWidth, (y+1) * Tile.TileSpriteHeight), + new Vector2(((edge.End.X - edge.End.Y) * Tile.TileSpriteWidth / 2), (edge.End.X + edge.End.Y) * Tile.TileSpriteHeight / 2) + adjust2, + color, 0.79f); + } + + public static void drawEdges(SpriteBatch batch, Edge[] edges, Color color) { + foreach (Edge edge in edges) { + drawEdge(batch, edge, color); + } + } + + public static void drawTileAt(SpriteBatch batch, int x, int y, int tileIndex, int height, float depth) - { + { int height_adjust = 0; if (height > 1) //not sure why this is necessary :/ - { + { height_adjust = height; }