summary refs log tree commit diff stats
path: root/src/com/fourisland/fourpuzzle/gamestate/mapview/event/SpecialEvent.java
diff options
context:
space:
mode:
authorStarla Insigna <hatkirby@fourisland.com>2009-03-17 09:34:18 -0400
committerStarla Insigna <hatkirby@fourisland.com>2009-03-17 09:34:18 -0400
commit28e41757f11ea216f641b4889bd43be2b6373484 (patch)
tree4d29231ca35702afd9e5bfad17b1c170098fc9aa /src/com/fourisland/fourpuzzle/gamestate/mapview/event/SpecialEvent.java
parent0a5ace745f171cad0150dbed11ae8febc0e17f27 (diff)
downloadfourpuzzle-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-xsrc/com/fourisland/fourpuzzle/gamestate/mapview/event/SpecialEvent.java50
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
16import com.fourisland.fourpuzzle.gamestate.mapview.viewpoint.AutomaticViewpoint; 16import com.fourisland.fourpuzzle.gamestate.mapview.viewpoint.AutomaticViewpoint;
17import com.fourisland.fourpuzzle.gamestate.mapview.viewpoint.FixedViewpoint; 17import com.fourisland.fourpuzzle.gamestate.mapview.viewpoint.FixedViewpoint;
18import com.fourisland.fourpuzzle.gamestate.mapview.viewpoint.MovingViewpoint; 18import com.fourisland.fourpuzzle.gamestate.mapview.viewpoint.MovingViewpoint;
19import com.fourisland.fourpuzzle.gamestate.mapview.viewpoint.ShakingViewpoint;
20import com.fourisland.fourpuzzle.gamestate.mapview.viewpoint.ShakingViewpoint.ShakeSpeed;
19import com.fourisland.fourpuzzle.gamestate.mapview.viewpoint.Viewpoint; 21import com.fourisland.fourpuzzle.gamestate.mapview.viewpoint.Viewpoint;
20import com.fourisland.fourpuzzle.transition.InTransition; 22import com.fourisland.fourpuzzle.transition.InTransition;
21import com.fourisland.fourpuzzle.transition.OutTransition; 23import 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}