diff options
| author | Starla Insigna <hatkirby@fourisland.com> | 2009-01-30 13:47:36 -0500 |
|---|---|---|
| committer | Starla Insigna <hatkirby@fourisland.com> | 2009-01-30 13:47:36 -0500 |
| commit | bb4a7e26902fd448ec7e041a7373cc30abb8feba (patch) | |
| tree | 02b8e52f1aa98388fd311b8c17bf391a452bd7f9 | |
| parent | aa3d2a1e1d13b04a8c5801629e077668214bc3ff (diff) | |
| download | fourpuzzle-bb4a7e26902fd448ec7e041a7373cc30abb8feba.tar.gz fourpuzzle-bb4a7e26902fd448ec7e041a7373cc30abb8feba.tar.bz2 fourpuzzle-bb4a7e26902fd448ec7e041a7373cc30abb8feba.zip | |
Fixed scrolling issues
| -rw-r--r-- | src/com/fourisland/fourpuzzle/gamestate/mapview/MapViewGameState.java | 31 |
1 files changed, 20 insertions, 11 deletions
| diff --git a/src/com/fourisland/fourpuzzle/gamestate/mapview/MapViewGameState.java b/src/com/fourisland/fourpuzzle/gamestate/mapview/MapViewGameState.java index dbc8aca..e4ecf44 100644 --- a/src/com/fourisland/fourpuzzle/gamestate/mapview/MapViewGameState.java +++ b/src/com/fourisland/fourpuzzle/gamestate/mapview/MapViewGameState.java | |||
| @@ -20,6 +20,7 @@ import com.fourisland.fourpuzzle.gamestate.mapview.event.specialmove.MoveEventTh | |||
| 20 | import com.fourisland.fourpuzzle.util.Functions; | 20 | import com.fourisland.fourpuzzle.util.Functions; |
| 21 | import com.fourisland.fourpuzzle.util.ResourceNotFoundException; | 21 | import com.fourisland.fourpuzzle.util.ResourceNotFoundException; |
| 22 | import java.awt.Graphics2D; | 22 | import java.awt.Graphics2D; |
| 23 | import java.awt.Point; | ||
| 23 | import java.awt.event.KeyEvent; | 24 | import java.awt.event.KeyEvent; |
| 24 | import java.awt.image.BufferedImage; | 25 | import java.awt.image.BufferedImage; |
| 25 | import java.util.logging.Level; | 26 | import java.util.logging.Level; |
| @@ -164,18 +165,26 @@ public class MapViewGameState implements GameState { | |||
| 164 | 165 | ||
| 165 | public void render(Graphics2D g) | 166 | public void render(Graphics2D g) |
| 166 | { | 167 | { |
| 167 | /* TODO Fix viewpoint scrolling code. Currently, when the Hero moves | ||
| 168 | * South or East across the scroll barrier, it warps reality a little, | ||
| 169 | * while the other two directions scroll fine. | ||
| 170 | */ | ||
| 171 | |||
| 172 | int x,y; | 168 | int x,y; |
| 173 | HeroEvent hero = Game.getHeroEvent(); | 169 | HeroEvent hero = Game.getHeroEvent(); |
| 174 | if (hero.getLocation().x > 10) | 170 | Point origLoc = hero.getLocation(); |
| 171 | Point endLoc = new Point(hero.getLocation()); | ||
| 172 | if (hero.isMoving()) | ||
| 173 | { | ||
| 174 | switch (hero.getDirection()) | ||
| 175 | { | ||
| 176 | case North: endLoc.translate(0, -1); break; | ||
| 177 | case West: endLoc.translate(-1, 0); break; | ||
| 178 | case South: endLoc.translate(0, 1); break; | ||
| 179 | case East: endLoc.translate(1, 0); break; | ||
| 180 | } | ||
| 181 | } | ||
| 182 | |||
| 183 | if (Math.max(endLoc.x,origLoc.x) > 10) | ||
| 175 | { | 184 | { |
| 176 | if (hero.getLocation().x < (currentMap.getSize().width - 9)) | 185 | if (Math.max(endLoc.x,origLoc.x) < (currentMap.getSize().width - 9)) |
| 177 | { | 186 | { |
| 178 | x = (hero.getLocation().x - 10) * 16; | 187 | x = (origLoc.x - 10) * 16; |
| 179 | x += hero.getMovingX(); | 188 | x += hero.getMovingX(); |
| 180 | } else { | 189 | } else { |
| 181 | x = (currentMap.getSize().width - 20) * 16; | 190 | x = (currentMap.getSize().width - 20) * 16; |
| @@ -184,11 +193,11 @@ public class MapViewGameState implements GameState { | |||
| 184 | x = 0; | 193 | x = 0; |
| 185 | } | 194 | } |
| 186 | 195 | ||
| 187 | if (hero.getLocation().y > 7) | 196 | if (Math.max(endLoc.y,origLoc.y) > 7) |
| 188 | { | 197 | { |
| 189 | if (hero.getLocation().y < (currentMap.getSize().height - 7)) | 198 | if (Math.max(endLoc.y,origLoc.y) < (currentMap.getSize().height - 7)) |
| 190 | { | 199 | { |
| 191 | y = (hero.getLocation().y - 7) * 16; | 200 | y = (origLoc.y - 7) * 16; |
| 192 | y += hero.getMovingY(); | 201 | y += hero.getMovingY(); |
| 193 | } else { | 202 | } else { |
| 194 | y = (currentMap.getSize().height - 15) * 16; | 203 | y = (currentMap.getSize().height - 15) * 16; |
