diff options
Diffstat (limited to 'src/com/fourisland/fourpuzzle/transition/SquareTransition.java')
-rw-r--r-- | src/com/fourisland/fourpuzzle/transition/SquareTransition.java | 34 |
1 files changed, 24 insertions, 10 deletions
diff --git a/src/com/fourisland/fourpuzzle/transition/SquareTransition.java b/src/com/fourisland/fourpuzzle/transition/SquareTransition.java index d60282d..1d8748a 100644 --- a/src/com/fourisland/fourpuzzle/transition/SquareTransition.java +++ b/src/com/fourisland/fourpuzzle/transition/SquareTransition.java | |||
@@ -7,19 +7,21 @@ package com.fourisland.fourpuzzle.transition; | |||
7 | 7 | ||
8 | import java.awt.Color; | 8 | import java.awt.Color; |
9 | import java.awt.Graphics2D; | 9 | import java.awt.Graphics2D; |
10 | import java.awt.image.BufferedImage; | ||
10 | 11 | ||
11 | /** | 12 | /** |
12 | * | 13 | * |
13 | * @author hatkirby | 14 | * @author hatkirby |
14 | */ | 15 | */ |
15 | public class SquareTransition extends Transition { | 16 | public class SquareTransition implements MultidirectionalTransition { |
16 | 17 | ||
17 | private int tick; | 18 | private int tick; |
18 | public SquareTransition(boolean from) | 19 | private TransitionDirection direction; |
20 | public SquareTransition(TransitionDirection direction) | ||
19 | { | 21 | { |
20 | setDirection(from); | 22 | this.direction = direction; |
21 | 23 | ||
22 | if (from) | 24 | if (direction == TransitionDirection.Out) |
23 | { | 25 | { |
24 | tick = 160; | 26 | tick = 160; |
25 | } else { | 27 | } else { |
@@ -27,24 +29,36 @@ public class SquareTransition extends Transition { | |||
27 | } | 29 | } |
28 | } | 30 | } |
29 | 31 | ||
30 | public void render(Graphics2D g) | 32 | public boolean render(Graphics2D g) |
31 | { | 33 | { |
32 | if (((!getDirection()) && (tick == 0)) || ((getDirection()) && (tick == 160))) | 34 | if (((direction == TransitionDirection.Out) && (tick == 0)) || ((direction == TransitionDirection.In) && (tick == 160))) |
33 | { | 35 | { |
34 | setRunning(false); | 36 | return true; |
35 | return; | ||
36 | } | 37 | } |
37 | 38 | ||
38 | if (getDirection()) | 39 | if (direction == TransitionDirection.In) |
39 | { | 40 | { |
40 | tick+=8; | 41 | tick+=8; |
41 | } else { | 42 | } else { |
42 | tick-=8; | 43 | tick-=8; |
43 | } | 44 | } |
44 | 45 | ||
45 | g.setBackground(Color.BLACK); | 46 | g.setBackground(Color.BLACK); |
46 | g.fillRect(0, 0, 320, 240); | 47 | g.fillRect(0, 0, 320, 240); |
47 | g.setClip(160-tick, 140-tick, tick*2, tick*2-40); | 48 | g.setClip(160-tick, 140-tick, tick*2, tick*2-40); |
49 | |||
50 | return false; | ||
51 | } | ||
52 | |||
53 | public TransitionDirection getDirection() | ||
54 | { | ||
55 | return direction; | ||
56 | } | ||
57 | |||
58 | private BufferedImage preTransition; | ||
59 | public void setPreTransition(BufferedImage preTransition) | ||
60 | { | ||
61 | this.preTransition = preTransition; | ||
48 | } | 62 | } |
49 | 63 | ||
50 | } | 64 | } |