Description:
Add Edge drawing functions (from last night).
Commit status:
[Not Reviewed]
References:
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r153:ada0c9356941 -

@@ -738,6 +738,10
738 738 Tile.OutlineSquare(batch, 3, 1, Color.Blue, 2);
739 739 Tile.OutlineSquare(batch, 5, 1, Color.Green, 2);
740 740 Tile.OutlineSquare(batch, 7, 1, Color.Orange, 2);
741 Tile.OutlineSquare(batch, 9, 1, Color.Orange, 3);
742 Tile.OutlineSquare2(batch, 12, 1, Color.Orange, 2);
743
744 Tile.drawEdge(batch, new Edge {Start=new Vector2(14, 1), End= new Vector2(15, 1)}, Color.Orange);
741 745 #endif
742 746
743 747
@@ -5,6 +5,12
5 5
6 6 namespace isometricparkfna
7 7 {
8
9 public struct Edge {
10 public Vector2 Start;
11 public Vector2 End;
12
13 }
8 14 public class Tile
9 15 {
10 16 //blatantly stolen from XNA resources.com
@@ -79,13 +85,79
79 85 }
80 86
81 87
88 static public void OutlineSquare2(SpriteBatch batch, float x, float y, Color color, int size)
89 {
90 Vector2 adjust2 = new Vector2(Tile.TileSpriteWidth / 2, Tile.TileSpriteHeight); //TODO figure out why this second value shouldn't be halved
91
92 //Upper right
93 //float x = this.mouseGrid.X;
94 //float y = this.mouseGrid.Y;
95 //
96 int size_less_one = size - 1;
97
98 Line.drawLine(batch,
99 new Vector2(((x - y) * Tile.TileSpriteWidth / 2), (x + y) * Tile.TileSpriteHeight / 2) + adjust2,
100 //new Vector2(this.squaresAcross * Tile.TileSpriteWidth, (y+1) * Tile.TileSpriteHeight),
101 new Vector2(((x - y + size_less_one) * Tile.TileSpriteWidth / 2), (x + y + size_less_one) * Tile.TileSpriteHeight / 2) + adjust2,
102 color, 0.79f);
103
104 //Bottom right
105 Line.drawLine(batch,
106 new Vector2(((x + size - y) * Tile.TileSpriteWidth / 2), (x + size_less_one + y) * Tile.TileSpriteHeight / 2) + adjust2,
107 //new Vector2(this.squaresAcross * Tile.TileSpriteWidth, (y+1) * Tile.TileSpriteHeight),
108 new Vector2(((x + size - (y + size)) * Tile.TileSpriteWidth / 2), (x + size_less_one + (y + size_less_one)) * Tile.TileSpriteHeight / 2) + adjust2,
109 color, 0.79f);
110 //Bottom left
111 Line.drawLine(batch,
112 new Vector2(((x - (y + size)) * Tile.TileSpriteWidth / 2), (x + y + size) * Tile.TileSpriteHeight / 2) + adjust2,
113 //new Vector2(this.squaresAcross * Tile.TileSpriteWidth, (y+1) * Tile.TileSpriteHeight),
114 new Vector2(((x + size - (y + size)) * Tile.TileSpriteWidth / 2), (x + size + (y + size)) * Tile.TileSpriteHeight / 2) + adjust2,
115 color, 0.79f);
116 //Upper left
117 Line.drawLine(batch,
118 new Vector2(((x - y) * Tile.TileSpriteWidth / 2), (x + y) * Tile.TileSpriteHeight / 2) + adjust2,
119 //new Vector2(this.squaresAcross * Tile.TileSpriteWidth, (y+1) * Tile.TileSpriteHeight),
120 new Vector2(((x - (y + size)) * Tile.TileSpriteWidth / 2), (x + (y + size)) * Tile.TileSpriteHeight / 2) + adjust2,
121 color, 0.79f);
122 }
123
124 public static void drawOutline(SpriteBatch batch, Color color) {
125 Vector2[] squares = {new Vector2(15, 1), new Vector2(15,2)};
126
127 foreach (Vector2 square in squares) {
128 }
129 }
130
131 public static void drawEdge(SpriteBatch batch, Edge edge, Color color) {
132
133 //x = edge.Start.X
134 //y = edge.Start.y
135 //y + size = edge.End.y
136 //x + size = edge.End.x
137
138 Vector2 adjust2 = new Vector2(Tile.TileSpriteWidth / 2, Tile.TileSpriteHeight); //TODO figure out why this second value shouldn't be halved
139
140 Line.drawLine(batch,
141 new Vector2(((edge.Start.X - edge.Start.Y) * Tile.TileSpriteWidth / 2), (edge.Start.X + edge.Start.Y) * Tile.TileSpriteHeight / 2) + adjust2,
142 //new Vector2(this.squaresAcross * Tile.TileSpriteWidth, (y+1) * Tile.TileSpriteHeight),
143 new Vector2(((edge.End.X - edge.End.Y) * Tile.TileSpriteWidth / 2), (edge.End.X + edge.End.Y) * Tile.TileSpriteHeight / 2) + adjust2,
144 color, 0.79f);
145 }
146
147 public static void drawEdges(SpriteBatch batch, Edge[] edges, Color color) {
148 foreach (Edge edge in edges) {
149 drawEdge(batch, edge, color);
150 }
151 }
152
153
82 154 public static void drawTileAt(SpriteBatch batch, int x, int y, int tileIndex, int height, float depth)
83 {
155 {
84 156
85 157 int height_adjust = 0;
86 158
87 159 if (height > 1) //not sure why this is necessary :/
88 {
160 {
89 161 height_adjust = height;
90 162 }
91 163
You need to be logged in to leave comments. Login now