summary refs log tree commit diff stats
path: root/src/com
diff options
context:
space:
mode:
Diffstat (limited to 'src/com')
-rw-r--r--src/com/fourisland/fourpuzzle/Display.java10
-rw-r--r--src/com/fourisland/fourpuzzle/transition/DoNotEraseTransition.java6
-rw-r--r--src/com/fourisland/fourpuzzle/transition/InTransition.java1
-rw-r--r--src/com/fourisland/fourpuzzle/transition/SlideTransition.java140
-rw-r--r--src/com/fourisland/fourpuzzle/transition/SquareTransition.java3
-rw-r--r--src/com/fourisland/fourpuzzle/transition/Transition.java2
6 files changed, 159 insertions, 3 deletions
diff --git a/src/com/fourisland/fourpuzzle/Display.java b/src/com/fourisland/fourpuzzle/Display.java index 3e13aba..f513d31 100644 --- a/src/com/fourisland/fourpuzzle/Display.java +++ b/src/com/fourisland/fourpuzzle/Display.java
@@ -123,6 +123,10 @@ public class Display {
123 postTransition = new BufferedImage(Game.WIDTH, Game.HEIGHT, BufferedImage.TYPE_INT_ARGB); 123 postTransition = new BufferedImage(Game.WIDTH, Game.HEIGHT, BufferedImage.TYPE_INT_ARGB);
124 Game.getGameState().render(postTransition.createGraphics()); 124 Game.getGameState().render(postTransition.createGraphics());
125 temp.setPostTransition(postTransition); 125 temp.setPostTransition(postTransition);
126 } else {
127 BufferedImage preTransition = new BufferedImage(Game.WIDTH, Game.HEIGHT, BufferedImage.TYPE_INT_ARGB);
128 Game.getGameState().render(preTransition.createGraphics());
129 temp.setPreTransition(preTransition);
126 } 130 }
127 } else { 131 } else {
128 if (startedTransition && !(transition instanceof InTransition)) 132 if (startedTransition && !(transition instanceof InTransition))
@@ -135,11 +139,15 @@ public class Display {
135 139
136 if (transition instanceof InTransition) 140 if (transition instanceof InTransition)
137 { 141 {
138 ((InTransition) transition).setPreTransition(midTransition); 142 transition.setPreTransition(midTransition);
139 143
140 postTransition = new BufferedImage(Game.WIDTH, Game.HEIGHT, BufferedImage.TYPE_INT_ARGB); 144 postTransition = new BufferedImage(Game.WIDTH, Game.HEIGHT, BufferedImage.TYPE_INT_ARGB);
141 Game.getGameState().render(postTransition.createGraphics()); 145 Game.getGameState().render(postTransition.createGraphics());
142 ((InTransition) transition).setPostTransition(postTransition); 146 ((InTransition) transition).setPostTransition(postTransition);
147 } else {
148 BufferedImage preTransition = new BufferedImage(Game.WIDTH, Game.HEIGHT, BufferedImage.TYPE_INT_ARGB);
149 Game.getGameState().render(preTransition.createGraphics());
150 transition.setPreTransition(preTransition);
143 } 151 }
144 } 152 }
145 153
diff --git a/src/com/fourisland/fourpuzzle/transition/DoNotEraseTransition.java b/src/com/fourisland/fourpuzzle/transition/DoNotEraseTransition.java index 63c3ea3..ccdf3f2 100644 --- a/src/com/fourisland/fourpuzzle/transition/DoNotEraseTransition.java +++ b/src/com/fourisland/fourpuzzle/transition/DoNotEraseTransition.java
@@ -6,6 +6,7 @@
6package com.fourisland.fourpuzzle.transition; 6package com.fourisland.fourpuzzle.transition;
7 7
8import java.awt.Graphics2D; 8import java.awt.Graphics2D;
9import java.awt.image.BufferedImage;
9 10
10/** 11/**
11 * 12 *
@@ -18,4 +19,9 @@ public class DoNotEraseTransition implements OutTransition {
18 return true; 19 return true;
19 } 20 }
20 21
22 public void setPreTransition(BufferedImage preTransition)
23 {
24 // Do nothing
25 }
26
21} 27}
diff --git a/src/com/fourisland/fourpuzzle/transition/InTransition.java b/src/com/fourisland/fourpuzzle/transition/InTransition.java index 0612bbb..6c07aa5 100644 --- a/src/com/fourisland/fourpuzzle/transition/InTransition.java +++ b/src/com/fourisland/fourpuzzle/transition/InTransition.java
@@ -13,7 +13,6 @@ import java.awt.image.BufferedImage;
13 */ 13 */
14public interface InTransition extends Transition { 14public interface InTransition extends Transition {
15 15
16 public void setPreTransition(BufferedImage preTransition);
17 public void setPostTransition(BufferedImage postTransition); 16 public void setPostTransition(BufferedImage postTransition);
18 17
19} 18}
diff --git a/src/com/fourisland/fourpuzzle/transition/SlideTransition.java b/src/com/fourisland/fourpuzzle/transition/SlideTransition.java new file mode 100644 index 0000000..e40ad99 --- /dev/null +++ b/src/com/fourisland/fourpuzzle/transition/SlideTransition.java
@@ -0,0 +1,140 @@
1/*
2 * To change this template, choose Tools | Templates
3 * and open the template in the editor.
4 */
5
6package com.fourisland.fourpuzzle.transition;
7
8import com.fourisland.fourpuzzle.Direction;
9import com.fourisland.fourpuzzle.Game;
10import java.awt.Color;
11import java.awt.Graphics2D;
12import java.awt.image.BufferedImage;
13
14/**
15 *
16 * @author hatkirby
17 */
18public class SlideTransition implements MultidirectionalTransition {
19
20 TransitionDirection direction;
21 Direction d;
22 public SlideTransition(TransitionDirection direction, Direction d)
23 {
24 this.direction = direction;
25 this.d = d;
26
27 if (d == Direction.North)
28 {
29 max = -(Game.HEIGHT);
30 way = SlideDirection.UpOrDown;
31 } else if (d == Direction.West)
32 {
33 max = -(Game.WIDTH);
34 way = SlideDirection.SideToSide;
35 } else if (d == Direction.South)
36 {
37 max = Game.HEIGHT;
38 way = SlideDirection.UpOrDown;
39 } else if (d == Direction.East)
40 {
41 max = Game.WIDTH;
42 way = SlideDirection.SideToSide;
43 }
44
45 wait = Math.round(max / (Game.FPS/2));
46 }
47
48 public TransitionDirection getDirection()
49 {
50 return direction;
51 }
52
53 int tick;
54 int wait;
55 int max;
56 SlideDirection way;
57 public boolean render(Graphics2D g)
58 {
59 if (max > 0)
60 {
61 tick = Math.min(tick + wait, max);
62 } else {
63 tick = Math.max(tick + wait, max);
64 }
65
66 if (direction == TransitionDirection.Out)
67 {
68 g.setColor(Color.BLACK);
69
70 if (way == SlideDirection.SideToSide)
71 {
72 g.drawImage(preTransition, tick, 0, null);
73
74 if (max > 0)
75 {
76 g.fillRect(0, 0, tick, Game.HEIGHT);
77 } else {
78 g.fillRect(Game.WIDTH+tick, 0, -tick, Game.HEIGHT);
79 }
80 } else {
81 g.drawImage(preTransition, 0, tick, null);
82
83 if (max > 0)
84 {
85 g.fillRect(0, 0, Game.WIDTH, tick);
86 } else {
87 g.fillRect(0, Game.HEIGHT+tick, Game.WIDTH, -tick);
88 }
89 }
90 } else if (direction == TransitionDirection.In)
91 {
92 if (way == SlideDirection.SideToSide)
93 {
94 g.drawImage(preTransition, tick, 0, null);
95
96 if (max > 0)
97 {
98 g.drawImage(postTransition, tick - Game.WIDTH, 0, null);
99 } else {
100 g.drawImage(postTransition, Game.WIDTH + tick, 0, null);
101 }
102 } else {
103 g.drawImage(preTransition, 0, tick, null);
104
105 if (max > 0)
106 {
107 g.drawImage(postTransition, 0, tick - Game.HEIGHT, null);
108 } else {
109 g.drawImage(postTransition, 0, Game.HEIGHT + tick, null);
110 }
111 }
112 }
113
114 if (tick == max)
115 {
116 return true;
117 }
118
119 return false;
120 }
121
122 private BufferedImage preTransition;
123 public void setPreTransition(BufferedImage preTransition)
124 {
125 this.preTransition = preTransition;
126 }
127
128 private BufferedImage postTransition;
129 public void setPostTransition(BufferedImage postTransition)
130 {
131 this.postTransition = postTransition;
132 }
133
134 private enum SlideDirection
135 {
136 SideToSide,
137 UpOrDown
138 }
139
140}
diff --git a/src/com/fourisland/fourpuzzle/transition/SquareTransition.java b/src/com/fourisland/fourpuzzle/transition/SquareTransition.java index fce70d1..8a74176 100644 --- a/src/com/fourisland/fourpuzzle/transition/SquareTransition.java +++ b/src/com/fourisland/fourpuzzle/transition/SquareTransition.java
@@ -32,11 +32,12 @@ public class SquareTransition implements MultidirectionalTransition {
32 32
33 public boolean render(Graphics2D g) 33 public boolean render(Graphics2D g)
34 { 34 {
35 g.drawImage(preTransition, 0, 0, null);
36
35 if (direction == TransitionDirection.In) 37 if (direction == TransitionDirection.In)
36 { 38 {
37 tick+=8; 39 tick+=8;
38 40
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); 41 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);
41 } else { 42 } else {
42 tick-=8; 43 tick-=8;
diff --git a/src/com/fourisland/fourpuzzle/transition/Transition.java b/src/com/fourisland/fourpuzzle/transition/Transition.java index 5b4dbe8..445d75d 100644 --- a/src/com/fourisland/fourpuzzle/transition/Transition.java +++ b/src/com/fourisland/fourpuzzle/transition/Transition.java
@@ -6,6 +6,7 @@
6package com.fourisland.fourpuzzle.transition; 6package com.fourisland.fourpuzzle.transition;
7 7
8import java.awt.Graphics2D; 8import java.awt.Graphics2D;
9import java.awt.image.BufferedImage;
9 10
10/** 11/**
11 * 12 *
@@ -21,4 +22,5 @@ public interface Transition {
21 */ 22 */
22 public boolean render(Graphics2D g); 23 public boolean render(Graphics2D g);
23 24
25 public void setPreTransition(BufferedImage preTransition);
24} \ No newline at end of file 26} \ No newline at end of file