Mercurial > hg > ristipolku
comparison game/Engine.java @ 40:a69103644bf6
Cleanups.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Fri, 18 Feb 2011 23:34:47 +0200 |
parents | e682b623aea9 |
children | a5fd4f74a767 |
comparison
equal
deleted
inserted
replaced
39:e682b623aea9 | 40:a69103644bf6 |
---|---|
33 } | 33 } |
34 | 34 |
35 public void print() | 35 public void print() |
36 { | 36 { |
37 System.out.print("PathInfo: inP="+in+", inX="+inX+", inY="+inY+"\n"); | 37 System.out.print("PathInfo: inP="+in+", inX="+inX+", inY="+inY+"\n"); |
38 System.out.print(" outP="+out+", outX="+outX+", outY="+outY+"\n"); | 38 System.out.print(" outP="+out+", outX="+outX+", outY="+outY+"\n\n"); |
39 } | 39 } |
40 } | 40 } |
41 | 41 |
42 /* | 42 /* |
43 class AnimatedElement | 43 class AnimatedElement |
198 { | 198 { |
199 // Mark, if needed | 199 // Mark, if needed |
200 if (mark) | 200 if (mark) |
201 { | 201 { |
202 curr.setType(PieceType.LOCKED); | 202 curr.setType(PieceType.LOCKED); |
203 curr.setActiveConnection(point); | 203 curr.setConnectionState(curr.getRotatedPoint(point), true); |
204 } | 204 } |
205 | 205 |
206 // Get next piece | 206 // Get next piece |
207 point = curr.getConnection(point); | 207 point = curr.getConnection(curr.getRotatedPoint(point)); |
208 switch (point) | 208 switch (point) |
209 { | 209 { |
210 case 0: y--; point = 5; break; | 210 case 0: y--; point = 5; break; |
211 case 1: y--; point = 4; break; | 211 case 1: y--; point = 4; break; |
212 | 212 |
235 public void pieceFinishTurn() | 235 public void pieceFinishTurn() |
236 { | 236 { |
237 // Do we have a piece? | 237 // Do we have a piece? |
238 if (current != null) | 238 if (current != null) |
239 { | 239 { |
240 // Yes, place and lock it | 240 // Yes, start resolving path to next piece placement |
241 current.setType(PieceType.LOCKED); | |
242 PathInfo i = resolvePath(moveX, moveY, movePoint, true); | 241 PathInfo i = resolvePath(moveX, moveY, movePoint, true); |
243 | 242 |
244 if (i != null) | 243 if (i != null) |
245 { | 244 { |
246 System.out.print("moveX="+moveX+", moveY="+moveY+", movePoint="+movePoint+"\n"); | |
247 i.print(); | |
248 moveX = i.outX; | 245 moveX = i.outX; |
249 moveY = i.outY; | 246 moveY = i.outY; |
250 movePoint = i.out; | 247 movePoint = i.out; |
251 } | 248 } |
252 } | 249 } |
263 else | 260 else |
264 { | 261 { |
265 // Resolve path | 262 // Resolve path |
266 PathInfo i = resolvePath(moveX, moveY, movePoint, true); | 263 PathInfo i = resolvePath(moveX, moveY, movePoint, true); |
267 if (i != null) | 264 if (i != null) |
265 { | |
266 // Path found, place the piece | |
268 board[moveX][moveY] = current; | 267 board[moveX][moveY] = current; |
268 } | |
269 else | 269 else |
270 { | 270 { |
271 // Path ended up center/gameboard walls - it's game over, man | 271 // Path ended up center/gameboard walls - it's game over, man |
272 System.out.print("pieceFinishTurn(): Game Over!\n"); | 272 System.out.print("pieceFinishTurn(): Game Over!\n"); |
273 flagGameOver = true; | 273 flagGameOver = true; |