diff options
Diffstat (limited to 'src/com')
-rw-r--r-- | src/com/fourisland/fourpuzzle/Display.java | 38 | ||||
-rw-r--r-- | src/com/fourisland/fourpuzzle/transition/InTransition.java | 1 | ||||
-rw-r--r-- | src/com/fourisland/fourpuzzle/transition/SquareTransition.java | 30 |
3 files changed, 50 insertions, 19 deletions
diff --git a/src/com/fourisland/fourpuzzle/Display.java b/src/com/fourisland/fourpuzzle/Display.java index 4f1e730..3e13aba 100644 --- a/src/com/fourisland/fourpuzzle/Display.java +++ b/src/com/fourisland/fourpuzzle/Display.java | |||
@@ -69,23 +69,30 @@ public class Display { | |||
69 | 69 | ||
70 | Graphics2D g = vImg.createGraphics(); | 70 | Graphics2D g = vImg.createGraphics(); |
71 | 71 | ||
72 | if (transition != null) | 72 | if (transitionRunning) |
73 | { | 73 | { |
74 | if (transition.render(g)) | 74 | Game.getGameState().render(g); |
75 | |||
76 | if (transition != null) | ||
75 | { | 77 | { |
76 | if (startedTransition) | 78 | if (transition.render(g)) |
77 | { | 79 | { |
78 | midTransition = new BufferedImage(Game.WIDTH, Game.HEIGHT, BufferedImage.TYPE_INT_ARGB); | 80 | if (startedTransition) |
79 | midTransition.getGraphics().drawImage(vImg, 0, 0, null); | 81 | { |
80 | } else { | 82 | midTransition = vImg.getSnapshot(); |
81 | midTransition = null; | 83 | } else { |
84 | midTransition = null; | ||
85 | } | ||
86 | |||
87 | transitionWait.countDown(); | ||
82 | } | 88 | } |
83 | 89 | } else { | |
84 | transitionWait.countDown(); | 90 | g.drawImage(midTransition, 0, 0, null); |
85 | } | 91 | } |
92 | } else { | ||
93 | Game.getGameState().render(g); | ||
86 | } | 94 | } |
87 | 95 | ||
88 | Game.getGameState().render(g); | ||
89 | g.dispose(); | 96 | g.dispose(); |
90 | } | 97 | } |
91 | 98 | ||
@@ -94,6 +101,7 @@ public class Display { | |||
94 | private static CountDownLatch transitionWait; | 101 | private static CountDownLatch transitionWait; |
95 | private static boolean transitionRunning = false; | 102 | private static boolean transitionRunning = false; |
96 | private static BufferedImage midTransition = null; | 103 | private static BufferedImage midTransition = null; |
104 | private static BufferedImage postTransition = null; | ||
97 | public static void transition(Transition transition) throws InterruptedException | 105 | public static void transition(Transition transition) throws InterruptedException |
98 | { | 106 | { |
99 | if (transition instanceof MultidirectionalTransition) | 107 | if (transition instanceof MultidirectionalTransition) |
@@ -111,6 +119,10 @@ public class Display { | |||
111 | if (temp.getDirection() == TransitionDirection.In) | 119 | if (temp.getDirection() == TransitionDirection.In) |
112 | { | 120 | { |
113 | temp.setPreTransition(midTransition); | 121 | temp.setPreTransition(midTransition); |
122 | |||
123 | postTransition = new BufferedImage(Game.WIDTH, Game.HEIGHT, BufferedImage.TYPE_INT_ARGB); | ||
124 | Game.getGameState().render(postTransition.createGraphics()); | ||
125 | temp.setPostTransition(postTransition); | ||
114 | } | 126 | } |
115 | } else { | 127 | } else { |
116 | if (startedTransition && !(transition instanceof InTransition)) | 128 | if (startedTransition && !(transition instanceof InTransition)) |
@@ -124,6 +136,10 @@ public class Display { | |||
124 | if (transition instanceof InTransition) | 136 | if (transition instanceof InTransition) |
125 | { | 137 | { |
126 | ((InTransition) transition).setPreTransition(midTransition); | 138 | ((InTransition) transition).setPreTransition(midTransition); |
139 | |||
140 | postTransition = new BufferedImage(Game.WIDTH, Game.HEIGHT, BufferedImage.TYPE_INT_ARGB); | ||
141 | Game.getGameState().render(postTransition.createGraphics()); | ||
142 | ((InTransition) transition).setPostTransition(postTransition); | ||
127 | } | 143 | } |
128 | } | 144 | } |
129 | 145 | ||
@@ -134,6 +150,8 @@ public class Display { | |||
134 | transitionWait = new CountDownLatch(1); | 150 | transitionWait = new CountDownLatch(1); |
135 | transitionWait.await(); | 151 | transitionWait.await(); |
136 | 152 | ||
153 | transition = null; | ||
154 | |||
137 | if (!startedTransition) | 155 | if (!startedTransition) |
138 | { | 156 | { |
139 | transitionRunning = false; | 157 | transitionRunning = false; |
diff --git a/src/com/fourisland/fourpuzzle/transition/InTransition.java b/src/com/fourisland/fourpuzzle/transition/InTransition.java index a326f52..0612bbb 100644 --- a/src/com/fourisland/fourpuzzle/transition/InTransition.java +++ b/src/com/fourisland/fourpuzzle/transition/InTransition.java | |||
@@ -14,5 +14,6 @@ import java.awt.image.BufferedImage; | |||
14 | public interface InTransition extends Transition { | 14 | public interface InTransition extends Transition { |
15 | 15 | ||
16 | public void setPreTransition(BufferedImage preTransition); | 16 | public void setPreTransition(BufferedImage preTransition); |
17 | public void setPostTransition(BufferedImage postTransition); | ||
17 | 18 | ||
18 | } | 19 | } |
diff --git a/src/com/fourisland/fourpuzzle/transition/SquareTransition.java b/src/com/fourisland/fourpuzzle/transition/SquareTransition.java index 1d8748a..fce70d1 100644 --- a/src/com/fourisland/fourpuzzle/transition/SquareTransition.java +++ b/src/com/fourisland/fourpuzzle/transition/SquareTransition.java | |||
@@ -5,6 +5,7 @@ | |||
5 | 5 | ||
6 | package com.fourisland.fourpuzzle.transition; | 6 | package com.fourisland.fourpuzzle.transition; |
7 | 7 | ||
8 | import com.fourisland.fourpuzzle.Game; | ||
8 | import java.awt.Color; | 9 | import java.awt.Color; |
9 | import java.awt.Graphics2D; | 10 | import java.awt.Graphics2D; |
10 | import java.awt.image.BufferedImage; | 11 | import java.awt.image.BufferedImage; |
@@ -31,21 +32,26 @@ public class SquareTransition implements MultidirectionalTransition { | |||
31 | 32 | ||
32 | public boolean render(Graphics2D g) | 33 | public boolean render(Graphics2D g) |
33 | { | 34 | { |
34 | if (((direction == TransitionDirection.Out) && (tick == 0)) || ((direction == TransitionDirection.In) && (tick == 160))) | ||
35 | { | ||
36 | return true; | ||
37 | } | ||
38 | |||
39 | if (direction == TransitionDirection.In) | 35 | if (direction == TransitionDirection.In) |
40 | { | 36 | { |
41 | tick+=8; | 37 | tick+=8; |
38 | |||
39 | g.drawImage(preTransition, 0, 0, null); | ||
40 | g.drawImage(postTransition, 160-tick, 140-tick, tick*2+(160-tick), tick*2-40+(140-tick), 160-tick, 140-tick, tick*2+(160-tick), tick*2-40+(140-tick), null); | ||
42 | } else { | 41 | } else { |
43 | tick-=8; | 42 | tick-=8; |
43 | |||
44 | g.setColor(Color.BLACK); | ||
45 | g.fillRect(0, 0, Game.WIDTH, 160-tick); | ||
46 | g.fillRect(0, 0, 160-tick, Game.HEIGHT); | ||
47 | g.fillRect(tick*2+(160-tick), 0, Game.WIDTH-(tick*2), Game.HEIGHT); | ||
48 | g.fillRect(0, tick*2-40+(140-tick), Game.WIDTH, Game.HEIGHT-(tick*2-40)); | ||
44 | } | 49 | } |
45 | 50 | ||
46 | g.setBackground(Color.BLACK); | 51 | if (((direction == TransitionDirection.Out) && (tick == 0)) || ((direction == TransitionDirection.In) && (tick == 160))) |
47 | g.fillRect(0, 0, 320, 240); | 52 | { |
48 | g.setClip(160-tick, 140-tick, tick*2, tick*2-40); | 53 | return true; |
54 | } | ||
49 | 55 | ||
50 | return false; | 56 | return false; |
51 | } | 57 | } |
@@ -60,5 +66,11 @@ public class SquareTransition implements MultidirectionalTransition { | |||
60 | { | 66 | { |
61 | this.preTransition = preTransition; | 67 | this.preTransition = preTransition; |
62 | } | 68 | } |
69 | |||
70 | private BufferedImage postTransition; | ||
71 | public void setPostTransition(BufferedImage postTransition) | ||
72 | { | ||
73 | this.postTransition = postTransition; | ||
74 | } | ||
63 | 75 | ||
64 | } | 76 | } |