diff options
| author | Starla Insigna <hatkirby@fourisland.com> | 2009-03-17 09:34:18 -0400 |
|---|---|---|
| committer | Starla Insigna <hatkirby@fourisland.com> | 2009-03-17 09:34:18 -0400 |
| commit | 28e41757f11ea216f641b4889bd43be2b6373484 (patch) | |
| tree | 4d29231ca35702afd9e5bfad17b1c170098fc9aa /src/com/fourisland/fourpuzzle/gamestate/mapview/event/SpecialEvent.java | |
| parent | 0a5ace745f171cad0150dbed11ae8febc0e17f27 (diff) | |
| download | fourpuzzle-28e41757f11ea216f641b4889bd43be2b6373484.tar.gz fourpuzzle-28e41757f11ea216f641b4889bd43be2b6373484.tar.bz2 fourpuzzle-28e41757f11ea216f641b4889bd43be2b6373484.zip | |
Engine: Added ShakeScreen() special action
Also implemented F12 to return to the title screen and added a move frequency variable to events that decides how often they move.
Diffstat (limited to 'src/com/fourisland/fourpuzzle/gamestate/mapview/event/SpecialEvent.java')
| -rwxr-xr-x | src/com/fourisland/fourpuzzle/gamestate/mapview/event/SpecialEvent.java | 50 |
1 files changed, 50 insertions, 0 deletions
| diff --git a/src/com/fourisland/fourpuzzle/gamestate/mapview/event/SpecialEvent.java b/src/com/fourisland/fourpuzzle/gamestate/mapview/event/SpecialEvent.java index ca3ba5e..2db33f7 100755 --- a/src/com/fourisland/fourpuzzle/gamestate/mapview/event/SpecialEvent.java +++ b/src/com/fourisland/fourpuzzle/gamestate/mapview/event/SpecialEvent.java | |||
| @@ -16,6 +16,8 @@ import com.fourisland.fourpuzzle.gamestate.mapview.event.specialmove.MoveEventTh | |||
| 16 | import com.fourisland.fourpuzzle.gamestate.mapview.viewpoint.AutomaticViewpoint; | 16 | import com.fourisland.fourpuzzle.gamestate.mapview.viewpoint.AutomaticViewpoint; |
| 17 | import com.fourisland.fourpuzzle.gamestate.mapview.viewpoint.FixedViewpoint; | 17 | import com.fourisland.fourpuzzle.gamestate.mapview.viewpoint.FixedViewpoint; |
| 18 | import com.fourisland.fourpuzzle.gamestate.mapview.viewpoint.MovingViewpoint; | 18 | import com.fourisland.fourpuzzle.gamestate.mapview.viewpoint.MovingViewpoint; |
| 19 | import com.fourisland.fourpuzzle.gamestate.mapview.viewpoint.ShakingViewpoint; | ||
| 20 | import com.fourisland.fourpuzzle.gamestate.mapview.viewpoint.ShakingViewpoint.ShakeSpeed; | ||
| 19 | import com.fourisland.fourpuzzle.gamestate.mapview.viewpoint.Viewpoint; | 21 | import com.fourisland.fourpuzzle.gamestate.mapview.viewpoint.Viewpoint; |
| 20 | import com.fourisland.fourpuzzle.transition.InTransition; | 22 | import com.fourisland.fourpuzzle.transition.InTransition; |
| 21 | import com.fourisland.fourpuzzle.transition.OutTransition; | 23 | import com.fourisland.fourpuzzle.transition.OutTransition; |
| @@ -366,4 +368,52 @@ public class SpecialEvent { | |||
| 366 | throw new InterruptedException(); | 368 | throw new InterruptedException(); |
| 367 | } | 369 | } |
| 368 | 370 | ||
| 371 | /** | ||
| 372 | * Shake the screen like an earthquake | ||
| 373 | * | ||
| 374 | * @param speed How fast the screen should shake | ||
| 375 | * @param length The amount of time (in milliseconds) the shaking should | ||
| 376 | * last | ||
| 377 | * @param block If true, the game will wait for the shaking to complete | ||
| 378 | * before executing any more commands | ||
| 379 | * @throws java.lang.InterruptedException | ||
| 380 | */ | ||
| 381 | public void ShakeScreen(ShakeSpeed speed, int length, final boolean block) throws InterruptedException | ||
| 382 | { | ||
| 383 | Viewpoint viewpoint = mapView.getViewpoint(); | ||
| 384 | final CountDownLatch blocker; | ||
| 385 | |||
| 386 | if (block) | ||
| 387 | { | ||
| 388 | blocker = new CountDownLatch(1); | ||
| 389 | } else { | ||
| 390 | blocker = null; | ||
| 391 | } | ||
| 392 | |||
| 393 | mapView.setViewpoint(new ShakingViewpoint(viewpoint.getX(), viewpoint.getY(), speed, length, new Runnable() { | ||
| 394 | public void run() | ||
| 395 | { | ||
| 396 | if (block) | ||
| 397 | { | ||
| 398 | blocker.countDown(); | ||
| 399 | } else { | ||
| 400 | ResetViewpoint(); | ||
| 401 | } | ||
| 402 | } | ||
| 403 | })); | ||
| 404 | |||
| 405 | if (block) | ||
| 406 | { | ||
| 407 | try | ||
| 408 | { | ||
| 409 | blocker.await(); | ||
| 410 | } catch (InterruptedException ex) | ||
| 411 | { | ||
| 412 | throw ex; | ||
| 413 | } finally { | ||
| 414 | ResetViewpoint(); | ||
| 415 | } | ||
| 416 | } | ||
| 417 | } | ||
| 418 | |||
| 369 | } | 419 | } |
