diff options
author | Starla Insigna <hatkirby@fourisland.com> | 2009-02-12 16:36:07 -0500 |
---|---|---|
committer | Starla Insigna <hatkirby@fourisland.com> | 2009-02-12 16:36:07 -0500 |
commit | bbf294dbf6b552751e5d9f3fb66188bd1bee724b (patch) | |
tree | 1e29d91a6e8a3b9d26ec874169de85928d4ec56f /src/com/fourisland/fourpuzzle/gamestate | |
parent | 3cd96daaf22236e4eb15c6422f772abf08351023 (diff) | |
download | fourpuzzle-bbf294dbf6b552751e5d9f3fb66188bd1bee724b.tar.gz fourpuzzle-bbf294dbf6b552751e5d9f3fb66188bd1bee724b.tar.bz2 fourpuzzle-bbf294dbf6b552751e5d9f3fb66188bd1bee724b.zip |
Engine: Wrote Message System
MessageWindow now has a static method run by SpecialEvent that triggers the message box. This method blocks until the message is complete and renders via Display's new feature. The message box also now features the "next" arrow and the letters gradually appear. Display has also been re-worked to have a list of a new interface called Renderable, which is any object that can be rendered. Such objects (such as MessageWindow) can register to Display, which will render them onto the game frame after the GameState has been rendered. Closes #5.
Diffstat (limited to 'src/com/fourisland/fourpuzzle/gamestate')
4 files changed, 11 insertions, 34 deletions
diff --git a/src/com/fourisland/fourpuzzle/gamestate/GameState.java b/src/com/fourisland/fourpuzzle/gamestate/GameState.java index de4d7de..e7bd783 100755 --- a/src/com/fourisland/fourpuzzle/gamestate/GameState.java +++ b/src/com/fourisland/fourpuzzle/gamestate/GameState.java | |||
@@ -5,30 +5,18 @@ | |||
5 | 5 | ||
6 | package com.fourisland.fourpuzzle.gamestate; | 6 | package com.fourisland.fourpuzzle.gamestate; |
7 | 7 | ||
8 | import java.awt.Graphics2D; | 8 | import com.fourisland.fourpuzzle.util.Renderable; |
9 | 9 | ||
10 | /** | 10 | /** |
11 | * | 11 | * |
12 | * @author hatkirby | 12 | * @author hatkirby |
13 | */ | 13 | */ |
14 | public interface GameState { | 14 | public interface GameState extends Renderable { |
15 | 15 | ||
16 | public void initalize(); | 16 | public void initalize(); |
17 | public void deinitalize(); | 17 | public void deinitalize(); |
18 | 18 | ||
19 | public void processInput(); | 19 | public void processInput(); |
20 | public void doGameCycle(); | 20 | public void doGameCycle(); |
21 | public void render(Graphics2D g); | ||
22 | 21 | ||
23 | } | 22 | } \ No newline at end of file |
24 | |||
25 | /* | ||
26 | TitleScreen | ||
27 | MapView | ||
28 | Battle | ||
29 | GameOver | ||
30 | Menu | ||
31 | LoadFile | ||
32 | SaveFile | ||
33 | Transition | ||
34 | */ \ No newline at end of file | ||
diff --git a/src/com/fourisland/fourpuzzle/gamestate/TitleScreenGameState.java b/src/com/fourisland/fourpuzzle/gamestate/TitleScreenGameState.java index 272c4f0..d5b4f90 100755 --- a/src/com/fourisland/fourpuzzle/gamestate/TitleScreenGameState.java +++ b/src/com/fourisland/fourpuzzle/gamestate/TitleScreenGameState.java | |||
@@ -27,20 +27,20 @@ import java.util.Arrays; | |||
27 | public class TitleScreenGameState implements GameState { | 27 | public class TitleScreenGameState implements GameState { |
28 | 28 | ||
29 | ChoiceWindow choices; | 29 | ChoiceWindow choices; |
30 | int wx, wy; | ||
31 | 30 | ||
32 | public void initalize() | 31 | public void initalize() |
33 | { | 32 | { |
34 | Audio.playMusic(Database.getMusic(Music.Title)); | 33 | Audio.playMusic(Database.getMusic(Music.Title)); |
35 | 34 | ||
36 | choices = new ChoiceWindow(Arrays.asList(Database.getVocab(Vocabulary.NewGame), Database.getVocab(Vocabulary.LoadGame), Database.getVocab(Vocabulary.EndGame)), true); | 35 | choices = new ChoiceWindow(Arrays.asList(Database.getVocab(Vocabulary.NewGame), Database.getVocab(Vocabulary.LoadGame), Database.getVocab(Vocabulary.EndGame)), true, ChoiceWindow.ChoiceWindowLocation.BottomLeft); |
37 | wx = (Game.WIDTH/5)-(choices.getWidth()/2); | 36 | Display.registerRenderable(choices); |
38 | wy = (Game.HEIGHT/4*3)-(choices.getHeight()/2); | ||
39 | } | 37 | } |
40 | 38 | ||
41 | public void deinitalize() | 39 | public void deinitalize() |
42 | { | 40 | { |
43 | Audio.stopMusic(); | 41 | Audio.stopMusic(); |
42 | |||
43 | Display.unregisterRenderable(choices); | ||
44 | } | 44 | } |
45 | 45 | ||
46 | PauseTimer pt = new PauseTimer(0); | 46 | PauseTimer pt = new PauseTimer(0); |
@@ -112,7 +112,6 @@ public class TitleScreenGameState implements GameState { | |||
112 | public void render(Graphics2D g) | 112 | public void render(Graphics2D g) |
113 | { | 113 | { |
114 | g.drawImage(ObjectLoader.getImage("Picture", "Title"), 0, 0, null); | 114 | g.drawImage(ObjectLoader.getImage("Picture", "Title"), 0, 0, null); |
115 | choices.render(g, wx, wy); | ||
116 | } | 115 | } |
117 | 116 | ||
118 | } | 117 | } |
diff --git a/src/com/fourisland/fourpuzzle/gamestate/mapview/MapViewGameState.java b/src/com/fourisland/fourpuzzle/gamestate/mapview/MapViewGameState.java index 3ed23c3..a20062d 100755 --- a/src/com/fourisland/fourpuzzle/gamestate/mapview/MapViewGameState.java +++ b/src/com/fourisland/fourpuzzle/gamestate/mapview/MapViewGameState.java | |||
@@ -23,7 +23,6 @@ import com.fourisland.fourpuzzle.gamestate.mapview.event.specialmove.MoveEventTh | |||
23 | import com.fourisland.fourpuzzle.gamestate.mapview.viewpoint.AutomaticViewpoint; | 23 | import com.fourisland.fourpuzzle.gamestate.mapview.viewpoint.AutomaticViewpoint; |
24 | import com.fourisland.fourpuzzle.gamestate.mapview.viewpoint.Viewpoint; | 24 | import com.fourisland.fourpuzzle.gamestate.mapview.viewpoint.Viewpoint; |
25 | import com.fourisland.fourpuzzle.util.Functions; | 25 | import com.fourisland.fourpuzzle.util.Functions; |
26 | import com.fourisland.fourpuzzle.window.MessageWindow; | ||
27 | import java.awt.Graphics2D; | 26 | import java.awt.Graphics2D; |
28 | import java.awt.event.KeyEvent; | 27 | import java.awt.event.KeyEvent; |
29 | import java.awt.image.BufferedImage; | 28 | import java.awt.image.BufferedImage; |
@@ -229,11 +228,6 @@ public class MapViewGameState implements GameState { | |||
229 | 228 | ||
230 | g.drawImage(eventLayer, 0, 0, Game.WIDTH, Game.HEIGHT, x, y, x+Game.WIDTH, y+Game.HEIGHT, null); | 229 | g.drawImage(eventLayer, 0, 0, Game.WIDTH, Game.HEIGHT, x, y, x+Game.WIDTH, y+Game.HEIGHT, null); |
231 | g.drawImage(currentMap.renderUpper(), 0, 0, Game.WIDTH, Game.HEIGHT, x, y, x+Game.WIDTH, y+Game.HEIGHT, null); | 230 | g.drawImage(currentMap.renderUpper(), 0, 0, Game.WIDTH, Game.HEIGHT, x, y, x+Game.WIDTH, y+Game.HEIGHT, null); |
232 | |||
233 | if (mw != null) | ||
234 | { | ||
235 | mw.render(g); | ||
236 | } | ||
237 | } | 231 | } |
238 | 232 | ||
239 | public void setCurrentMap(String mapName) | 233 | public void setCurrentMap(String mapName) |
@@ -256,11 +250,5 @@ public class MapViewGameState implements GameState { | |||
256 | { | 250 | { |
257 | currentViewpoint = viewpoint; | 251 | currentViewpoint = viewpoint; |
258 | } | 252 | } |
259 | |||
260 | volatile MessageWindow mw = null; | ||
261 | public void displayMessage(String message) | ||
262 | { | ||
263 | mw = new MessageWindow(message); | ||
264 | } | ||
265 | 253 | ||
266 | } | 254 | } |
diff --git a/src/com/fourisland/fourpuzzle/gamestate/mapview/event/SpecialEvent.java b/src/com/fourisland/fourpuzzle/gamestate/mapview/event/SpecialEvent.java index 7ca08ff..2b54dc9 100755 --- a/src/com/fourisland/fourpuzzle/gamestate/mapview/event/SpecialEvent.java +++ b/src/com/fourisland/fourpuzzle/gamestate/mapview/event/SpecialEvent.java | |||
@@ -17,6 +17,7 @@ import com.fourisland.fourpuzzle.gamestate.mapview.viewpoint.MovingViewpoint; | |||
17 | import com.fourisland.fourpuzzle.gamestate.mapview.viewpoint.Viewpoint; | 17 | import com.fourisland.fourpuzzle.gamestate.mapview.viewpoint.Viewpoint; |
18 | import com.fourisland.fourpuzzle.transition.InTransition; | 18 | import com.fourisland.fourpuzzle.transition.InTransition; |
19 | import com.fourisland.fourpuzzle.transition.OutTransition; | 19 | import com.fourisland.fourpuzzle.transition.OutTransition; |
20 | import com.fourisland.fourpuzzle.window.MessageWindow; | ||
20 | import java.util.concurrent.CountDownLatch; | 21 | import java.util.concurrent.CountDownLatch; |
21 | 22 | ||
22 | /** | 23 | /** |
@@ -50,10 +51,11 @@ public class SpecialEvent { | |||
50 | * been read. | 51 | * been read. |
51 | * | 52 | * |
52 | * @param message The message to display | 53 | * @param message The message to display |
54 | * @throws InterruptedException | ||
53 | */ | 55 | */ |
54 | public void DisplayMessage(String message) | 56 | public void DisplayMessage(String message) throws InterruptedException |
55 | { | 57 | { |
56 | mapView.displayMessage(message); | 58 | MessageWindow.displayMessage(message); |
57 | } | 59 | } |
58 | 60 | ||
59 | /** | 61 | /** |