summary refs log tree commit diff stats
path: root/src/com/fourisland/fourpuzzle/gamestate/mapview/MapViewGameState.java
diff options
context:
space:
mode:
authorStarla Insigna <hatkirby@fourisland.com>2009-01-24 15:25:58 -0500
committerStarla Insigna <hatkirby@fourisland.com>2009-01-24 15:25:58 -0500
commitcd6b39590b8aced78fc2f6ed0c345fb9af1960c0 (patch)
tree807bc48adeb2a78a3f1d9b93f3471012509b5e51 /src/com/fourisland/fourpuzzle/gamestate/mapview/MapViewGameState.java
parenta581d9b4136bb633771e5e881bbee5a36247b0e0 (diff)
downloadfourpuzzle-cd6b39590b8aced78fc2f6ed0c345fb9af1960c0.tar.gz
fourpuzzle-cd6b39590b8aced78fc2f6ed0c345fb9af1960c0.tar.bz2
fourpuzzle-cd6b39590b8aced78fc2f6ed0c345fb9af1960c0.zip
Replaced checked exceptions with RuntimeException
Diffstat (limited to 'src/com/fourisland/fourpuzzle/gamestate/mapview/MapViewGameState.java')
-rw-r--r--src/com/fourisland/fourpuzzle/gamestate/mapview/MapViewGameState.java38
1 files changed, 25 insertions, 13 deletions
diff --git a/src/com/fourisland/fourpuzzle/gamestate/mapview/MapViewGameState.java b/src/com/fourisland/fourpuzzle/gamestate/mapview/MapViewGameState.java index 6aeac83..3d8d15d 100644 --- a/src/com/fourisland/fourpuzzle/gamestate/mapview/MapViewGameState.java +++ b/src/com/fourisland/fourpuzzle/gamestate/mapview/MapViewGameState.java
@@ -17,8 +17,11 @@ import com.fourisland.fourpuzzle.gamestate.mapview.event.EventList;
17import com.fourisland.fourpuzzle.gamestate.mapview.event.LayerEvent; 17import com.fourisland.fourpuzzle.gamestate.mapview.event.LayerEvent;
18import com.fourisland.fourpuzzle.gamestate.mapview.event.specialmove.MoveEventThread; 18import com.fourisland.fourpuzzle.gamestate.mapview.event.specialmove.MoveEventThread;
19import com.fourisland.fourpuzzle.util.Functions; 19import com.fourisland.fourpuzzle.util.Functions;
20import com.fourisland.fourpuzzle.util.ResourceNotFoundException;
20import java.awt.Graphics2D; 21import java.awt.Graphics2D;
21import java.awt.event.KeyEvent; 22import java.awt.event.KeyEvent;
23import java.util.logging.Level;
24import java.util.logging.Logger;
22 25
23/** 26/**
24 * 27 *
@@ -30,14 +33,14 @@ public class MapViewGameState implements GameState {
30 boolean processInput = true; 33 boolean processInput = true;
31 Map currentMap; 34 Map currentMap;
32 35
33 public MapViewGameState(String map, int x, int y) throws Exception 36 public MapViewGameState(String map, int x, int y)
34 { 37 {
35 //currentMap = ObjectLoader.getMap(map); 38 //currentMap = ObjectLoader.getMap(map);
36 setCurrentMap(map); 39 setCurrentMap(map);
37 Game.getSaveFile().getHero().setLocation(x, y); 40 Game.getSaveFile().getHero().setLocation(x, y);
38 } 41 }
39 42
40 public void initalize() throws Exception 43 public void initalize()
41 { 44 {
42 //if (!currentMap.getMusic().equals("")) 45 //if (!currentMap.getMusic().equals(""))
43 { 46 {
@@ -45,7 +48,7 @@ public class MapViewGameState implements GameState {
45 } 48 }
46 } 49 }
47 50
48 public void deinitalize() throws Exception 51 public void deinitalize()
49 { 52 {
50 //if (!currentMap.getMusic().equals("")) 53 //if (!currentMap.getMusic().equals(""))
51 { 54 {
@@ -53,7 +56,7 @@ public class MapViewGameState implements GameState {
53 } 56 }
54 } 57 }
55 58
56 public void processInput() throws Exception 59 public void processInput()
57 { 60 {
58 if (processInput) 61 if (processInput)
59 { 62 {
@@ -132,7 +135,7 @@ public class MapViewGameState implements GameState {
132 } 135 }
133 } 136 }
134 137
135 public void doGameCycle() throws Exception 138 public void doGameCycle()
136 { 139 {
137 HeroEvent hero = Game.getSaveFile().getHero(); 140 HeroEvent hero = Game.getSaveFile().getHero();
138 if (hero.isMoving()) 141 if (hero.isMoving())
@@ -154,7 +157,7 @@ public class MapViewGameState implements GameState {
154 } 157 }
155 } 158 }
156 159
157 public void render(Graphics2D g) throws Exception 160 public void render(Graphics2D g)
158 { 161 {
159 ChipSet chipSet = ChipSet.getChipSet(currentMap.getChipSet()); 162 ChipSet chipSet = ChipSet.getChipSet(currentMap.getChipSet());
160 int i,x,y; 163 int i,x,y;
@@ -202,19 +205,28 @@ public class MapViewGameState implements GameState {
202 } 205 }
203 } 206 }
204 207
205 public void initCurrentMap(String mapName) throws Exception 208 public void initCurrentMap(String mapName)
206 { 209 {
207 Class mapClass = Class.forName(PuzzleApplication.INSTANCE.getGamePackage() + ".gamedata.map." + mapName); 210 try {
208 Object mapObject = mapClass.newInstance(); 211 Class mapClass = Class.forName(PuzzleApplication.INSTANCE.getGamePackage() + ".gamedata.map." + mapName);
209 Map map = (Map) mapObject; 212 Object mapObject = mapClass.newInstance();
210 map.initalize(); 213 Map map = (Map) mapObject;
211 currentMap = map; 214 map.initalize();
215 currentMap = map;
216 } catch (InstantiationException ex) {
217 Logger.getLogger(MapViewGameState.class.getName()).log(Level.SEVERE, null, ex);
218 } catch (IllegalAccessException ex) {
219 Logger.getLogger(MapViewGameState.class.getName()).log(Level.SEVERE, null, ex);
220 } catch (ClassNotFoundException ex) {
221 throw new ResourceNotFoundException("Map", mapName);
222 }
212 } 223 }
213 public void setCurrentMap(String mapName) throws Exception 224 public void setCurrentMap(String mapName)
214 { 225 {
215 Game.getSaveFile().setCurrentMap(mapName); 226 Game.getSaveFile().setCurrentMap(mapName);
216 initCurrentMap(mapName); 227 initCurrentMap(mapName);
217 } 228 }
229
218 public Map getCurrentMap() 230 public Map getCurrentMap()
219 { 231 {
220 return currentMap; 232 return currentMap;