- 遊ぶためのクラスのスタブを作りました。
- コマンドライン引数で指定したステージを読み込んで自由に走れるようになりました。
- 道路の当たり判定をしていないので、どこでも同じように走れます。
@@ -97,7 +97,7 @@ | ||
97 | 97 | |
98 | 98 | /** |
99 | 99 | * メインメソッドです。 |
100 | - * @param args | |
100 | + * @param args コマンドライン引数 | |
101 | 101 | * @throws UnsupportedLookAndFeelException |
102 | 102 | * @throws IllegalAccessException |
103 | 103 | * @throws InstantiationException |
@@ -328,7 +328,7 @@ | ||
328 | 328 | } |
329 | 329 | if (deleteCheckPoint == null) { |
330 | 330 | for (final Rail rail : stage.getRails()) { |
331 | - if (Util.getFill(rail).contains(mouseLocation.toPoint2D())) { | |
331 | + if (Util.getShape(rail, true).contains(mouseLocation.toPoint2D())) { | |
332 | 332 | deleteRail = rail; |
333 | 333 | break; |
334 | 334 | } |
@@ -343,7 +343,7 @@ | ||
343 | 343 | if (point1.distance(mouseLocation) < minDistance) { |
344 | 344 | temporaryCheckPoint.location = point1; |
345 | 345 | temporaryCheckPoint.angle = rail.angle |
346 | - + (Util.getFill(rail).contains(mouseLocation.toPoint2D()) ? Math.PI : 0); | |
346 | + + (Util.getShape(rail, true).contains(mouseLocation.toPoint2D()) ? Math.PI : 0); | |
347 | 347 | minDistance = point1.distance(mouseLocation); |
348 | 348 | } |
349 | 349 | final Point point2 = Util.getPoint2(rail); |
@@ -351,7 +351,7 @@ | ||
351 | 351 | temporaryCheckPoint.location = point2; |
352 | 352 | temporaryCheckPoint.angle = rail.angle |
353 | 353 | + (rail.isReverse ? -rail.type.getAngle() : rail.type.getAngle()) |
354 | - + (Util.getFill(rail).contains(mouseLocation.toPoint2D()) ? 0 : Math.PI); | |
354 | + + (Util.getShape(rail, true).contains(mouseLocation.toPoint2D()) ? 0 : Math.PI); | |
355 | 355 | minDistance = point2.distance(mouseLocation); |
356 | 356 | } |
357 | 357 | } |
@@ -52,9 +52,10 @@ | ||
52 | 52 | |
53 | 53 | /** |
54 | 54 | * @param rail レール |
55 | - * @return レールの塗りつぶし | |
55 | + * @param isFill 塗りつぶし部かどうか | |
56 | + * @return レールの形 | |
56 | 57 | */ |
57 | - public static Shape getFill(final Rail rail) { | |
58 | + public static Shape getShape(final Rail rail, final boolean isFill) { | |
58 | 59 | final AffineTransform transform = new AffineTransform(); |
59 | 60 | transform.translate(rail.location.getX(), rail.location.getY()); |
60 | 61 | transform.rotate(rail.angle); |
@@ -61,7 +62,7 @@ | ||
61 | 62 | if (rail.isReverse) { |
62 | 63 | transform.scale(1, -1); |
63 | 64 | } |
64 | - return transform.createTransformedShape(rail.type.getFill()); | |
65 | + return transform.createTransformedShape(isFill ? rail.type.getFill() : rail.type.getShape()); | |
65 | 66 | } |
66 | 67 | |
67 | 68 | /** |