diff options
author | Starla Insigna <hatkirby@fourisland.com> | 2009-01-30 15:20:40 -0500 |
---|---|---|
committer | Starla Insigna <hatkirby@fourisland.com> | 2009-01-30 15:20:40 -0500 |
commit | f2738dc2e06f172a6db0822d4f94ccdcd6b52da8 (patch) | |
tree | cc317672794472243251d51154d4b9a8f680b15f /src | |
parent | 000384f5921bad138b77870fb6381fea5ac4d38b (diff) | |
download | fourpuzzle-f2738dc2e06f172a6db0822d4f94ccdcd6b52da8.tar.gz fourpuzzle-f2738dc2e06f172a6db0822d4f94ccdcd6b52da8.tar.bz2 fourpuzzle-f2738dc2e06f172a6db0822d4f94ccdcd6b52da8.zip |
Fixed AutomaticViewpoint cache issue
Previously, heroLoc wasn't a defensive copy of HeroEvent.getLocation(), it was HeroEvent.getLocation(). As of such, the condition that they were inequal always failed. However, a typo in the condition (leaving out the exclamation point) led us to believe it was working fine when in fact, AutomaticViewpoint was recalculating the viewpoint every tick instead of everytime the hero moves. Now it only refreshes when the hero moves or is moving. Also cleared up an ambiguous comment in SpecialEvent's PanViewpoint's JavaDoc.
Diffstat (limited to 'src')
-rw-r--r-- | src/com/fourisland/fourpuzzle/gamestate/mapview/event/SpecialEvent.java | 4 | ||||
-rw-r--r-- | src/com/fourisland/fourpuzzle/gamestate/mapview/viewpoint/AutomaticViewpoint.java | 11 |
2 files changed, 8 insertions, 7 deletions
diff --git a/src/com/fourisland/fourpuzzle/gamestate/mapview/event/SpecialEvent.java b/src/com/fourisland/fourpuzzle/gamestate/mapview/event/SpecialEvent.java index 342b65f..43cf626 100644 --- a/src/com/fourisland/fourpuzzle/gamestate/mapview/event/SpecialEvent.java +++ b/src/com/fourisland/fourpuzzle/gamestate/mapview/event/SpecialEvent.java | |||
@@ -188,8 +188,8 @@ public class SpecialEvent { | |||
188 | /** | 188 | /** |
189 | * Pans the viewpoint the the specified tile location | 189 | * Pans the viewpoint the the specified tile location |
190 | * | 190 | * |
191 | * @param x The x coordinate of the tile to pan to | 191 | * @param x The x coordinate of the tile in the top-left corner to pan to |
192 | * @param y The y coordinate of the tile to pan to | 192 | * @param y The y coordinate of the tile in the top-left corner to pan to |
193 | * @param length How long (in milliseconds) it will take to pan | 193 | * @param length How long (in milliseconds) it will take to pan |
194 | * @param block If true, the game will wait for the pan to complete | 194 | * @param block If true, the game will wait for the pan to complete |
195 | * before executing any more commands | 195 | * before executing any more commands |
diff --git a/src/com/fourisland/fourpuzzle/gamestate/mapview/viewpoint/AutomaticViewpoint.java b/src/com/fourisland/fourpuzzle/gamestate/mapview/viewpoint/AutomaticViewpoint.java index fbd7e03..1f8a796 100644 --- a/src/com/fourisland/fourpuzzle/gamestate/mapview/viewpoint/AutomaticViewpoint.java +++ b/src/com/fourisland/fourpuzzle/gamestate/mapview/viewpoint/AutomaticViewpoint.java | |||
@@ -17,21 +17,22 @@ import java.awt.Point; | |||
17 | public class AutomaticViewpoint implements Viewpoint { | 17 | public class AutomaticViewpoint implements Viewpoint { |
18 | 18 | ||
19 | private Map map; | 19 | private Map map; |
20 | private Point heroLoc; | 20 | private Point heroLoc = new Point(); |
21 | private Point viewpoint; | 21 | private Point viewpoint; |
22 | 22 | ||
23 | public AutomaticViewpoint(Map map) | 23 | public AutomaticViewpoint(Map map) |
24 | { | 24 | { |
25 | this.map = map; | 25 | this.map = map; |
26 | heroLoc = Game.getHeroEvent().getLocation(); | 26 | |
27 | refresh(); | 27 | refresh(); |
28 | } | 28 | } |
29 | 29 | ||
30 | private void refresh() | 30 | private void refresh() |
31 | { | 31 | { |
32 | int x,y; | 32 | int x,y; |
33 | |||
33 | HeroEvent hero = Game.getHeroEvent(); | 34 | HeroEvent hero = Game.getHeroEvent(); |
34 | heroLoc = hero.getLocation(); | 35 | heroLoc.setLocation(hero.getLocation()); |
35 | 36 | ||
36 | Point endLoc = new Point(hero.getLocation()); | 37 | Point endLoc = new Point(hero.getLocation()); |
37 | if (hero.isMoving()) | 38 | if (hero.isMoving()) |
@@ -76,7 +77,7 @@ public class AutomaticViewpoint implements Viewpoint { | |||
76 | 77 | ||
77 | public int getX() | 78 | public int getX() |
78 | { | 79 | { |
79 | if (Game.getHeroEvent().getLocation().equals(heroLoc)) | 80 | if (!Game.getHeroEvent().getLocation().equals(heroLoc) || Game.getHeroEvent().isMoving()) |
80 | { | 81 | { |
81 | refresh(); | 82 | refresh(); |
82 | } | 83 | } |
@@ -86,7 +87,7 @@ public class AutomaticViewpoint implements Viewpoint { | |||
86 | 87 | ||
87 | public int getY() | 88 | public int getY() |
88 | { | 89 | { |
89 | if (!Game.getHeroEvent().getLocation().equals(heroLoc)) | 90 | if (!Game.getHeroEvent().getLocation().equals(heroLoc) || Game.getHeroEvent().isMoving()) |
90 | { | 91 | { |
91 | refresh(); | 92 | refresh(); |
92 | } | 93 | } |