Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

maps test

  • Loading branch information...
commit d2425e88dcf25a71e97603ea76fc7ee9c25711a3 1 parent 0dfa563
Danny authored
2  mario/MarioWorld.java
View
@@ -132,6 +132,6 @@ public void newGame()
public void setStage(String stageName)
{
-
+ stage.setStage(stageName);
}
}
25 mario/Stages/Map.java
View
@@ -0,0 +1,25 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package mario.Stages;
+
+/**
+ *
+ * @author danny
+ */
+public abstract class Map
+{
+ protected String theme;
+ protected int[] map;
+
+ public Map(String theme, int[] map)
+ {
+ this.theme = theme;
+ this.map = map;
+ }
+
+
+
+}
29 mario/Stages/Stage.java
View
@@ -15,11 +15,11 @@
*/
public class Stage
{
- private boolean running = false;
- private boolean paused = false;
private AiDirector aiDirector = new AiDirector(this);
private StageMario mario = new StageMario(this,200, 420, 42, 57);
private Sound sound = new Sound();
+ private StageLoader stageLoader = new StageLoader();
+ private StageArray stageArray;
private Background background = new Background(this, 0, 552, 800, 48);
private Background background2 = new Background(this, 800, 552, 800, 48);
@@ -41,26 +41,6 @@ public Stage()
mapObjects.add(ScoreBalk);
}
- public boolean isRunning()
- {
- return running;
- }
-
- public void setRunning(boolean running)
- {
- this.running = running;
- }
-
- public boolean isPaused()
- {
- return paused;
- }
-
- public void setPaused(boolean paused)
- {
- this.paused = paused;
- }
-
public StageMario getMario()
{
return mario;
@@ -168,4 +148,9 @@ private void handleKeys(ArrayList<KeyButtons> keyPressed, boolean setter)
mario.setDown(setter);
}
}
+
+ public void setStage(String stageName)
+ {
+ stageArray = stageLoader.getStage(stageName);
+ }
}
47 mario/Stages/StageArray.java
View
@@ -0,0 +1,47 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package mario.Stages;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ *
+ * @author Danny
+ */
+public class StageArray
+{
+ private String[] map;
+
+ StageArray(String[] map)
+ {
+ this.map = map;
+ }
+
+ StageArray(BufferedReader in)
+ {
+ if (in == null)
+ {
+ throw new ExceptionInInitializerError("The file is not loaded");
+ }
+ //try
+ {
+ int i = 0;
+ //for(String line : in.readLine())
+ {
+
+ //map[i] = line;
+ i++;
+ }
+ //} catch (IOException ex)
+ {
+ //Logger.getLogger(StageArray.class.getName()).log(Level.SEVERE, null, ex);
+ }
+ }
+
+ }
+}
47 mario/Stages/StageLoader.java
View
@@ -2,13 +2,56 @@
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
-
package mario.Stages;
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
+import java.net.URL;
+import java.util.HashMap;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import mario.Main;
+
/**
*
* @author danny
*/
-public class StageLoader {
+public class StageLoader
+{
+ private static HashMap<String, StageArray> stages = new HashMap<String, StageArray>();
+
+ public StageLoader()
+ {
+ }
+
+ public StageArray getStage(String key)
+ {
+ StageArray stage = stages.get(key);
+
+ if (stage == null)
+ {
+ stages.put(key, loadStage(key));
+ stage = stages.get(key);
+ }
+ return stage;
+ }
+
+ private StageArray loadStage(String key)
+ {
+ URL arrayUrl = Main.class.getResource("/stages/" + key + ".map");
+ BufferedReader in = null;
+
+ try
+ {
+ in = new BufferedReader(new FileReader(arrayUrl.getFile()));
+ } catch (FileNotFoundException ex)
+ {
+ Logger.getLogger(StageLoader.class.getName()).log(Level.SEVERE, null, ex);
+ }
+ StageArray stageArray = new StageArray(in);
+ return stageArray;
+ }
}
4 mario/Stages/StageMario.java
View
@@ -295,7 +295,6 @@ public void doCharacterCollision(Collision collision, StageObject mapObject)
}
else{
game.getSound().playSound("/sound/dead.wav");
- game.setRunning(false);
}
}
//System.out.println("MARIO DOOD");
@@ -379,5 +378,4 @@ public void setStepCounter(int stepCounter)
{
this.stepCounter = stepCounter;
}
-
-}
+}
14 mario/Stages/goombasGarden/GoombaGardenEnd.java
View
@@ -0,0 +1,14 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package mario.Stages.goombasGarden;
+
+/**
+ *
+ * @author danny
+ */
+public class GoombaGardenEnd {
+
+}
16 mario/Stages/goombasGarden/GoombaGardenStart.java
View
@@ -0,0 +1,16 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package mario.Stages.goombasGarden;
+
+import mario.Stages.Map;
+
+/**
+ *
+ * @author danny
+ */
+public class GoombaGardenStart extends Map
+{
+
+}
10 stages/Goomba's garden.map
View
@@ -0,0 +1,10 @@
+1
+2
+3
+4
+5
+6
+7
+8
+9
+10
Please sign in to comment.
Something went wrong with that request. Please try again.