diff --git a/src/fr/enssat/BoulderDash/Game.java b/src/fr/enssat/BoulderDash/Game.java
index 7c77c46c..0d4b5886 100644
--- a/src/fr/enssat/BoulderDash/Game.java
+++ b/src/fr/enssat/BoulderDash/Game.java
@@ -7,17 +7,17 @@ import javax.swing.*;
/**
* Game
- *
+ *
* Spawns the game.
*
- * @author Valerian Saliou
- * @since 2015-06-19
+ * @author Valerian Saliou
+ * @since 2015-06-19
*/
public class Game {
/**
* Class constructor
*
- * @param args Command-line arguments
+ * @param args Command-line arguments
*/
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
diff --git a/src/fr/enssat/BoulderDash/bridges/SoundJLayerBridge.java b/src/fr/enssat/BoulderDash/bridges/SoundJLayerBridge.java
index e1088119..33b34037 100644
--- a/src/fr/enssat/BoulderDash/bridges/SoundJLayerBridge.java
+++ b/src/fr/enssat/BoulderDash/bridges/SoundJLayerBridge.java
@@ -8,11 +8,11 @@ import javazoom.jl.player.FactoryRegistry;
/**
* SoundJLayerBridge
- *
+ *
* Sound bridge to the JLayer library.
*
- * @author Valerian Saliou
- * @since 2015-06-19
+ * @author Valerian Saliou
+ * @since 2015-06-19
*/
public class SoundJLayerBridge extends PlaybackListener implements Runnable {
private String filePath;
@@ -22,7 +22,7 @@ public class SoundJLayerBridge extends PlaybackListener implements Runnable {
/**
* Class constructor
*
- * @param filePath File path to sound file
+ * @param filePath File path to sound file
*/
public SoundJLayerBridge(String filePath) {
this.filePath = filePath;
@@ -34,9 +34,9 @@ public class SoundJLayerBridge extends PlaybackListener implements Runnable {
public void play() {
try {
String urlAsString = "file:///"
- + new java.io.File(".").getCanonicalPath()
- + "/"
- + this.filePath;
+ + new java.io.File(".").getCanonicalPath()
+ + "/"
+ + this.filePath;
this.player = new AdvancedPlayer(
new URL(urlAsString).openStream(),
diff --git a/src/fr/enssat/BoulderDash/controllers/BoulderAndDiamondController.java b/src/fr/enssat/BoulderDash/controllers/BoulderAndDiamondController.java
index 656481ff..3848ab13 100644
--- a/src/fr/enssat/BoulderDash/controllers/BoulderAndDiamondController.java
+++ b/src/fr/enssat/BoulderDash/controllers/BoulderAndDiamondController.java
@@ -7,7 +7,7 @@ import fr.enssat.BoulderDash.helpers.AudioLoadHelper;
/**
* ElementPositionUpdateHelper
- *
+ *
* Updates position of all elements displayed on the map, according to their
* next potential position. Each object has a weight, which is used to compare
* their power to destroy in the food chain. Sorry for that Darwinism.
@@ -16,149 +16,149 @@ import fr.enssat.BoulderDash.helpers.AudioLoadHelper;
* @since 2015-06-19
*/
public class BoulderAndDiamondController implements Runnable {
- private LevelModel levelModel;
+ private LevelModel levelModel;
private AudioLoadHelper audioLoadHelper;
- private Thread elementMovingThread;
+ private Thread elementMovingThread;
- /**
- * Class constructor
- *
- * @param levelModel Level model
- */
- public BoulderAndDiamondController(LevelModel levelModel, AudioLoadHelper audioLoadHelper) {
- this.levelModel = levelModel;
+ /**
+ * Class constructor
+ *
+ * @param levelModel Level model
+ */
+ public BoulderAndDiamondController(LevelModel levelModel, AudioLoadHelper audioLoadHelper) {
+ this.levelModel = levelModel;
this.audioLoadHelper = audioLoadHelper;
// Start thread
- this.elementMovingThread = new Thread(this);
- this.elementMovingThread.start();
- }
+ this.elementMovingThread = new Thread(this);
+ this.elementMovingThread.start();
+ }
- /**
- * Watches for elements to be moved
- */
- public void run() {
- while (this.levelModel.isGameRunning()) {
- if(!this.levelModel.getGamePaused()){
- this.manageFallingObject();
- }
- try {
- Thread.sleep(250);
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- }
- }
+ /**
+ * Watches for elements to be moved
+ */
+ public void run() {
+ while (this.levelModel.isGameRunning()) {
+ if (!this.levelModel.getGamePaused()) {
+ this.manageFallingObject();
+ }
+ try {
+ Thread.sleep(250);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+ }
- /**
- * Scan the ground to detect the boulders & the diamonds, then make them
- * fall if necessary
+ /**
+ * Scan the ground to detect the boulders & the diamonds, then make them
+ * fall if necessary
* Note: scan of the ground upside down: we want things to fall slowly !
- */
- private void manageFallingObject() {
- for (int x = this.levelModel.getSizeWidth() - 1; x >= 0; x--) {
- for (int y = this.levelModel.getSizeHeight() - 1; y >= 0; y--) {
- // Gets the spriteName of actual DisplayableElementModel object scanned
- DisplayableElementModel elementModel = this.levelModel.getGroundLevelModel()[x][y];
+ */
+ private void manageFallingObject() {
+ for (int x = this.levelModel.getSizeWidth() - 1; x >= 0; x--) {
+ for (int y = this.levelModel.getSizeHeight() - 1; y >= 0; y--) {
+ // Gets the spriteName of actual DisplayableElementModel object scanned
+ DisplayableElementModel elementModel = this.levelModel.getGroundLevelModel()[x][y];
- if(elementModel == null) {
- elementModel = new DirtModel();
- }
+ if (elementModel == null) {
+ elementModel = new DirtModel();
+ }
- String spriteName = elementModel.getSpriteName();
-
- // If it is a boulder or a diamond...
- if (spriteName == "boulder" || spriteName == "diamond") {
- this.manageFall(x, y);
- } else if(spriteName == "expandingwall"){
- if(this.expandWall(x,y).equals("left")){
- x -= 1;
- }
- }
- }
- }
- }
+ String spriteName = elementModel.getSpriteName();
- /**
- * Expand the wall at left & right
+ // If it is a boulder or a diamond...
+ if (spriteName == "boulder" || spriteName == "diamond") {
+ this.manageFall(x, y);
+ } else if (spriteName == "expandingwall") {
+ if (this.expandWall(x, y).equals("left")) {
+ x -= 1;
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * Expand the wall at left & right
*
- * @param x Horizontal position
- * @param y Vertical position
- */
- private String expandWall(int x, int y) {
- DisplayableElementModel elementLeft = this.levelModel.getGroundLevelModel()[x - 1][y];
+ * @param x Horizontal position
+ * @param y Vertical position
+ */
+ private String expandWall(int x, int y) {
+ DisplayableElementModel elementLeft = this.levelModel.getGroundLevelModel()[x - 1][y];
DisplayableElementModel elementRight = this.levelModel.getGroundLevelModel()[x + 1][y];
- String spriteNameLeft = elementLeft.getSpriteName();
- String spriteNameRight = elementRight.getSpriteName();
-
- String way = "";
- if(spriteNameLeft == "black"){
- this.levelModel.expandThisWallToLeft(x,y);
- way = "left";
- }
- if(spriteNameRight == "black"){
- this.levelModel.expandThisWallToRight(x,y);
- way = "right";
- }
- return way;
- }
+ String spriteNameLeft = elementLeft.getSpriteName();
+ String spriteNameRight = elementRight.getSpriteName();
- /**
- * Manages the fall of elements
- *
- * @param x Horizontal position
- * @param y Vertical position
- */
- private void manageFall(int x, int y) {
- // Get informed about Rockford surroundings
+ String way = "";
+ if (spriteNameLeft == "black") {
+ this.levelModel.expandThisWallToLeft(x, y);
+ way = "left";
+ }
+ if (spriteNameRight == "black") {
+ this.levelModel.expandThisWallToRight(x, y);
+ way = "right";
+ }
+ return way;
+ }
+
+ /**
+ * Manages the fall of elements
+ *
+ * @param x Horizontal position
+ * @param y Vertical position
+ */
+ private void manageFall(int x, int y) {
+ // Get informed about Rockford surroundings
DisplayableElementModel elementBelow = this.levelModel.getGroundLevelModel()[x][y + 1];
- DisplayableElementModel elementLeft = this.levelModel.getGroundLevelModel()[x - 1][y];
+ DisplayableElementModel elementLeft = this.levelModel.getGroundLevelModel()[x - 1][y];
DisplayableElementModel elementRight = this.levelModel.getGroundLevelModel()[x + 1][y];
String spriteNameBelow = elementBelow.getSpriteName();
- String spriteNameLeft = elementLeft.getSpriteName();
- String spriteNameRight = elementRight.getSpriteName();
+ String spriteNameLeft = elementLeft.getSpriteName();
+ String spriteNameRight = elementRight.getSpriteName();
- // Then, process in case of the surrounding
- if (spriteNameBelow == "black") {
- this.levelModel.makeThisDisplayableElementFall(x, y);
- } else if (spriteNameBelow == "boulder") {
- // Boulders have to roll if they hit another boulder
- if (this.levelModel.getGroundLevelModel()[x - 1][y + 1].getSpriteName() == "black") {
- this.levelModel.makeThisBoulderSlideLeft(x, y);
- } else if (this.levelModel.getGroundLevelModel()[x + 1][y + 1].getSpriteName() == "black") {
- this.levelModel.makeThisBoulderSlideRight(x, y);
- }
- } else if (spriteNameBelow == "rockford" && this.levelModel.getGroundLevelModel()[x][y].isFalling()) {
- this.levelModel.exploseGround(x, y + 1);
+ // Then, process in case of the surrounding
+ if (spriteNameBelow == "black") {
+ this.levelModel.makeThisDisplayableElementFall(x, y);
+ } else if (spriteNameBelow == "boulder") {
+ // Boulders have to roll if they hit another boulder
+ if (this.levelModel.getGroundLevelModel()[x - 1][y + 1].getSpriteName() == "black") {
+ this.levelModel.makeThisBoulderSlideLeft(x, y);
+ } else if (this.levelModel.getGroundLevelModel()[x + 1][y + 1].getSpriteName() == "black") {
+ this.levelModel.makeThisBoulderSlideRight(x, y);
+ }
+ } else if (spriteNameBelow == "rockford" && this.levelModel.getGroundLevelModel()[x][y].isFalling()) {
+ this.levelModel.exploseGround(x, y + 1);
this.audioLoadHelper.playSound("die");
- try {
- Thread.sleep(25);
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
+ try {
+ Thread.sleep(25);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
- this.levelModel.setGameRunning(false);
- } else if (spriteNameBelow == "magicwall") {
- if (this.levelModel.getGroundLevelModel()[x][y].getSpriteName() == "boulder"
- && (this.levelModel.getGroundLevelModel()[x][y+2].getSpriteName() == "dirt" ||
- this.levelModel.getGroundLevelModel()[x][y+2].getSpriteName() == "black")) {
- if(this.levelModel.getGroundLevelModel()[x][y].isConvertible()) {
- this.levelModel.transformThisBoulderIntoADiamond(x, y);
- } else {
- this.levelModel.deleteThisBoulder(x, y);
- }
- }
- } else if (elementBelow.isDestructible() && spriteNameBelow != "dirt" && this.levelModel.getGroundLevelModel()[x][y].isFalling()) {
- this.levelModel.exploseThisBrickWall(x, y);
- } else if (spriteNameLeft == "rockford" && this.levelModel.getRockford().isRunningRight() && this.levelModel.getGroundLevelModel()[x + 1][y].getSpriteName() == "black") {
- this.levelModel.moveThisBoulderToRight(x, y);
- } else if (spriteNameRight == "rockford" && this.levelModel.getRockford().isRunningLeft() && this.levelModel.getGroundLevelModel()[x - 1][y].getSpriteName() == "black") {
- this.levelModel.moveThisBoulderToLeft(x, y);
- } else {
- this.levelModel.getGroundLevelModel()[x][y].setFalling(false);
- }
- }
+ this.levelModel.setGameRunning(false);
+ } else if (spriteNameBelow == "magicwall") {
+ if (this.levelModel.getGroundLevelModel()[x][y].getSpriteName() == "boulder"
+ && (this.levelModel.getGroundLevelModel()[x][y + 2].getSpriteName() == "dirt" ||
+ this.levelModel.getGroundLevelModel()[x][y + 2].getSpriteName() == "black")) {
+ if (this.levelModel.getGroundLevelModel()[x][y].isConvertible()) {
+ this.levelModel.transformThisBoulderIntoADiamond(x, y);
+ } else {
+ this.levelModel.deleteThisBoulder(x, y);
+ }
+ }
+ } else if (elementBelow.isDestructible() && spriteNameBelow != "dirt" && this.levelModel.getGroundLevelModel()[x][y].isFalling()) {
+ this.levelModel.exploseThisBrickWall(x, y);
+ } else if (spriteNameLeft == "rockford" && this.levelModel.getRockford().isRunningRight() && this.levelModel.getGroundLevelModel()[x + 1][y].getSpriteName() == "black") {
+ this.levelModel.moveThisBoulderToRight(x, y);
+ } else if (spriteNameRight == "rockford" && this.levelModel.getRockford().isRunningLeft() && this.levelModel.getGroundLevelModel()[x - 1][y].getSpriteName() == "black") {
+ this.levelModel.moveThisBoulderToLeft(x, y);
+ } else {
+ this.levelModel.getGroundLevelModel()[x][y].setFalling(false);
+ }
+ }
}
diff --git a/src/fr/enssat/BoulderDash/controllers/GameController.java b/src/fr/enssat/BoulderDash/controllers/GameController.java
index 2a921c9c..3d01c8e6 100644
--- a/src/fr/enssat/BoulderDash/controllers/GameController.java
+++ b/src/fr/enssat/BoulderDash/controllers/GameController.java
@@ -12,57 +12,57 @@ import java.awt.event.ActionListener;
/**
* GameController
- *
+ *
* This system creates the view.
* The game loop is also handled there.
*
- * @author Colin Leverger
- * @since 2015-06-19
+ * @author Colin Leverger
+ * @since 2015-06-19
*/
public class GameController implements ActionListener {
- private LevelModel levelModel;
+ private LevelModel levelModel;
private AudioLoadHelper audioLoadHelper;
private boolean firstClickOnPause;
- private MenuView menuView;
- private GameView gameView;
- private NavigationBetweenViewController navigationBetweenViewController;
-
+ private MenuView menuView;
+ private GameView gameView;
+ private NavigationBetweenViewController navigationBetweenViewController;
+
/**
* Class constructor
*
- * @param levelModel Level model
- * @param navigationBetweenViewController
+ * @param levelModel Level model
+ * @param navigationBetweenViewController
*/
- public GameController(LevelModel levelModel, AudioLoadHelper audioLoadHelper, NavigationBetweenViewController navigationBetweenViewController) {
+ public GameController(LevelModel levelModel, AudioLoadHelper audioLoadHelper, NavigationBetweenViewController navigationBetweenViewController) {
this.firstClickOnPause = true;
-
+
this.navigationBetweenViewController = navigationBetweenViewController;
-
- this.levelModel = levelModel;
+
+ this.levelModel = levelModel;
this.audioLoadHelper = audioLoadHelper;
- this.gameView = new GameView(this, levelModel);
+ this.gameView = new GameView(this, levelModel);
this.menuView = navigationBetweenViewController.getMenuView();
this.getAudioLoadHelper().stopMusic();
this.getAudioLoadHelper().playSound("new");
- }
+ }
- /**
- * Handles the 'action performed' event
+ /**
+ * Handles the 'action performed' event
*
- * @param event Action event
- */
- public void actionPerformed(ActionEvent event) {
- switch(event.getActionCommand()) {
+ * @param event Action event
+ */
+ public void actionPerformed(ActionEvent event) {
+ switch (event.getActionCommand()) {
case "pause":
- if(this.firstClickOnPause) {
- this.levelModel.setGamePaused(true);
- } else if(!this.firstClickOnPause) {
- this.levelModel.setGamePaused(false);
- }
+ if (this.firstClickOnPause) {
+ this.levelModel.setGamePaused(true);
+ } else if (!this.firstClickOnPause) {
+ this.levelModel.setGamePaused(false);
+ }
- this.firstClickOnPause = !this.firstClickOnPause;
- this.gameView.getGameFieldView().grabFocus();
+ this.firstClickOnPause = !this.firstClickOnPause;
+ this.gameView.getGameFieldView().grabFocus();
break;
case "restart":
@@ -70,32 +70,32 @@ public class GameController implements ActionListener {
this.getAudioLoadHelper().playSound("new");
this.gameView.getGameFieldView().grabFocus();
break;
-
+
case "menu":
- this.menuView.setVisible(true);
+ this.menuView.setVisible(true);
this.getAudioLoadHelper().startMusic("game");
- this.resetGame("menu");
+ this.resetGame("menu");
break;
}
- }
+ }
- /**
- * Function to reset the game
- */
+ /**
+ * Function to reset the game
+ */
private void resetGame(String source) {
- this.gameView.dispose();
-
- if(source.equals("restart")){
- this.levelModel = new LevelModel(this.navigationBetweenViewController.getPickedLevelIdentifier(), audioLoadHelper);
- this.gameView = new GameView(this, levelModel);
- this.gameView.setVisible(true);
- }
- }
+ this.gameView.dispose();
- /**
+ if (source.equals("restart")) {
+ this.levelModel = new LevelModel(this.navigationBetweenViewController.getPickedLevelIdentifier(), audioLoadHelper);
+ this.gameView = new GameView(this, levelModel);
+ this.gameView.setVisible(true);
+ }
+ }
+
+ /**
* Gets the audio load helper instance
*
- * @return Audio load helper instance
+ * @return Audio load helper instance
*/
public AudioLoadHelper getAudioLoadHelper() {
return this.audioLoadHelper;
@@ -103,17 +103,19 @@ public class GameController implements ActionListener {
/**
* Return the game view
+ *
* @return gameView
*/
- public GameView getGameView() {
- return gameView;
- }
+ public GameView getGameView() {
+ return gameView;
+ }
- /**
- * Set the gameView
- * @param gameView
- */
- public void setGameView(GameView gameView) {
- this.gameView = gameView;
- }
+ /**
+ * Set the gameView
+ *
+ * @param gameView
+ */
+ public void setGameView(GameView gameView) {
+ this.gameView = gameView;
+ }
}
\ No newline at end of file
diff --git a/src/fr/enssat/BoulderDash/controllers/GameKeyController.java b/src/fr/enssat/BoulderDash/controllers/GameKeyController.java
index a7821b1d..3944c419 100644
--- a/src/fr/enssat/BoulderDash/controllers/GameKeyController.java
+++ b/src/fr/enssat/BoulderDash/controllers/GameKeyController.java
@@ -12,32 +12,33 @@ import java.awt.event.KeyListener;
/**
* GameKeyController
- *
+ *
* Manages the key events controller.
*
- * @author Colin Leverger
- * @since 2015-06-19
+ * @author Colin Leverger
+ * @since 2015-06-19
*/
public class GameKeyController implements KeyListener {
- private LevelModel levelModel;
- private RockfordUpdateController updatePosRockford;
+ private LevelModel levelModel;
+ private RockfordUpdateController updatePosRockford;
+
/**
* Class constructor
*
- * @param levelModel Level model
+ * @param levelModel Level model
*/
- public GameKeyController(LevelModel levelModel, AudioLoadHelper audioLoadHelper) {
- this.levelModel = levelModel;
- new BoulderAndDiamondController(levelModel, audioLoadHelper);
- this.updatePosRockford = new RockfordUpdateController(levelModel);
- }
+ public GameKeyController(LevelModel levelModel, AudioLoadHelper audioLoadHelper) {
+ this.levelModel = levelModel;
+ new BoulderAndDiamondController(levelModel, audioLoadHelper);
+ this.updatePosRockford = new RockfordUpdateController(levelModel);
+ }
/**
* Handles the 'key pressed' event
*
- * @param e Key event
+ * @param e Key event
*/
- public void keyPressed(KeyEvent e) {
+ public void keyPressed(KeyEvent e) {
int keyCode = e.getKeyCode();
switch (keyCode) {
@@ -85,25 +86,25 @@ public class GameKeyController implements KeyListener {
break;
}
- }
+ }
/**
* Handles the 'key released' event
*
- * @param e Key event
+ * @param e Key event
*/
- @Override
- public void keyReleased(KeyEvent e) {
- this.levelModel.getRockford().startStaying();
- }
+ @Override
+ public void keyReleased(KeyEvent e) {
+ this.levelModel.getRockford().startStaying();
+ }
/**
* Handles the 'key typed' event
*
- * @param e Key event
+ * @param e Key event
*/
- @Override
- public void keyTyped(KeyEvent e) {
+ @Override
+ public void keyTyped(KeyEvent e) {
// Do nothing.
- }
+ }
}
diff --git a/src/fr/enssat/BoulderDash/controllers/LevelEditorController.java b/src/fr/enssat/BoulderDash/controllers/LevelEditorController.java
index c5a7a410..c781e457 100644
--- a/src/fr/enssat/BoulderDash/controllers/LevelEditorController.java
+++ b/src/fr/enssat/BoulderDash/controllers/LevelEditorController.java
@@ -15,21 +15,21 @@ import javax.swing.*;
/**
* LevelEditorController
- *
+ *
* Manages the level editor controller.
*
- * @author Valerian Saliou
- * @since 2015-06-19
+ * @author Valerian Saliou
+ * @since 2015-06-19
*/
public class LevelEditorController implements ActionListener {
private LevelModel levelModel;
- private LevelEditorView levelEditorView;
- private NavigationBetweenViewController nav;
+ private LevelEditorView levelEditorView;
+ private NavigationBetweenViewController nav;
/**
* Class constructor'
*
- * @param levelModel Level model
+ * @param levelModel Level model
*/
public LevelEditorController(LevelModel levelModel, NavigationBetweenViewController nav) {
this.levelModel = levelModel;
@@ -37,7 +37,7 @@ public class LevelEditorController implements ActionListener {
this.nav = nav;
this.nav.getAudioLoadHelper().stopMusic();
-
+
this.levelEditorView = new LevelEditorView(this, levelModel, nav);
// Pre-bind event watcher (hack to fix a Java issue)
@@ -47,13 +47,13 @@ public class LevelEditorController implements ActionListener {
/**
* Handles the 'action performed' event
*
- * @param event Action event
+ * @param event Action event
*/
public void actionPerformed(ActionEvent event) {
- switch(event.getActionCommand()) {
+ switch (event.getActionCommand()) {
case "menu":
- this.levelEditorView.setVisible(false);
- this.nav.setMenuView();
+ this.levelEditorView.setVisible(false);
+ this.nav.setMenuView();
this.nav.getAudioLoadHelper().startMusic("game");
break;
@@ -67,7 +67,7 @@ public class LevelEditorController implements ActionListener {
String levelId = this.levelEditorView.getSelectedLevel();
LevelSaveHelper levelSave;
- if(levelId == null || levelId.isEmpty()) {
+ if (levelId == null || levelId.isEmpty()) {
// Create a new level
levelSave = new LevelSaveHelper(levelModel.getGroundLevelModel());
} else {
@@ -79,7 +79,7 @@ public class LevelEditorController implements ActionListener {
JOptionPane.showMessageDialog(frameDialog, "Level saved");
this.levelEditorView.openedLevelChange(levelSave.getLevelId());
- } catch(LevelConstraintNotRespectedException e) {
+ } catch (LevelConstraintNotRespectedException e) {
JFrame frameDialog = new JFrame("Error");
JOptionPane.showMessageDialog(frameDialog, e.getMessage());
}
@@ -90,7 +90,7 @@ public class LevelEditorController implements ActionListener {
String levelId = this.levelEditorView.getSelectedLevel();
JFrame frameDialog = new JFrame("Info");
- if(levelId == null || levelId.isEmpty()) {
+ if (levelId == null || levelId.isEmpty()) {
JOptionPane.showMessageDialog(frameDialog, "Level not yet saved, no need to delete it!");
} else {
new LevelRemoveHelper(levelId);
@@ -99,9 +99,9 @@ public class LevelEditorController implements ActionListener {
this.levelEditorView.openedLevelChange(null);
}
break;
-
+
case "help":
- new HelpView();
+ new HelpView();
break;
case "new":
@@ -115,16 +115,16 @@ public class LevelEditorController implements ActionListener {
/**
* Gets the level editor view
*
- * @return Level editor view
+ * @return Level editor view
*/
- public LevelEditorView getLevelEditorView() {
- return levelEditorView;
- }
+ public LevelEditorView getLevelEditorView() {
+ return levelEditorView;
+ }
/**
* Gets level model
*
- * @return Level model
+ * @return Level model
*/
public LevelModel getLevelModel() {
return this.levelModel;
@@ -133,11 +133,11 @@ public class LevelEditorController implements ActionListener {
/**
* Sets the level editor view
*
- * @param levelEditorView Level editor view
+ * @param levelEditorView Level editor view
*/
- public void setLevelEditorView(LevelEditorView levelEditorView) {
- this.levelEditorView = levelEditorView;
- }
-
-
+ public void setLevelEditorView(LevelEditorView levelEditorView) {
+ this.levelEditorView = levelEditorView;
+ }
+
+
}
\ No newline at end of file
diff --git a/src/fr/enssat/BoulderDash/controllers/LevelEditorKeyController.java b/src/fr/enssat/BoulderDash/controllers/LevelEditorKeyController.java
index 78f98d3f..2b9ee215 100644
--- a/src/fr/enssat/BoulderDash/controllers/LevelEditorKeyController.java
+++ b/src/fr/enssat/BoulderDash/controllers/LevelEditorKeyController.java
@@ -9,22 +9,22 @@ import java.awt.event.KeyListener;
/**
* LevelEditorKeyController
- *
+ *
* Manages the key events controller.
*
- * @author Valerian Saliou
- * @since 2015-06-21
+ * @author Valerian Saliou
+ * @since 2015-06-21
*/
public class LevelEditorKeyController implements KeyListener {
private LevelModel levelModel;
private LevelEditorView levelEditorView;
- private boolean capLocks;
+ private boolean capLocks;
/**
* Class constructor
*
- * @param levelModel Level model
- * @param levelEditorView Level editor view
+ * @param levelModel Level model
+ * @param levelEditorView Level editor view
*/
public LevelEditorKeyController(LevelModel levelModel, LevelEditorView levelEditorView) {
this.levelModel = levelModel;
@@ -35,7 +35,7 @@ public class LevelEditorKeyController implements KeyListener {
/**
* Handles the 'key pressed' event
*
- * @param e Key event
+ * @param e Key event
*/
public void keyPressed(KeyEvent e) {
int keyCode = e.getKeyCode();
@@ -65,22 +65,22 @@ public class LevelEditorKeyController implements KeyListener {
case KeyEvent.VK_SPACE:
this.levelModel.triggerBlockChange(this.levelEditorView.getPickedBlockValue());
break;
-
+
case 16:
this.capLocks = !capLocks;
break;
}
// Hold block change (quick edit)
- if(capLocks) {
- this.levelModel.triggerBlockChange(this.levelEditorView.getPickedBlockValue());
+ if (capLocks) {
+ this.levelModel.triggerBlockChange(this.levelEditorView.getPickedBlockValue());
}
}
/**
* Handles the 'key released' event
*
- * @param e Key event
+ * @param e Key event
*/
@Override
public void keyReleased(KeyEvent e) {
@@ -90,7 +90,7 @@ public class LevelEditorKeyController implements KeyListener {
/**
* Handles the 'key typed' event
*
- * @param e Key event
+ * @param e Key event
*/
@Override
public void keyTyped(KeyEvent e) {
diff --git a/src/fr/enssat/BoulderDash/controllers/NavigationBetweenViewController.java b/src/fr/enssat/BoulderDash/controllers/NavigationBetweenViewController.java
index db190f48..59ab914a 100644
--- a/src/fr/enssat/BoulderDash/controllers/NavigationBetweenViewController.java
+++ b/src/fr/enssat/BoulderDash/controllers/NavigationBetweenViewController.java
@@ -11,39 +11,38 @@ import fr.enssat.BoulderDash.controllers.GameController;
/**
* Controller to navigate between the different views
- *
- * @author Colin Leverger
*
+ * @author Colin Leverger
*/
public class NavigationBetweenViewController implements ActionListener {
- private LevelEditorController levelEditorController;
- private MenuView menuView;
- private AudioLoadHelper audioLoadHelper;
- private LevelModel levelModelForGame, levelModelForEditor;
- private GameController gameController;
- private String pickedLevelIdentifier;
+ private LevelEditorController levelEditorController;
+ private MenuView menuView;
+ private AudioLoadHelper audioLoadHelper;
+ private LevelModel levelModelForGame, levelModelForEditor;
+ private GameController gameController;
+ private String pickedLevelIdentifier;
/**
* Class constructor
*/
- public NavigationBetweenViewController() {
- this.audioLoadHelper = new AudioLoadHelper();
+ public NavigationBetweenViewController() {
+ this.audioLoadHelper = new AudioLoadHelper();
// Play game music
this.getAudioLoadHelper().startMusic("game");
- // Creation of the first view
- this.menuView = new MenuView(this);
- }
+ // Creation of the first view
+ this.menuView = new MenuView(this);
+ }
/**
* Action performed event handler
*
- * @param event Action event
+ * @param event Action event
*/
- @Override
- public void actionPerformed(ActionEvent event) {
- switch (event.getActionCommand()) {
+ @Override
+ public void actionPerformed(ActionEvent event) {
+ switch (event.getActionCommand()) {
case "quit":
System.exit(0);
break;
@@ -76,16 +75,16 @@ public class NavigationBetweenViewController implements ActionListener {
this.gameController.getGameView().setVisible(true);
this.gameController.getGameView().getGameFieldView().grabFocus();
- break;
- }
+ break;
+ }
- this.menuView.setVisible(false);
- }
+ this.menuView.setVisible(false);
+ }
/**
* Get the audio load helper
*
- * @return Audio load helper
+ * @return Audio load helper
*/
public AudioLoadHelper getAudioLoadHelper() {
return this.audioLoadHelper;
@@ -94,39 +93,39 @@ public class NavigationBetweenViewController implements ActionListener {
/**
* Get the first view
*
- * @return First view
+ * @return First view
*/
public MenuView getMenuView() {
return this.menuView;
}
- /**
- * Set the first view
- *
- * @param menuView
- */
- public MenuView setMenuView() {
- this.menuView = new MenuView(this);
- return menuView;
- }
-
- /**
- * Get the pickedLevel
+ /**
+ * Set the first view
*
- * @return pickedLevelIdentifier Picked level identifier
- */
- public String getPickedLevelIdentifier() {
- return pickedLevelIdentifier;
- }
+ * @param menuView
+ */
+ public MenuView setMenuView() {
+ this.menuView = new MenuView(this);
+ return menuView;
+ }
- /**
- * Set the pickedLevelIdentifier
+ /**
+ * Get the pickedLevel
*
- * @param pickedLevelIdentifier Picked level identifier
- */
- public void setPickedLevelIdentifier(String pickedLevelIdentifier) {
- this.pickedLevelIdentifier = pickedLevelIdentifier;
- }
-
-
+ * @return pickedLevelIdentifier Picked level identifier
+ */
+ public String getPickedLevelIdentifier() {
+ return pickedLevelIdentifier;
+ }
+
+ /**
+ * Set the pickedLevelIdentifier
+ *
+ * @param pickedLevelIdentifier Picked level identifier
+ */
+ public void setPickedLevelIdentifier(String pickedLevelIdentifier) {
+ this.pickedLevelIdentifier = pickedLevelIdentifier;
+ }
+
+
}
diff --git a/src/fr/enssat/BoulderDash/controllers/RockfordUpdateController.java b/src/fr/enssat/BoulderDash/controllers/RockfordUpdateController.java
index c4ecd1ba..c849ba66 100644
--- a/src/fr/enssat/BoulderDash/controllers/RockfordUpdateController.java
+++ b/src/fr/enssat/BoulderDash/controllers/RockfordUpdateController.java
@@ -4,7 +4,7 @@ import fr.enssat.BoulderDash.models.LevelModel;
/**
* ElementPositionUpdateHelper
- *
+ *
* Updates position of all elements displayed on the map, according to their
* next potential position. Each object has a weight, which is used to compare
* their power to destroy in the food chain. Sorry for that Darwinism.
@@ -13,52 +13,52 @@ import fr.enssat.BoulderDash.models.LevelModel;
* @since 2015-06-19
*/
public class RockfordUpdateController implements Runnable {
- private LevelModel levelModel;
- private Thread elementMovingThread;
- private int rockfordPositionX;
- private int rockfordPositionY;
- private boolean rockfordHasMoved;
+ private LevelModel levelModel;
+ private Thread elementMovingThread;
+ private int rockfordPositionX;
+ private int rockfordPositionY;
+ private boolean rockfordHasMoved;
- /**
- * Class constructor
- *
- * @param levelModel Level model
- */
- public RockfordUpdateController(LevelModel levelModel) {
- this.levelModel = levelModel;
- this.elementMovingThread = new Thread(this);
- this.elementMovingThread.start();
- this.rockfordHasMoved = false;
- }
+ /**
+ * Class constructor
+ *
+ * @param levelModel Level model
+ */
+ public RockfordUpdateController(LevelModel levelModel) {
+ this.levelModel = levelModel;
+ this.elementMovingThread = new Thread(this);
+ this.elementMovingThread.start();
+ this.rockfordHasMoved = false;
+ }
- /**
- * Watches for elements to be moved
- */
- public void run() {
- while (this.levelModel.isGameRunning()) {
- if(!this.levelModel.getGamePaused()){
- if (this.rockfordHasMoved) {
- this.levelModel.setPositionOfRockford(rockfordPositionX, rockfordPositionY);
- this.rockfordHasMoved = false;
- }
- }
- try {
- Thread.sleep(100);
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- }
- }
-
- /**
- * Moves Rockford
- *
- * @param rockfordPositionX Next horizontal position on the grid
- * @param rockfordPositionY Next vertical position on the grid
- */
- public void moveRockford(int rockfordPositionX, int rockfordPositionY) {
- this.rockfordPositionX = rockfordPositionX;
- this.rockfordPositionY = rockfordPositionY;
- this.rockfordHasMoved = true;
- }
+ /**
+ * Watches for elements to be moved
+ */
+ public void run() {
+ while (this.levelModel.isGameRunning()) {
+ if (!this.levelModel.getGamePaused()) {
+ if (this.rockfordHasMoved) {
+ this.levelModel.setPositionOfRockford(rockfordPositionX, rockfordPositionY);
+ this.rockfordHasMoved = false;
+ }
+ }
+ try {
+ Thread.sleep(100);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ /**
+ * Moves Rockford
+ *
+ * @param rockfordPositionX Next horizontal position on the grid
+ * @param rockfordPositionY Next vertical position on the grid
+ */
+ public void moveRockford(int rockfordPositionX, int rockfordPositionY) {
+ this.rockfordPositionX = rockfordPositionX;
+ this.rockfordPositionY = rockfordPositionY;
+ this.rockfordHasMoved = true;
+ }
}
diff --git a/src/fr/enssat/BoulderDash/exceptions/LevelConstraintNotRespectedException.java b/src/fr/enssat/BoulderDash/exceptions/LevelConstraintNotRespectedException.java
index a0f65401..e4dc3719 100644
--- a/src/fr/enssat/BoulderDash/exceptions/LevelConstraintNotRespectedException.java
+++ b/src/fr/enssat/BoulderDash/exceptions/LevelConstraintNotRespectedException.java
@@ -3,18 +3,18 @@ package fr.enssat.BoulderDash.exceptions;
/**
* LevelConstraintNotRespectedException
- *
+ *
* Raises an 'LevelConstraintNotRespectedException' exception.
* Given the exception message.
*
- * @author Valerian Saliou
- * @since 2015-06-24
+ * @author Valerian Saliou
+ * @since 2015-06-24
*/
public class LevelConstraintNotRespectedException extends Exception {
/**
* Class constructor
*
- * @param message Exception backtrace message
+ * @param message Exception backtrace message
*/
public LevelConstraintNotRespectedException(String message) {
super(message);
diff --git a/src/fr/enssat/BoulderDash/exceptions/ModelNotReadyException.java b/src/fr/enssat/BoulderDash/exceptions/ModelNotReadyException.java
index 556ed8aa..a4995c63 100644
--- a/src/fr/enssat/BoulderDash/exceptions/ModelNotReadyException.java
+++ b/src/fr/enssat/BoulderDash/exceptions/ModelNotReadyException.java
@@ -3,18 +3,18 @@ package fr.enssat.BoulderDash.exceptions;
/**
* ModelNotReadyException
- *
+ *
* Raises an 'ModelNotReadyException' exception.
* Given the exception message.
*
- * @author Valerian Saliou
- * @since 2015-06-23
+ * @author Valerian Saliou
+ * @since 2015-06-23
*/
public class ModelNotReadyException extends Exception {
/**
* Class constructor
*
- * @param message Exception backtrace message
+ * @param message Exception backtrace message
*/
public ModelNotReadyException(String message) {
super(message);
diff --git a/src/fr/enssat/BoulderDash/exceptions/UnknownModelException.java b/src/fr/enssat/BoulderDash/exceptions/UnknownModelException.java
index 84fa390d..55503f80 100644
--- a/src/fr/enssat/BoulderDash/exceptions/UnknownModelException.java
+++ b/src/fr/enssat/BoulderDash/exceptions/UnknownModelException.java
@@ -3,20 +3,20 @@ package fr.enssat.BoulderDash.exceptions;
/**
* UnknownModelException
- *
+ *
* Raises an 'UnknownSpriteException' exception.
* Given the exception message.
*
- * @author Valerian Saliou
- * @since 2015-06-19
+ * @author Valerian Saliou
+ * @since 2015-06-19
*/
public class UnknownModelException extends Exception {
- /**
- * Class constructor
- *
- * @param message Exception backtrace message
- */
- public UnknownModelException(String message) {
- super(message);
- }
+ /**
+ * Class constructor
+ *
+ * @param message Exception backtrace message
+ */
+ public UnknownModelException(String message) {
+ super(message);
+ }
}
diff --git a/src/fr/enssat/BoulderDash/helpers/AudioLoadHelper.java b/src/fr/enssat/BoulderDash/helpers/AudioLoadHelper.java
index bcfc6435..eeb800cc 100644
--- a/src/fr/enssat/BoulderDash/helpers/AudioLoadHelper.java
+++ b/src/fr/enssat/BoulderDash/helpers/AudioLoadHelper.java
@@ -8,11 +8,11 @@ import java.util.HashMap;
/**
* AudioLoadHelper
- *
+ *
* Manages audio
*
- * @author Valerian Saliou
- * @since 2015-06-19
+ * @author Valerian Saliou
+ * @since 2015-06-19
*/
public class AudioLoadHelper {
private static String pathToAudioStore = "./res/audio";
@@ -30,8 +30,8 @@ public class AudioLoadHelper {
/**
* Gets music storage path
*
- * @param musicId Music identifier
- * @return Music path, with file extension
+ * @param musicId Music identifier
+ * @return Music path, with file extension
*/
private String getMusicPathInAudioStore(String musicId) {
return AudioLoadHelper.pathToAudioStore + "/music/" + musicId + ".mp3";
@@ -40,10 +40,10 @@ public class AudioLoadHelper {
/**
* Starts game music
*
- * @param musicId Music identifier
+ * @param musicId Music identifier
*/
public void startMusic(String musicId) {
- if(this.musicToPlay != null) {
+ if (this.musicToPlay != null) {
this.stopMusic();
}
@@ -70,7 +70,7 @@ public class AudioLoadHelper {
// List sound files
File soundsDir = new File(AudioLoadHelper.pathToAudioStore + "/sounds/");
- File [] soundFiles = soundsDir.listFiles(new FilenameFilter() {
+ File[] soundFiles = soundsDir.listFiles(new FilenameFilter() {
@Override
public boolean accept(File dir, String name) {
return name.endsWith(".mp3");
@@ -91,8 +91,8 @@ public class AudioLoadHelper {
/**
* Gets a preloaded sound
*
- * @param soundId Sound identifier
- * @return Preloaded sound instance
+ * @param soundId Sound identifier
+ * @return Preloaded sound instance
*/
private SoundJLayerBridge getPreloadedSound(String soundId) {
return this.preloadedSounds.get(soundId);
@@ -101,7 +101,7 @@ public class AudioLoadHelper {
/**
* Plays a sound
*
- * @param soundId Sound identifier
+ * @param soundId Sound identifier
*/
public void playSound(String soundId) {
this.getPreloadedSound(soundId).play();
diff --git a/src/fr/enssat/BoulderDash/helpers/LevelLoadHelper.java b/src/fr/enssat/BoulderDash/helpers/LevelLoadHelper.java
index ac24e653..4b1c1901 100644
--- a/src/fr/enssat/BoulderDash/helpers/LevelLoadHelper.java
+++ b/src/fr/enssat/BoulderDash/helpers/LevelLoadHelper.java
@@ -36,233 +36,233 @@ import java.util.Locale;
/**
* LevelLoadHelper
- *
+ *
* Proceeds level load routine
* Able to deserialize level data from storage, and format it to
* internal representation To be used as a data factory from level
* model classes
*
- * @author Valerian Saliou
- * @since 2015-06-19
+ * @author Valerian Saliou
+ * @since 2015-06-19
*/
public class LevelLoadHelper {
- private static String pathToDataStore = "./res/levels";
- private String levelId = null;
- private Document levelDOM;
- private XPath xpathBuilder;
+ private static String pathToDataStore = "./res/levels";
+ private String levelId = null;
+ private Document levelDOM;
+ private XPath xpathBuilder;
private SimpleDateFormat dateFormatter;
- // Parsed values
- private String nameValue = null;
- private Date dateCreatedValue = null;
- private Date dateModifiedValue = null;
+ // Parsed values
+ private String nameValue = null;
+ private Date dateCreatedValue = null;
+ private Date dateModifiedValue = null;
- private int widthSizeValue = 0;
- private int heightSizeValue = 0;
- private int limitsWidth = 2;
- private int limitsHeight = 2;
- private int limitsOffsetWidth = 1;
- private int limitsOffsetHeight = 1;
+ private int widthSizeValue = 0;
+ private int heightSizeValue = 0;
+ private int limitsWidth = 2;
+ private int limitsHeight = 2;
+ private int limitsOffsetWidth = 1;
+ private int limitsOffsetHeight = 1;
- private RockfordModel rockfordInstance;
- private int rockfordPositionX = 0;
- private int rockfordPositionY = 0;
-
- private int diamondsToCatch;
+ private RockfordModel rockfordInstance;
+ private int rockfordPositionX = 0;
+ private int rockfordPositionY = 0;
- private DisplayableElementModel[][] groundGrid;
+ private int diamondsToCatch;
+
+ private DisplayableElementModel[][] groundGrid;
/**
* Class constructor
*
- * @param levelId Level identifier
+ * @param levelId Level identifier
*/
- public LevelLoadHelper(String levelId) {
- this.setLevelId(levelId);
- this.diamondsToCatch = 0;
+ public LevelLoadHelper(String levelId) {
+ this.setLevelId(levelId);
+ this.diamondsToCatch = 0;
// Requirements
this.dateFormatter = new SimpleDateFormat("yyy-MM-dd/HH:mm:ss", Locale.ENGLISH);
- if (this.levelId != null) {
- // Let's go.
- this.loadLevelData();
- }
- }
+ if (this.levelId != null) {
+ // Let's go.
+ this.loadLevelData();
+ }
+ }
/**
* Gets level storage path
*
- * @return Level path, with file extension
+ * @return Level path, with file extension
*/
- private String getLevelPathInDataStore() {
- return this.pathToDataStore + "/" + this.getLevelId() + ".xml";
- }
+ private String getLevelPathInDataStore() {
+ return this.pathToDataStore + "/" + this.getLevelId() + ".xml";
+ }
/**
* Loads the level data into instance data space
*/
- private void loadLevelData() {
- this.xpathBuilder = XPathFactory.newInstance().newXPath();
+ private void loadLevelData() {
+ this.xpathBuilder = XPathFactory.newInstance().newXPath();
- String pathToData = this.getLevelPathInDataStore();
+ String pathToData = this.getLevelPathInDataStore();
- // Parse & process level data
- this.parseLevelData(pathToData);
- this.processLevelData();
- }
+ // Parse & process level data
+ this.parseLevelData(pathToData);
+ this.processLevelData();
+ }
/**
* Parses the level data for the given file
* Handles the task of reading and storing the parsed DOM
*
- * @param pathToLevelData FS path to the level data
+ * @param pathToLevelData FS path to the level data
*/
- private void parseLevelData(String pathToLevelData) {
- DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
+ private void parseLevelData(String pathToLevelData) {
+ DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
- try {
- DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
+ try {
+ DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
- // Parse data in level file
- this.levelDOM = documentBuilder.parse(pathToLevelData);
- } catch (ParserConfigurationException e) {
- e.printStackTrace();
- } catch (org.xml.sax.SAXException e) {
- e.printStackTrace();
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
+ // Parse data in level file
+ this.levelDOM = documentBuilder.parse(pathToLevelData);
+ } catch (ParserConfigurationException e) {
+ e.printStackTrace();
+ } catch (org.xml.sax.SAXException e) {
+ e.printStackTrace();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
/**
* Processes the parsed level data
*/
- private void processLevelData() {
- // Parse elements from structure
- try {
- this.processNameElement();
- this.processDateElement();
- this.processSizeElement();
- this.processGridElement();
- } catch (XPathExpressionException e) {
- e.printStackTrace();
- } catch (ParseException e) {
- e.printStackTrace();
- }
- }
+ private void processLevelData() {
+ // Parse elements from structure
+ try {
+ this.processNameElement();
+ this.processDateElement();
+ this.processSizeElement();
+ this.processGridElement();
+ } catch (XPathExpressionException e) {
+ e.printStackTrace();
+ } catch (ParseException e) {
+ e.printStackTrace();
+ }
+ }
/**
* Processes the 'name' element
*/
- private void processNameElement() throws XPathExpressionException {
- // Returns level name value
- this.nameValue = this.xpathBuilder.compile("/bd-level/name").evaluate(this.levelDOM);
- }
+ private void processNameElement() throws XPathExpressionException {
+ // Returns level name value
+ this.nameValue = this.xpathBuilder.compile("/bd-level/name").evaluate(this.levelDOM);
+ }
/**
* Processes the 'date' element
*/
- private void processDateElement() throws XPathExpressionException, ParseException {
- // Returns level creation date value
- this.dateCreatedValue = this.dateFormatter.parse(xpathBuilder.compile("/bd-level/date[@format='utc']/created").evaluate(this.levelDOM));
+ private void processDateElement() throws XPathExpressionException, ParseException {
+ // Returns level creation date value
+ this.dateCreatedValue = this.dateFormatter.parse(xpathBuilder.compile("/bd-level/date[@format='utc']/created").evaluate(this.levelDOM));
- // Returns level modification date value
- this.dateModifiedValue = this.dateFormatter.parse(this.xpathBuilder.compile("/bd-level/date[@format='utc']/modified").evaluate(this.levelDOM));
- }
+ // Returns level modification date value
+ this.dateModifiedValue = this.dateFormatter.parse(this.xpathBuilder.compile("/bd-level/date[@format='utc']/modified").evaluate(this.levelDOM));
+ }
/**
* Processes the 'size' element
*/
- private void processSizeElement() throws XPathExpressionException {
- // Returns level width value
- this.widthSizeValue = Integer.parseInt(this.xpathBuilder.compile("/bd-level/size/width").evaluate(this.levelDOM));
- this.widthSizeValue += this.limitsWidth;
+ private void processSizeElement() throws XPathExpressionException {
+ // Returns level width value
+ this.widthSizeValue = Integer.parseInt(this.xpathBuilder.compile("/bd-level/size/width").evaluate(this.levelDOM));
+ this.widthSizeValue += this.limitsWidth;
- // Returns level height value
- this.heightSizeValue = Integer.parseInt(this.xpathBuilder.compile("/bd-level/size/height").evaluate(this.levelDOM));
- this.heightSizeValue += this.limitsHeight;
- }
+ // Returns level height value
+ this.heightSizeValue = Integer.parseInt(this.xpathBuilder.compile("/bd-level/size/height").evaluate(this.levelDOM));
+ this.heightSizeValue += this.limitsHeight;
+ }
/**
* Processes the 'grid' element
*/
- private void processGridElement() throws XPathExpressionException {
- // Initialize the grid
- this.groundGrid = new DisplayableElementModel[this.widthSizeValue][this.heightSizeValue];
+ private void processGridElement() throws XPathExpressionException {
+ // Initialize the grid
+ this.groundGrid = new DisplayableElementModel[this.widthSizeValue][this.heightSizeValue];
- // Populate the grid
- NodeList lineNode = (NodeList) this.xpathBuilder.compile("/bd-level/grid[@state='initial']/line").evaluate(this.levelDOM, XPathConstants.NODESET);
+ // Populate the grid
+ NodeList lineNode = (NodeList) this.xpathBuilder.compile("/bd-level/grid[@state='initial']/line").evaluate(this.levelDOM, XPathConstants.NODESET);
- // Parse lines
- for (int y = 0; y < lineNode.getLength(); y++) {
- Node currentLineNode = lineNode.item(y);
+ // Parse lines
+ for (int y = 0; y < lineNode.getLength(); y++) {
+ Node currentLineNode = lineNode.item(y);
- // Current line
- if (currentLineNode.getNodeType() == Node.ELEMENT_NODE) {
- Element currentLineElement = (Element) currentLineNode;
- int lineIndex = Integer.parseInt(currentLineElement.getAttribute("index"));
+ // Current line
+ if (currentLineNode.getNodeType() == Node.ELEMENT_NODE) {
+ Element currentLineElement = (Element) currentLineNode;
+ int lineIndex = Integer.parseInt(currentLineElement.getAttribute("index"));
- NodeList rowNode = (NodeList) currentLineNode.getChildNodes();
+ NodeList rowNode = (NodeList) currentLineNode.getChildNodes();
- for (int x = 0; x < rowNode.getLength(); x++) {
- Node currentRowNode = rowNode.item(x);
+ for (int x = 0; x < rowNode.getLength(); x++) {
+ Node currentRowNode = rowNode.item(x);
- // Current row
- if (currentRowNode.getNodeType() == Node.ELEMENT_NODE) {
- Element currentRowElement = (Element) currentRowNode;
- int rowIndex = Integer.parseInt(currentRowElement.getAttribute("index"));
+ // Current row
+ if (currentRowNode.getNodeType() == Node.ELEMENT_NODE) {
+ Element currentRowElement = (Element) currentRowNode;
+ int rowIndex = Integer.parseInt(currentRowElement.getAttribute("index"));
- NodeList spriteNode = currentRowElement.getElementsByTagName("sprite");
+ NodeList spriteNode = currentRowElement.getElementsByTagName("sprite");
- if (spriteNode.getLength() > 0) {
- Node currentSpriteNode = spriteNode.item(0);
+ if (spriteNode.getLength() > 0) {
+ Node currentSpriteNode = spriteNode.item(0);
- if (currentSpriteNode.getNodeType() == Node.ELEMENT_NODE) {
- Element currentSpriteElement = (Element) currentSpriteNode;
- String currentSpriteName = currentSpriteElement.getAttribute("name");
+ if (currentSpriteNode.getNodeType() == Node.ELEMENT_NODE) {
+ Element currentSpriteElement = (Element) currentSpriteNode;
+ String currentSpriteName = currentSpriteElement.getAttribute("name");
String currentSpriteConvertibleValue = currentSpriteElement.getAttribute("convertible");
boolean currentSpriteConvertible = false;
// No name? Continue.
- if(currentSpriteName == null || currentSpriteName.isEmpty()) {
+ if (currentSpriteName == null || currentSpriteName.isEmpty()) {
continue;
}
- if(currentSpriteConvertibleValue.equals("1")) {
- currentSpriteConvertible = true;
+ if (currentSpriteConvertibleValue.equals("1")) {
+ currentSpriteConvertible = true;
}
- // Process positions
- int pX = rowIndex + this.limitsOffsetWidth;
- int pY = lineIndex + this.limitsOffsetHeight;
+ // Process positions
+ int pX = rowIndex + this.limitsOffsetWidth;
+ int pY = lineIndex + this.limitsOffsetHeight;
- try {
- this.groundGrid[pX][pY] = this.constructGridElement(currentSpriteName, pX, pY, currentSpriteConvertible);
- } catch (UnknownModelException e) {
- e.printStackTrace();
- }
- }
- }
- }
- }
- }
- }
- }
+ try {
+ this.groundGrid[pX][pY] = this.constructGridElement(currentSpriteName, pX, pY, currentSpriteConvertible);
+ } catch (UnknownModelException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
/**
* Constructs the grid element
*
- * @param spriteName Sprite name
- * @param rowIndex Position in row (horizontal axis)
- * @param lineIndex Position in line (vertical axis)
+ * @param spriteName Sprite name
+ * @param rowIndex Position in row (horizontal axis)
+ * @param lineIndex Position in line (vertical axis)
*/
- private DisplayableElementModel constructGridElement(String spriteName, int rowIndex, int lineIndex, boolean convertible) throws UnknownModelException {
+ private DisplayableElementModel constructGridElement(String spriteName, int rowIndex, int lineIndex, boolean convertible) throws UnknownModelException {
ModelConvertHelper modelConvert = new ModelConvertHelper();
DisplayableElementModel element = modelConvert.toModel(spriteName, convertible);
- // Custom actions?
- switch (spriteName) {
+ // Custom actions?
+ switch (spriteName) {
case "diamond":
diamondsToCatch += 1;
break;
@@ -272,206 +272,208 @@ public class LevelLoadHelper {
this.setRockfordPositionY(lineIndex);
this.setRockfordInstance((RockfordModel) element);
break;
- }
+ }
- return element;
- }
+ return element;
+ }
/**
* Gets the level identifier
*
- * @return Level identifier
+ * @return Level identifier
*/
- public String getLevelId() {
- return this.levelId;
- }
+ public String getLevelId() {
+ return this.levelId;
+ }
/**
* Sets the level identifier
*
- * @param levelId Level identifier
+ * @param levelId Level identifier
*/
- private void setLevelId(String levelId) {
- this.levelId = levelId;
- }
+ private void setLevelId(String levelId) {
+ this.levelId = levelId;
+ }
/**
* Gets the name value
*
- * @return Name value
+ * @return Name value
*/
- public String getNameValue() {
- return this.nameValue;
- }
+ public String getNameValue() {
+ return this.nameValue;
+ }
/**
* Sets the name value
*
- * @param nameValue Name value
+ * @param nameValue Name value
*/
- private void setNameValue(String nameValue) {
- this.nameValue = nameValue;
- }
+ private void setNameValue(String nameValue) {
+ this.nameValue = nameValue;
+ }
/**
* Gets the creation date value
*
- * @return Creation date value
+ * @return Creation date value
*/
- public Date getDateCreatedValue() {
- return this.dateCreatedValue;
- }
+ public Date getDateCreatedValue() {
+ return this.dateCreatedValue;
+ }
/**
* Sets the creation date value
*
- * @param dateCreatedValue Creation date value
+ * @param dateCreatedValue Creation date value
*/
- private void setDateCreatedValue(Date dateCreatedValue) {
- this.dateCreatedValue = dateCreatedValue;
- }
+ private void setDateCreatedValue(Date dateCreatedValue) {
+ this.dateCreatedValue = dateCreatedValue;
+ }
/**
* Gets the modified date value
*
- * @return Modified date value
+ * @return Modified date value
*/
- public Date getDateModifiedValue() {
- return this.dateModifiedValue;
- }
+ public Date getDateModifiedValue() {
+ return this.dateModifiedValue;
+ }
/**
* Sets the modified date value
*
- * @param dateModifiedValue Modified date value
+ * @param dateModifiedValue Modified date value
*/
- private void setDateModifiedValue(Date dateModifiedValue) {
- this.dateModifiedValue = dateModifiedValue;
- }
+ private void setDateModifiedValue(Date dateModifiedValue) {
+ this.dateModifiedValue = dateModifiedValue;
+ }
/**
* Gets the width size value
*
- * @return Width size value
+ * @return Width size value
*/
- public int getWidthSizeValue() {
- return this.widthSizeValue;
- }
+ public int getWidthSizeValue() {
+ return this.widthSizeValue;
+ }
/**
* Sets the width size value
*
- * @param widthSizeValue Width size value
+ * @param widthSizeValue Width size value
*/
- private void setWidthSizeValue(int widthSizeValue) {
- this.widthSizeValue = widthSizeValue;
- }
+ private void setWidthSizeValue(int widthSizeValue) {
+ this.widthSizeValue = widthSizeValue;
+ }
/**
* Gets the height size value
*
- * @return Height size value
+ * @return Height size value
*/
- public int getHeightSizeValue() {
- return this.heightSizeValue;
- }
+ public int getHeightSizeValue() {
+ return this.heightSizeValue;
+ }
/**
* Sets the eight size value
*
- * @param heightSizeValue Height size value
+ * @param heightSizeValue Height size value
*/
- private void setHeightSizeValue(int heightSizeValue) {
- this.heightSizeValue = heightSizeValue;
- }
+ private void setHeightSizeValue(int heightSizeValue) {
+ this.heightSizeValue = heightSizeValue;
+ }
/**
* Gets the horizontal position of the Rockford element
*
- * @return Horizontal position of the Rockford element
+ * @return Horizontal position of the Rockford element
*/
- public int getRockfordPositionX() {
- return this.rockfordPositionX;
- }
+ public int getRockfordPositionX() {
+ return this.rockfordPositionX;
+ }
/**
* Sets the horizontal position of the Rockford element
*
- * @param x Horizontal position of the Rockford element
+ * @param x Horizontal position of the Rockford element
*/
- public void setRockfordPositionX(int x) {
- this.rockfordPositionX = x;
- }
+ public void setRockfordPositionX(int x) {
+ this.rockfordPositionX = x;
+ }
/**
* Gets the vertical position of the Rockford element
*
- * @return Vertical position of the Rockford element
+ * @return Vertical position of the Rockford element
*/
- public int getRockfordPositionY() {
- return this.rockfordPositionY;
- }
+ public int getRockfordPositionY() {
+ return this.rockfordPositionY;
+ }
/**
* Sets the vertical position of the Rockford element
*
- * @param y Vertical position of the Rockford element
+ * @param y Vertical position of the Rockford element
*/
- public void setRockfordPositionY(int y) {
- this.rockfordPositionY = y;
- }
+ public void setRockfordPositionY(int y) {
+ this.rockfordPositionY = y;
+ }
/**
* Gets the instance of Rockford
*
- * @return Rockford instance
+ * @return Rockford instance
*/
- public RockfordModel getRockfordInstance() {
- return this.rockfordInstance;
- }
+ public RockfordModel getRockfordInstance() {
+ return this.rockfordInstance;
+ }
/**
* Sets the instance of Rockford
*
- * @param rockfordInstance Rockford instance
+ * @param rockfordInstance Rockford instance
*/
- public void setRockfordInstance(RockfordModel rockfordInstance) {
- this.rockfordInstance = rockfordInstance;
- }
+ public void setRockfordInstance(RockfordModel rockfordInstance) {
+ this.rockfordInstance = rockfordInstance;
+ }
/**
* Gets the ground grid
*
- * @return Ground grid
+ * @return Ground grid
*/
- public DisplayableElementModel[][] getGroundGrid() {
- return this.groundGrid;
- }
+ public DisplayableElementModel[][] getGroundGrid() {
+ return this.groundGrid;
+ }
/**
* Sets the ground grid
*
- * @param groundGrid Ground grid
+ * @param groundGrid Ground grid
*/
- private void setGroundGrid(DisplayableElementModel[][] groundGrid) {
- this.groundGrid = groundGrid;
- }
+ private void setGroundGrid(DisplayableElementModel[][] groundGrid) {
+ this.groundGrid = groundGrid;
+ }
+
+ /**
+ * Gets the number of Diamonds to catch
+ *
+ * @return number of Diamonds to catch
+ */
+ public int getDiamondsToCatch() {
+ return diamondsToCatch;
+ }
+
+ /**
+ * Sets the number of Diamonds to catch
+ *
+ * @param diamondsToCatch
+ */
+ public void setDiamondsToCatch(int diamondsToCatch) {
+ this.diamondsToCatch = diamondsToCatch;
+ }
- /**
- * Gets the number of Diamonds to catch
- * @return number of Diamonds to catch
- */
- public int getDiamondsToCatch() {
- return diamondsToCatch;
- }
- /**
- * Sets the number of Diamonds to catch
- * @param diamondsToCatch
- */
- public void setDiamondsToCatch(int diamondsToCatch) {
- this.diamondsToCatch = diamondsToCatch;
- }
-
-
}
diff --git a/src/fr/enssat/BoulderDash/helpers/LevelRemoveHelper.java b/src/fr/enssat/BoulderDash/helpers/LevelRemoveHelper.java
index c8bc82c5..f21fb3a8 100644
--- a/src/fr/enssat/BoulderDash/helpers/LevelRemoveHelper.java
+++ b/src/fr/enssat/BoulderDash/helpers/LevelRemoveHelper.java
@@ -5,12 +5,12 @@ import java.io.File;
/**
* LevelRemoveHelper
- *
+ *
* Proceeds level save routine
* Able to iterate on internal representation of a map and serialize it to XML
*
- * @author Valerian Saliou
- * @since 2015-06-21
+ * @author Valerian Saliou
+ * @since 2015-06-21
*/
public class LevelRemoveHelper {
private static String pathToDataStore = "./res/levels";
@@ -19,7 +19,7 @@ public class LevelRemoveHelper {
/**
* Class constructor
*
- * @param levelId Level identifier
+ * @param levelId Level identifier
*/
public LevelRemoveHelper(String levelId) {
this.levelId = levelId;
@@ -31,7 +31,7 @@ public class LevelRemoveHelper {
/**
* Gets level storage path
*
- * @return Level path, with file extension
+ * @return Level path, with file extension
*/
private String getLevelPathInDataStore() {
return this.pathToDataStore + "/" + this.levelId + ".xml";
diff --git a/src/fr/enssat/BoulderDash/helpers/LevelSaveHelper.java b/src/fr/enssat/BoulderDash/helpers/LevelSaveHelper.java
index cbdc2eac..ed7f93d9 100644
--- a/src/fr/enssat/BoulderDash/helpers/LevelSaveHelper.java
+++ b/src/fr/enssat/BoulderDash/helpers/LevelSaveHelper.java
@@ -23,12 +23,12 @@ import fr.enssat.BoulderDash.models.DirtModel;
/**
* LevelSaveHelper
- *
+ *
* Proceeds level save routine
* Able to iterate on internal representation of a map and serialize it to XML
*
- * @author Valerian Saliou
- * @since 2015-06-21
+ * @author Valerian Saliou
+ * @since 2015-06-21
*/
public class LevelSaveHelper {
private static String pathToDataStore = "./res/levels";
@@ -39,8 +39,8 @@ public class LevelSaveHelper {
/**
* Class constructor
*
- * @param levelId Level identifier
- * @param groundGrid Ground grid
+ * @param levelId Level identifier
+ * @param groundGrid Ground grid
*/
public LevelSaveHelper(String levelId, DisplayableElementModel[][] groundGrid) {
this.setLevelId(levelId);
@@ -58,7 +58,7 @@ public class LevelSaveHelper {
/**
* Class constructor
*
- * @param groundGrid Ground grid
+ * @param groundGrid Ground grid
*/
public LevelSaveHelper(DisplayableElementModel[][] groundGrid) {
this(generateNewLevelId(), groundGrid);
@@ -67,7 +67,7 @@ public class LevelSaveHelper {
/**
* Gets level storage path
*
- * @return Level path, with file extension
+ * @return Level path, with file extension
*/
private String getLevelPathInDataStore() {
return this.pathToDataStore + "/" + this.getLevelId() + ".xml";
@@ -76,7 +76,7 @@ public class LevelSaveHelper {
/**
* Generates a new level identifier
*
- * @return Level identifier
+ * @return Level identifier
*/
private static String generateNewLevelId() {
File directory = new File(pathToDataStore);
@@ -93,13 +93,13 @@ public class LevelSaveHelper {
Pattern pattern = Pattern.compile("^level([0-9]+)\\.xml");
Matcher matcher;
- for (File file : fileList){
+ for (File file : fileList) {
matcher = pattern.matcher(file.getName());
if (matcher.matches()) {
matchedId = matcher.group(1);
- if(!matchedId.isEmpty()) {
+ if (!matchedId.isEmpty()) {
tempLevelId = new Integer(matchedId);
if (tempLevelId > electedLastLevelId) {
@@ -117,7 +117,7 @@ public class LevelSaveHelper {
electedLastLevelId += 1;
// Stringify
- if(electedLastLevelId < 10) {
+ if (electedLastLevelId < 10) {
finalLevelId = "0" + electedLastLevelId.toString();
} else {
finalLevelId = electedLastLevelId.toString();
@@ -156,8 +156,8 @@ public class LevelSaveHelper {
/**
* Writes the level document data to disk
*
- * @param document Document to be saved
- * @return Whether save was successful or not
+ * @param document Document to be saved
+ * @return Whether save was successful or not
*/
private boolean writeDocumentToDisk(Document document) {
boolean isSuccessful = true;
@@ -180,8 +180,8 @@ public class LevelSaveHelper {
/**
* Creates the name node
*
- * @param document Document
- * @return Name node
+ * @param document Document
+ * @return Name node
*/
private Node nameNode(Document document) {
String nameValue;
@@ -194,14 +194,14 @@ public class LevelSaveHelper {
/**
* Creates the date node
*
- * @param document Document
- * @return Date node
+ * @param document Document
+ * @return Date node
*/
private Node dateNode(Document document) {
// Get values
String dateCreatedValue, dateModifiedValue;
- dateCreatedValue = "0000-00-00/00:00:00";
+ dateCreatedValue = "0000-00-00/00:00:00";
dateModifiedValue = "0000-00-00/00:00:00";
// Create element
@@ -218,8 +218,8 @@ public class LevelSaveHelper {
/**
* Creates the size node
*
- * @param document Document
- * @return Size node
+ * @param document Document
+ * @return Size node
*/
private Node sizeNode(Document document) {
// Get values
@@ -227,11 +227,11 @@ public class LevelSaveHelper {
widthValue = this.getGroundGrid().length - 2;
- if(widthValue > 0) {
+ if (widthValue > 0) {
heightValue = this.getGroundGrid()[0].length - 2;
}
- if(heightValue < 0 || widthValue < 0) {
+ if (heightValue < 0 || widthValue < 0) {
heightValue = 0;
widthValue = 0;
}
@@ -248,15 +248,15 @@ public class LevelSaveHelper {
/**
* Creates the grid node
*
- * @param document Document
- * @return Grid node
+ * @param document Document
+ * @return Grid node
*/
private Node gridNode(Document document) {
Element gridElement = document.createElement("grid");
gridElement.setAttribute("state", "initial");
// Iterate in MATRIX:{x}
- if(this.getGroundGrid().length > 2) {
+ if (this.getGroundGrid().length > 2) {
// XML structure matrix is the inverse of the internal representation (hence the weird loop)
for (Integer curLineIndex = 1; curLineIndex < (this.getGroundGrid()[0].length - 1); curLineIndex++) {
gridElement.appendChild(this.gridLineNode(document, curLineIndex));
@@ -269,16 +269,16 @@ public class LevelSaveHelper {
/**
* Creates the grid line node
*
- * @param document Document
- * @param curLineIndex Current line index
- * @return Grid line node
+ * @param document Document
+ * @param curLineIndex Current line index
+ * @return Grid line node
*/
private Node gridLineNode(Document document, Integer curLineIndex) {
Element gridLineElement = document.createElement("line");
gridLineElement.setAttribute("index", Integer.toString(curLineIndex - 1));
// Iterate in MATRIX:X:{y}
- if(this.getGroundGrid().length > 2) {
+ if (this.getGroundGrid().length > 2) {
// XML structure matrix is the inverse of the internal representation (hence the weird loop)
for (Integer curItemIndex = 1; curItemIndex < (this.getGroundGrid().length - 1); curItemIndex++) {
gridLineElement.appendChild(this.gridLineItemNode(document, curLineIndex, curItemIndex));
@@ -291,10 +291,10 @@ public class LevelSaveHelper {
/**
* Creates the grid line item node
*
- * @param document Document
- * @param curLineIndex Current line index
- * @param curItemIndex Current line item index
- * @return Grid line item node
+ * @param document Document
+ * @param curLineIndex Current line index
+ * @param curItemIndex Current line item index
+ * @return Grid line item node
*/
private Node gridLineItemNode(Document document, Integer curLineIndex, Integer curItemIndex) {
Element gridLineItemElement = document.createElement("item");
@@ -308,10 +308,10 @@ public class LevelSaveHelper {
/**
* Creates the grid line sprite item node
*
- * @param document Document
- * @param curLineIndex Current line index
- * @param curItemIndex Current line item index
- * @return Grid line item sprite node
+ * @param document Document
+ * @param curLineIndex Current line index
+ * @param curItemIndex Current line item index
+ * @return Grid line item sprite node
*/
private Node gridLineItemSpriteNode(Document document, Integer curLineIndex, Integer curItemIndex) {
String groupValue, nameValue, stateValue, convertibleValue;
@@ -319,14 +319,14 @@ public class LevelSaveHelper {
DisplayableElementModel curGridElement = this.getGroundGrid()[curItemIndex][curLineIndex];
// Null?
- if(curGridElement == null) {
+ if (curGridElement == null) {
curGridElement = new DirtModel();
}
// Retrieve current values
- groupValue = curGridElement.getGroupName();
- nameValue = curGridElement.getSpriteName();
- stateValue = curGridElement.getStateValue();
+ groupValue = curGridElement.getGroupName();
+ nameValue = curGridElement.getSpriteName();
+ stateValue = curGridElement.getStateValue();
if (curGridElement.isConvertible()) {
convertibleValue = "1";
} else {
@@ -341,7 +341,7 @@ public class LevelSaveHelper {
gridLineItemSpriteElement.setAttribute("name", nameValue);
gridLineItemSpriteElement.setAttribute("state", stateValue);
- if("1".equals(convertibleValue)) {
+ if ("1".equals(convertibleValue)) {
gridLineItemSpriteElement.setAttribute("convertible", convertibleValue);
}
@@ -351,10 +351,10 @@ public class LevelSaveHelper {
/**
* Creates a bare text node
*
- * @param document Document
- * @param name Element name
- * @param value Element value
- * @return Text node
+ * @param document Document
+ * @param name Element name
+ * @param value Element value
+ * @return Text node
*/
private Node textNode(Document document, String name, String value) {
Element node = document.createElement(name);
@@ -366,7 +366,7 @@ public class LevelSaveHelper {
/**
* Gets the level identifier
*
- * @return Level identifier
+ * @return Level identifier
*/
public String getLevelId() {
return this.levelId;
@@ -375,7 +375,7 @@ public class LevelSaveHelper {
/**
* Sets the level identifier
*
- * @param levelId Level identifier
+ * @param levelId Level identifier
*/
private void setLevelId(String levelId) {
this.levelId = levelId;
@@ -384,7 +384,7 @@ public class LevelSaveHelper {
/**
* Gets the ground grid
*
- * @return Ground grid
+ * @return Ground grid
*/
public DisplayableElementModel[][] getGroundGrid() {
return this.groundGrid;
@@ -393,7 +393,7 @@ public class LevelSaveHelper {
/**
* Sets the ground grid
*
- * @param groundGrid Ground grid
+ * @param groundGrid Ground grid
*/
private void setGroundGrid(DisplayableElementModel[][] groundGrid) {
this.groundGrid = groundGrid;
diff --git a/src/fr/enssat/BoulderDash/helpers/LevelSelectorHelper.java b/src/fr/enssat/BoulderDash/helpers/LevelSelectorHelper.java
index 511c6572..4db2bae6 100644
--- a/src/fr/enssat/BoulderDash/helpers/LevelSelectorHelper.java
+++ b/src/fr/enssat/BoulderDash/helpers/LevelSelectorHelper.java
@@ -10,11 +10,11 @@ import java.util.List;
/**
* LevelSelectorHelper
- *
+ *
* Level selector helper
*
- * @author Valerian Saliou
- * @since 2015-06-23
+ * @author Valerian Saliou
+ * @since 2015-06-23
*/
public class LevelSelectorHelper {
private static String levelStorage = "./res/levels";
@@ -37,7 +37,7 @@ public class LevelSelectorHelper {
/**
* Creates the level list
*
- * @return Level list selector
+ * @return Level list selector
*/
public MenuLevelSelector createLevelList() {
String[] availableLevels = this.listAvailableLevels();
@@ -45,10 +45,11 @@ public class LevelSelectorHelper {
// Proceed available levels listing
MenuLevelSelector menuLevelList = new MenuLevelSelector(availableLevels, this.levelEditorView);
- if(availableLevels.length > 0) {
+ if (availableLevels.length > 0) {
menuLevelList.setChoiceValue(availableLevels[0]);
menuLevelList.setSelectedIndex(0);
- };
+ }
+ ;
menuLevelList.addActionListener(menuLevelList);
@@ -58,7 +59,7 @@ public class LevelSelectorHelper {
/**
* Lists available levels and store them in instance context
*
- * @return Available levels
+ * @return Available levels
*/
private String[] listAvailableLevels() {
List stockList = new ArrayList();
@@ -69,18 +70,18 @@ public class LevelSelectorHelper {
int fileNameExtIndex;
// Add empty element?
- if(this.hasEmptyElement) {
+ if (this.hasEmptyElement) {
stockList.add("");
}
- for (File file : fileList){
+ for (File file : fileList) {
fileName = file.getName();
fileNameExtIndex = fileName.lastIndexOf('.');
if (fileNameExtIndex > 0) {
fileNameExtValue = fileName.substring(fileNameExtIndex, fileName.length());
- if(fileNameExtValue.equals(".xml")) {
+ if (fileNameExtValue.equals(".xml")) {
fileName = fileName.substring(0, fileNameExtIndex);
stockList.add(fileName);
}
diff --git a/src/fr/enssat/BoulderDash/helpers/ModelConvertHelper.java b/src/fr/enssat/BoulderDash/helpers/ModelConvertHelper.java
index 2856a412..8eb52bef 100644
--- a/src/fr/enssat/BoulderDash/helpers/ModelConvertHelper.java
+++ b/src/fr/enssat/BoulderDash/helpers/ModelConvertHelper.java
@@ -16,11 +16,11 @@ import fr.enssat.BoulderDash.models.SteelWallModel;
/**
* ModelConvertHelper
- *
+ *
* Provides model conversion services.
*
- * @author Valerian Saliou
- * @since 2015-06-22
+ * @author Valerian Saliou
+ * @since 2015-06-22
*/
public class ModelConvertHelper {
/**
@@ -33,8 +33,8 @@ public class ModelConvertHelper {
/**
* Gets the model associated to the string
*
- * @param spriteName Sprite name
- * @return Model associated to given sprite name
+ * @param spriteName Sprite name
+ * @return Model associated to given sprite name
*/
public DisplayableElementModel toModel(String spriteName, boolean isConvertible) throws UnknownModelException {
DisplayableElementModel element;
@@ -96,7 +96,7 @@ public class ModelConvertHelper {
/**
* Gets the string associated to the model
*
- * @return Model string name
+ * @return Model string name
*/
public String toString(DisplayableElementModel model) {
return model.getSpriteName();
diff --git a/src/fr/enssat/BoulderDash/models/BoulderModel.java b/src/fr/enssat/BoulderDash/models/BoulderModel.java
index ad29b564..7befc9fb 100644
--- a/src/fr/enssat/BoulderDash/models/BoulderModel.java
+++ b/src/fr/enssat/BoulderDash/models/BoulderModel.java
@@ -5,42 +5,42 @@ import fr.enssat.BoulderDash.models.DisplayableElementModel;
/**
* BoulderModel
- *
+ *
* Represents the boulders.
*
- * @author Colin Leverger
- * @since 2015-06-19
+ * @author Colin Leverger
+ * @since 2015-06-19
*/
public class BoulderModel extends DisplayableElementModel {
- private static String spriteName;
- private static boolean isDestructible;
- private static boolean canMove;
- private static boolean impactExplosive;
- private static boolean animate;
- private static int priority;
- private static String collideSound;
+ private static String spriteName;
+ private static boolean isDestructible;
+ private static boolean canMove;
+ private static boolean impactExplosive;
+ private static boolean animate;
+ private static int priority;
+ private static String collideSound;
/**
* Static dataset
* Specifies the physical parameters of the object
*/
- static {
- spriteName = "boulder";
- isDestructible = false;
- canMove = true;
- impactExplosive = false;
- animate = true;
- priority = 2;
- collideSound = "die";
- }
+ static {
+ spriteName = "boulder";
+ isDestructible = false;
+ canMove = true;
+ impactExplosive = false;
+ animate = true;
+ priority = 2;
+ collideSound = "die";
+ }
/**
* Class constructor
*/
- public BoulderModel(boolean convertible) {
- super(isDestructible, canMove, spriteName, priority, impactExplosive, animate, false, collideSound, convertible);
+ public BoulderModel(boolean convertible) {
+ super(isDestructible, canMove, spriteName, priority, impactExplosive, animate, false, collideSound, convertible);
this.loadSprite(spriteName);
- }
+ }
public BoulderModel() {
this(false);
diff --git a/src/fr/enssat/BoulderDash/models/BrickWallModel.java b/src/fr/enssat/BoulderDash/models/BrickWallModel.java
index 15269b39..3da39e99 100644
--- a/src/fr/enssat/BoulderDash/models/BrickWallModel.java
+++ b/src/fr/enssat/BoulderDash/models/BrickWallModel.java
@@ -5,42 +5,42 @@ import fr.enssat.BoulderDash.models.DisplayableElementModel;
/**
* BrickWallModel
- *
+ *
* Represents the brick wall in the game.
*
- * @author Colin Leverger
- * @since 2015-06-19
+ * @author Colin Leverger
+ * @since 2015-06-19
*/
public class BrickWallModel extends DisplayableElementModel {
- private static String spriteName;
- private static boolean isDestructible;
- private static boolean canMove;
- private static boolean impactExplosive;
- private static boolean animate;
- private static int priority;
- private static boolean falling;
- private static String collideSound;
+ private static String spriteName;
+ private static boolean isDestructible;
+ private static boolean canMove;
+ private static boolean impactExplosive;
+ private static boolean animate;
+ private static int priority;
+ private static boolean falling;
+ private static String collideSound;
/**
* Static dataset
* Specifies the physical parameters of the object
*/
- static {
- spriteName = "brickwall";
- isDestructible = true;
- canMove = false;
- impactExplosive = false;
- animate = false;
- priority = 3;
- falling = false;
- collideSound = "touch";
- }
+ static {
+ spriteName = "brickwall";
+ isDestructible = true;
+ canMove = false;
+ impactExplosive = false;
+ animate = false;
+ priority = 3;
+ falling = false;
+ collideSound = "touch";
+ }
/**
* Class constructor
*/
- public BrickWallModel() {
- super(isDestructible, canMove, spriteName, priority, impactExplosive, animate, falling, collideSound);
+ public BrickWallModel() {
+ super(isDestructible, canMove, spriteName, priority, impactExplosive, animate, falling, collideSound);
this.loadSprite(spriteName);
- }
+ }
}
diff --git a/src/fr/enssat/BoulderDash/models/CursorModel.java b/src/fr/enssat/BoulderDash/models/CursorModel.java
index 1e7ba34a..2cf76b22 100644
--- a/src/fr/enssat/BoulderDash/models/CursorModel.java
+++ b/src/fr/enssat/BoulderDash/models/CursorModel.java
@@ -5,11 +5,11 @@ import fr.enssat.BoulderDash.models.DisplayableElementModel;
/**
* CursorModel
- *
+ *
* Represents the field cursor pointer.
*
- * @author Valerian Saliou
- * @since 2015-06-22
+ * @author Valerian Saliou
+ * @since 2015-06-22
*/
public class CursorModel extends DisplayableElementModel {
private static String spriteName;
diff --git a/src/fr/enssat/BoulderDash/models/DiamondModel.java b/src/fr/enssat/BoulderDash/models/DiamondModel.java
index ba1dbab5..63756725 100644
--- a/src/fr/enssat/BoulderDash/models/DiamondModel.java
+++ b/src/fr/enssat/BoulderDash/models/DiamondModel.java
@@ -8,83 +8,83 @@ import fr.enssat.BoulderDash.models.DisplayableElementModel;
/**
* DiamondModel
- *
+ *
* Represents a diamond in the game.
*
- * @author Colin Leverger
- * @since 2015-06-19
+ * @author Colin Leverger
+ * @since 2015-06-19
*/
public class DiamondModel extends DisplayableElementModel {
- private static String spriteName;
- private static boolean isDestructible;
- private static boolean canMove;
- private static boolean impactExplosive;
- private static boolean animate;
- private static int priority;
- private static String collideSound;
- private long previousTime;
- private int currentFrame;
+ private static String spriteName;
+ private static boolean isDestructible;
+ private static boolean canMove;
+ private static boolean impactExplosive;
+ private static boolean animate;
+ private static int priority;
+ private static String collideSound;
+ private long previousTime;
+ private int currentFrame;
- private final int SIZ_X_OF_SPRITE = 16;
- private final int SIZ_Y_OF_SPRITE = 16;
- private long speed;
+ private final int SIZ_X_OF_SPRITE = 16;
+ private final int SIZ_Y_OF_SPRITE = 16;
+ private long speed;
- private ArrayList framesDiamond;
+ private ArrayList framesDiamond;
/**
* Static dataset
* Specifies the physical parameters of the object
*/
- static {
- spriteName = "diamond";
- isDestructible = true;
- canMove = true;
- impactExplosive = false;
- animate = true;
- priority = 0;
- collideSound = "coin";
- }
+ static {
+ spriteName = "diamond";
+ isDestructible = true;
+ canMove = true;
+ impactExplosive = false;
+ animate = true;
+ priority = 0;
+ collideSound = "coin";
+ }
/**
* Class constructor
*/
- public DiamondModel() {
- super(isDestructible, canMove, spriteName, priority, impactExplosive, animate, false, collideSound);
+ public DiamondModel() {
+ super(isDestructible, canMove, spriteName, priority, impactExplosive, animate, false, collideSound);
- this.initSprites();
- }
+ this.initSprites();
+ }
/**
* Updates the sprite (animation loop)
*
- * @param time Current time
+ * @param time Current time
*/
- public void update(long time) {
- if (time - previousTime >= speed) {
- // Update the animation
- previousTime = time;
+ public void update(long time) {
+ if (time - previousTime >= speed) {
+ // Update the animation
+ previousTime = time;
try {
- this.currentFrame += 1;
+ this.currentFrame += 1;
this.setSprite(framesDiamond.get(this.currentFrame));
- } catch (IndexOutOfBoundsException e) {
- this.currentFrame = 0;
- }
- }
- }
+ } catch (IndexOutOfBoundsException e) {
+ this.currentFrame = 0;
+ }
+ }
+ }
/**
* Initialize the sprites
* This is an animated element, hence this method
*/
- private void initSprites() {
- /* Initialize object sprites */
- this.framesDiamond = new ArrayList();
+ private void initSprites() {
+ /* Initialize object sprites */
+ this.framesDiamond = new ArrayList();
- for (int i = 0; i < 8; i++) {
+ for (int i = 0; i < 8; i++) {
this.framesDiamond.add(
this.grabSprite(loadSprite(spriteName), i * 24, 0, SIZ_X_OF_SPRITE, SIZ_Y_OF_SPRITE)
);
- }
- }
+ }
+ }
}
\ No newline at end of file
diff --git a/src/fr/enssat/BoulderDash/models/DirtModel.java b/src/fr/enssat/BoulderDash/models/DirtModel.java
index c0635c9b..aeb14a27 100644
--- a/src/fr/enssat/BoulderDash/models/DirtModel.java
+++ b/src/fr/enssat/BoulderDash/models/DirtModel.java
@@ -5,43 +5,43 @@ import fr.enssat.BoulderDash.models.DisplayableElementModel;
/**
* DirtModel
- *
+ *
* Represents the dirt in the game.
*
- * @author Colin Leverger
- * @since 2015-06-19
+ * @author Colin Leverger
+ * @since 2015-06-19
*/
public class DirtModel extends DisplayableElementModel {
- private static String spriteName;
- private static boolean isDestructible;
- private static boolean canMove;
- private static boolean impactExplosive;
- private static boolean animate;
- private static int priority;
- private static boolean falling;
- private static String collideSound;
-
+ private static String spriteName;
+ private static boolean isDestructible;
+ private static boolean canMove;
+ private static boolean impactExplosive;
+ private static boolean animate;
+ private static int priority;
+ private static boolean falling;
+ private static String collideSound;
+
/**
* Static dataset
* Specifies the physical parameters of the object
*/
- static {
- spriteName = "dirt";
- isDestructible = true;
- canMove = false;
- impactExplosive = false;
- animate = false;
- priority = 0;
- falling = false;
- collideSound = null;
- }
+ static {
+ spriteName = "dirt";
+ isDestructible = true;
+ canMove = false;
+ impactExplosive = false;
+ animate = false;
+ priority = 0;
+ falling = false;
+ collideSound = null;
+ }
/**
* Class constructor
*/
- public DirtModel() {
- super(isDestructible, canMove, spriteName, priority, impactExplosive, animate, falling, collideSound);
+ public DirtModel() {
+ super(isDestructible, canMove, spriteName, priority, impactExplosive, animate, falling, collideSound);
this.loadSprite(spriteName);
- }
+ }
}
\ No newline at end of file
diff --git a/src/fr/enssat/BoulderDash/models/DisplayableElementModel.java b/src/fr/enssat/BoulderDash/models/DisplayableElementModel.java
index dd0bf8c1..0bee6293 100644
--- a/src/fr/enssat/BoulderDash/models/DisplayableElementModel.java
+++ b/src/fr/enssat/BoulderDash/models/DisplayableElementModel.java
@@ -8,59 +8,59 @@ import java.io.IOException;
/**
* DisplayableElementModel
- *
+ *
* Represents a abstract displayable element
*
- * @author Colin Leverger
- * @since 2015-06-19
+ * @author Colin Leverger
+ * @since 2015-06-19
*/
public abstract class DisplayableElementModel {
- private static String spriteStorageFolderPath = "./res/drawable/field/";
+ private static String spriteStorageFolderPath = "./res/drawable/field/";
- private static String groupName;
- private static String stateValue;
+ private static String groupName;
+ private static String stateValue;
- private boolean destructible;
- private boolean moving;
- private boolean animate;
- private boolean impactExplosive;
- private String spriteName;
- private int priority;
- private BufferedImage sprite;
+ private boolean destructible;
+ private boolean moving;
+ private boolean animate;
+ private boolean impactExplosive;
+ private String spriteName;
+ private int priority;
+ private BufferedImage sprite;
private boolean falling;
- private boolean convertible;
- private String collideSound;
+ private boolean convertible;
+ private String collideSound;
- /**
- * Static dataset
- */
- static {
- groupName = "field";
- stateValue = "initial";
- }
+ /**
+ * Static dataset
+ */
+ static {
+ groupName = "field";
+ stateValue = "initial";
+ }
- /**
+ /**
* Class constructor
*
- * @param destructible Object destructible?
- * @param moving Object is moving?
- * @param spriteName Object sprite name?
- * @param priority Object priority?
- * @param impactExplosive Object explodes on impact?
- * @param animate Object can be animated?
- */
- public DisplayableElementModel(boolean destructible, boolean moving, String spriteName, int priority, boolean impactExplosive, boolean animate, boolean falling, String collideSound, boolean convertible) {
- this.moving = moving;
- this.destructible = destructible;
- this.spriteName = spriteName;
- this.priority = priority;
- this.animate = animate;
- this.impactExplosive = impactExplosive;
- this.priority = priority;
- this.falling = falling;
+ * @param destructible Object destructible?
+ * @param moving Object is moving?
+ * @param spriteName Object sprite name?
+ * @param priority Object priority?
+ * @param impactExplosive Object explodes on impact?
+ * @param animate Object can be animated?
+ */
+ public DisplayableElementModel(boolean destructible, boolean moving, String spriteName, int priority, boolean impactExplosive, boolean animate, boolean falling, String collideSound, boolean convertible) {
+ this.moving = moving;
+ this.destructible = destructible;
+ this.spriteName = spriteName;
+ this.priority = priority;
+ this.animate = animate;
+ this.impactExplosive = impactExplosive;
+ this.priority = priority;
+ this.falling = falling;
this.convertible = convertible;
- this.collideSound = collideSound;
- }
+ this.collideSound = collideSound;
+ }
public DisplayableElementModel(boolean destructible, boolean moving, String spriteName, int priority, boolean impactExplosive, boolean animate, boolean falling, String collideSound) {
this(
@@ -71,179 +71,179 @@ public abstract class DisplayableElementModel {
/**
* Gets the 'destructible' value
*
- * @return Whether object is destructible or not
- */
- public boolean isDestructible() {
- return this.destructible;
- }
+ * @return Whether object is destructible or not
+ */
+ public boolean isDestructible() {
+ return this.destructible;
+ }
- /**
- * Gets the 'moving' value
+ /**
+ * Gets the 'moving' value
*
- * @return Whether object is moving or not
- */
- public boolean isMoving() {
- return this.moving;
- }
+ * @return Whether object is moving or not
+ */
+ public boolean isMoving() {
+ return this.moving;
+ }
- /**
- * Gets the group name value
- *
- * @return Group name value
- */
- public String getGroupName() {
- return this.groupName;
- }
-
- /**
- * Gets the state value
- *
- * @return State value
- */
- public String getStateValue() {
- return this.stateValue;
- }
-
- /**
- * Gets the sprite name value
+ /**
+ * Gets the group name value
*
- * @return Sprite name value
- */
- public String getSpriteName() {
- return this.spriteName;
- }
+ * @return Group name value
+ */
+ public String getGroupName() {
+ return this.groupName;
+ }
- /**
- * Gets the folder path of the sprite storage
+ /**
+ * Gets the state value
*
- * @return Folder path of the sprite storage
- */
- private static String getSpriteStorageFolderPath() {
- return spriteStorageFolderPath;
- }
+ * @return State value
+ */
+ public String getStateValue() {
+ return this.stateValue;
+ }
- /**
- * Gets the path to the sprite file in storage
+ /**
+ * Gets the sprite name value
*
- * @return Path to the sprite file in storage
- */
- public String getPathToSprite() {
- return getSpriteStorageFolderPath() + getSpriteName() + ".gif";
- }
+ * @return Sprite name value
+ */
+ public String getSpriteName() {
+ return this.spriteName;
+ }
- /**
- * Gets the priority of the object
+ /**
+ * Gets the folder path of the sprite storage
*
- * @return Object priority
- */
- public int getPriority() {
- return this.priority;
- }
-
- /**
+ * @return Folder path of the sprite storage
+ */
+ private static String getSpriteStorageFolderPath() {
+ return spriteStorageFolderPath;
+ }
+
+ /**
+ * Gets the path to the sprite file in storage
+ *
+ * @return Path to the sprite file in storage
+ */
+ public String getPathToSprite() {
+ return getSpriteStorageFolderPath() + getSpriteName() + ".gif";
+ }
+
+ /**
+ * Gets the priority of the object
+ *
+ * @return Object priority
+ */
+ public int getPriority() {
+ return this.priority;
+ }
+
+ /**
* Sets the priority of the object
*
- * @param priority Object priority
- */
- public void setPriority(int priority) {
- this.priority = priority;
- }
+ * @param priority Object priority
+ */
+ public void setPriority(int priority) {
+ this.priority = priority;
+ }
- /**
- * Gets the 'animate' value
+ /**
+ * Gets the 'animate' value
*
- * @return Whether object is animated or not
- */
- public boolean isAnimate() {
- return this.animate;
- }
+ * @return Whether object is animated or not
+ */
+ public boolean isAnimate() {
+ return this.animate;
+ }
- /**
- * Sets the 'animate' value
+ /**
+ * Sets the 'animate' value
*
- * @return animate Whether object is animated or not
- */
- public void setAnimate(boolean animate) {
- this.animate = animate;
- }
+ * @return animate Whether object is animated or not
+ */
+ public void setAnimate(boolean animate) {
+ this.animate = animate;
+ }
- /**
- * Gets the 'impact explosive' value
+ /**
+ * Gets the 'impact explosive' value
*
- * @return Whether object explodes on impact or not
- */
- public boolean isImpactExplosive() {
- return this.impactExplosive;
- }
+ * @return Whether object explodes on impact or not
+ */
+ public boolean isImpactExplosive() {
+ return this.impactExplosive;
+ }
- /**
- * Sets the 'impact explosive' value
+ /**
+ * Sets the 'impact explosive' value
*
- * @return impactExplosive Whether object explodes on impact or not
- */
- public void setImpactExplosive(boolean impactExplosive) {
- this.impactExplosive = impactExplosive;
- }
-
- /**
- * Sets the sprite
+ * @return impactExplosive Whether object explodes on impact or not
+ */
+ public void setImpactExplosive(boolean impactExplosive) {
+ this.impactExplosive = impactExplosive;
+ }
+
+ /**
+ * Sets the sprite
*
- * @param sprite Sprite object
- */
- public void setSprite(BufferedImage sprite) {
- this.sprite = sprite;
- }
+ * @param sprite Sprite object
+ */
+ public void setSprite(BufferedImage sprite) {
+ this.sprite = sprite;
+ }
/**
* Gets the sprite
*
- * @return Sprite object
+ * @return Sprite object
*/
- public BufferedImage getSprite() {
- return sprite;
- }
+ public BufferedImage getSprite() {
+ return sprite;
+ }
/**
* Loads the target sprite
*
- * @param spriteName Sprite name
- * @return Sprite object
+ * @param spriteName Sprite name
+ * @return Sprite object
*/
- public BufferedImage loadSprite(String spriteName) {
- BufferedImage sprite = null;
+ public BufferedImage loadSprite(String spriteName) {
+ BufferedImage sprite = null;
- try {
- sprite = ImageIO.read(new File("res/drawable/field/" + spriteName + ".gif"));
- } catch (IOException e) {
- e.printStackTrace();
- }
+ try {
+ sprite = ImageIO.read(new File("res/drawable/field/" + spriteName + ".gif"));
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
- this.sprite = sprite;
+ this.sprite = sprite;
- return sprite;
- }
+ return sprite;
+ }
- /**
- * Grabs the sprite from the large image containing all the static sprites items
+ /**
+ * Grabs the sprite from the large image containing all the static sprites items
*
- * @param spriteSheet Sprite sheet instance
- * @param x Sub image horizontal offset on sprite sheet
- * @param y Sub image vertical offset on sprite sheet
- * @param width Sub image width on sprite sheet
- * @param height Sub image height on sprite sheet
- * @return Target sub image
- */
- public BufferedImage grabSprite(BufferedImage spriteSheet, int x, int y, int width, int height) {
- BufferedImage subImage = spriteSheet.getSubimage(x, y, width, height);
+ * @param spriteSheet Sprite sheet instance
+ * @param x Sub image horizontal offset on sprite sheet
+ * @param y Sub image vertical offset on sprite sheet
+ * @param width Sub image width on sprite sheet
+ * @param height Sub image height on sprite sheet
+ * @return Target sub image
+ */
+ public BufferedImage grabSprite(BufferedImage spriteSheet, int x, int y, int width, int height) {
+ BufferedImage subImage = spriteSheet.getSubimage(x, y, width, height);
- this.sprite = subImage;
- return subImage;
- }
+ this.sprite = subImage;
+ return subImage;
+ }
/**
* Gets the falling state of the object
*
- * @return Whether object is falling or not
+ * @return Whether object is falling or not
*/
public boolean isFalling() {
return this.falling;
@@ -252,7 +252,7 @@ public abstract class DisplayableElementModel {
/**
* Sets the falling state of the object
*
- * @param falling Whether object is falling or not
+ * @param falling Whether object is falling or not
*/
public void setFalling(boolean falling) {
this.falling = falling;
@@ -261,7 +261,7 @@ public abstract class DisplayableElementModel {
/**
* Gets the collide sound of the object
*
- * @return Collide sound
+ * @return Collide sound
*/
public String getCollideSound() {
return this.collideSound;
@@ -270,7 +270,7 @@ public abstract class DisplayableElementModel {
/**
* Sets the collide sound of the object
*
- * @param collideSound Collide sound
+ * @param collideSound Collide sound
*/
public void setCollideSound(String collideSound) {
this.collideSound = collideSound;
@@ -279,7 +279,7 @@ public abstract class DisplayableElementModel {
/**
* Gets the convertible value of the object
*
- * @return Convertible value
+ * @return Convertible value
*/
public boolean isConvertible() {
return this.convertible;
@@ -288,15 +288,17 @@ public abstract class DisplayableElementModel {
/**
* Sets the convertible value of the object
*
- * @param convertible Convertible value
+ * @param convertible Convertible value
*/
public void setConvertibleValue(boolean convertible) {
this.convertible = convertible;
}
-
- /**
- * Function to update the sprites
- * @param currentTimeMillis Current time in milliseconds
- */
- public void update(long currentTimeMillis) {}
+
+ /**
+ * Function to update the sprites
+ *
+ * @param currentTimeMillis Current time in milliseconds
+ */
+ public void update(long currentTimeMillis) {
+ }
}
diff --git a/src/fr/enssat/BoulderDash/models/DoorModel.java b/src/fr/enssat/BoulderDash/models/DoorModel.java
index 26f0f039..c64fcefb 100644
--- a/src/fr/enssat/BoulderDash/models/DoorModel.java
+++ b/src/fr/enssat/BoulderDash/models/DoorModel.java
@@ -5,43 +5,43 @@ import fr.enssat.BoulderDash.models.DisplayableElementModel;
/**
* DoorModel
- *
+ *
* Represents escape door.
*
- * @author Colin Leverger
- * @since 2015-06-19
+ * @author Colin Leverger
+ * @since 2015-06-19
*/
public class DoorModel extends DisplayableElementModel {
- private static String spriteName;
- private static boolean isDestructible;
- private static boolean canMove;
- private static boolean impactExplosive;
- private static boolean animate;
- private static int priority;
- private static boolean falling;
- private static String collideSound;
+ private static String spriteName;
+ private static boolean isDestructible;
+ private static boolean canMove;
+ private static boolean impactExplosive;
+ private static boolean animate;
+ private static int priority;
+ private static boolean falling;
+ private static String collideSound;
/**
* Static dataset
* Specifies the physical parameters of the object
*/
- static {
- spriteName = "door";
- isDestructible = false;
- canMove = false;
- impactExplosive = false;
- animate = false;
- priority = 0;
- falling = false;
- collideSound = null;
- }
+ static {
+ spriteName = "door";
+ isDestructible = false;
+ canMove = false;
+ impactExplosive = false;
+ animate = false;
+ priority = 0;
+ falling = false;
+ collideSound = null;
+ }
/**
* Class constructor
*/
- public DoorModel() {
- super(isDestructible, canMove, spriteName, priority, impactExplosive, animate, falling, collideSound);
+ public DoorModel() {
+ super(isDestructible, canMove, spriteName, priority, impactExplosive, animate, falling, collideSound);
- this.loadSprite(spriteName);
- }
+ this.loadSprite(spriteName);
+ }
}
diff --git a/src/fr/enssat/BoulderDash/models/EmptyModel.java b/src/fr/enssat/BoulderDash/models/EmptyModel.java
index 4f538009..505f286c 100644
--- a/src/fr/enssat/BoulderDash/models/EmptyModel.java
+++ b/src/fr/enssat/BoulderDash/models/EmptyModel.java
@@ -5,43 +5,43 @@ import fr.enssat.BoulderDash.models.DisplayableElementModel;
/**
* EmptyModel
- *
+ *
* Represents "nothing".
*
- * @author Colin Leverger
- * @since 2015-06-19
+ * @author Colin Leverger
+ * @since 2015-06-19
*/
public class EmptyModel extends DisplayableElementModel {
- private static String spriteName;
- private static boolean isDestructible;
- private static boolean canMove;
- private static boolean impactExplosive;
- private static boolean animate;
- private static int priority;
- private static boolean falling;
- private static String collideSound;
+ private static String spriteName;
+ private static boolean isDestructible;
+ private static boolean canMove;
+ private static boolean impactExplosive;
+ private static boolean animate;
+ private static int priority;
+ private static boolean falling;
+ private static String collideSound;
/**
* Static dataset
* Specifies the physical parameters of the object
*/
- static {
- spriteName = "black";
- isDestructible = false;
- canMove = false;
- impactExplosive = false;
- animate = false;
- priority = 0;
- falling = false;
- collideSound = null;
- }
+ static {
+ spriteName = "black";
+ isDestructible = false;
+ canMove = false;
+ impactExplosive = false;
+ animate = false;
+ priority = 0;
+ falling = false;
+ collideSound = null;
+ }
/**
* Class constructor
*/
- public EmptyModel() {
- super(isDestructible, canMove, spriteName, priority, impactExplosive, animate, falling, collideSound);
+ public EmptyModel() {
+ super(isDestructible, canMove, spriteName, priority, impactExplosive, animate, falling, collideSound);
- this.loadSprite(spriteName);
- }
+ this.loadSprite(spriteName);
+ }
}
diff --git a/src/fr/enssat/BoulderDash/models/ExpandingWallModel.java b/src/fr/enssat/BoulderDash/models/ExpandingWallModel.java
index f0be9ce5..edd642de 100644
--- a/src/fr/enssat/BoulderDash/models/ExpandingWallModel.java
+++ b/src/fr/enssat/BoulderDash/models/ExpandingWallModel.java
@@ -5,42 +5,42 @@ import fr.enssat.BoulderDash.models.DisplayableElementModel;
/**
* ExpandingWallModel
- *
+ *
* Represents a ExpandingWall in the game.
*
- * @author Colin Leverger
- * @since 2015-06-19
+ * @author Colin Leverger
+ * @since 2015-06-19
*/
public class ExpandingWallModel extends DisplayableElementModel {
- private static String spriteName;
- private static boolean destructible;
- private static boolean canMove;
- private static boolean impactExplosive;
- private static boolean animate;
- private static int priority;
- private static boolean falling;
- private static String collideSound;
-
- /*
- * Static dataset
- * Specifies the physical parameters of the object
- */
- static {
- spriteName = "expandingwall";
- destructible = false;
- canMove = false;
- impactExplosive = false;
- animate = false;
- priority = 10;
- falling = false;
- collideSound = null;
- }
-
+ private static String spriteName;
+ private static boolean destructible;
+ private static boolean canMove;
+ private static boolean impactExplosive;
+ private static boolean animate;
+ private static int priority;
+ private static boolean falling;
+ private static String collideSound;
+
+ /*
+ * Static dataset
+ * Specifies the physical parameters of the object
+ */
+ static {
+ spriteName = "expandingwall";
+ destructible = false;
+ canMove = false;
+ impactExplosive = false;
+ animate = false;
+ priority = 10;
+ falling = false;
+ collideSound = null;
+ }
+
/**
* Class constructor
*/
- public ExpandingWallModel() {
- super(destructible, canMove, spriteName, priority, impactExplosive, animate, falling, collideSound);
- this.loadSprite(spriteName);
- }
+ public ExpandingWallModel() {
+ super(destructible, canMove, spriteName, priority, impactExplosive, animate, falling, collideSound);
+ this.loadSprite(spriteName);
+ }
}
\ No newline at end of file
diff --git a/src/fr/enssat/BoulderDash/models/GameInformationModel.java b/src/fr/enssat/BoulderDash/models/GameInformationModel.java
index 2144237a..2b89ab4f 100644
--- a/src/fr/enssat/BoulderDash/models/GameInformationModel.java
+++ b/src/fr/enssat/BoulderDash/models/GameInformationModel.java
@@ -6,109 +6,108 @@ import java.util.Observable;
/**
* GameInformationModel will contain all the data which will
* go to the InformationPanel.
- *
- * @author Colin Leverger
- * @since 2015-06-19
- *
+ *
+ * @author Colin Leverger
+ * @since 2015-06-19
*/
-public class GameInformationModel extends Observable {
- private int score;
- private int remainingsDiamonds;
- private int timer;
+public class GameInformationModel extends Observable {
+ private int score;
+ private int remainingsDiamonds;
+ private int timer;
- public GameInformationModel(int remainingsDiamonds) {
- this.score = 0;
- this.remainingsDiamonds = remainingsDiamonds;
- this.timer = 0;
- }
+ public GameInformationModel(int remainingsDiamonds) {
+ this.score = 0;
+ this.remainingsDiamonds = remainingsDiamonds;
+ this.timer = 0;
+ }
- /**
- * Returns the actual score
+ /**
+ * Returns the actual score
*
- * @return score
- */
- public int getScore() {
- return score;
- }
+ * @return score
+ */
+ public int getScore() {
+ return score;
+ }
- /**
- * Sets the score
+ /**
+ * Sets the score
*
- * @param score Score
- */
- public void setScore(int score) {
- this.score = score;
- }
+ * @param score Score
+ */
+ public void setScore(int score) {
+ this.score = score;
+ }
- /**
- * Returns the actual number of remaining diamonds
+ /**
+ * Returns the actual number of remaining diamonds
*
- * @return Remaining diamonds
- */
- public int getRemainingsDiamonds() {
- return remainingsDiamonds;
- }
+ * @return Remaining diamonds
+ */
+ public int getRemainingsDiamonds() {
+ return remainingsDiamonds;
+ }
- /**
- * Sets the number of remainingDiamonds
+ /**
+ * Sets the number of remainingDiamonds
*
- * @param remainingDiamonds Remaining diamonds
- */
- public void setRemainingsDiamonds(int remainingDiamonds) {
- this.remainingsDiamonds = remainingDiamonds;
- }
+ * @param remainingDiamonds Remaining diamonds
+ */
+ public void setRemainingsDiamonds(int remainingDiamonds) {
+ this.remainingsDiamonds = remainingDiamonds;
+ }
/**
* Gets the timer
*
- * @return Timer
+ * @return Timer
*/
- public int getTimer() {
- return timer;
- }
+ public int getTimer() {
+ return timer;
+ }
/**
* Sets the timer
*
- * @param timer Timer
+ * @param timer Timer
*/
- public void setTimer(int timer) {
- this.timer = timer;
- }
+ public void setTimer(int timer) {
+ this.timer = timer;
+ }
- /**
- * Increments the score & notify observers
- */
- public void incrementScore() {
- this.score += 1;
- this.myNotify();
- }
-
- /**
- * Generic function which will notify the observers.
- */
- private void myNotify() {
- this.notifyObservers();
- this.setChanged();
- }
+ /**
+ * Increments the score & notify observers
+ */
+ public void incrementScore() {
+ this.score += 1;
+ this.myNotify();
+ }
- /**
- * Decrement of one the number total of remaining diamonds.
- */
- public void decrementRemainingsDiamonds() {
- if(remainingsDiamonds > 0){
- this.remainingsDiamonds -= 1;
- this.myNotify();
- }
- }
+ /**
+ * Generic function which will notify the observers.
+ */
+ private void myNotify() {
+ this.notifyObservers();
+ this.setChanged();
+ }
+
+ /**
+ * Decrement of one the number total of remaining diamonds.
+ */
+ public void decrementRemainingsDiamonds() {
+ if (remainingsDiamonds > 0) {
+ this.remainingsDiamonds -= 1;
+ this.myNotify();
+ }
+ }
/**
* Reset details about object
*/
- public void resetInformations() {
- this.score = 0;
- this.remainingsDiamonds = remainingsDiamonds;
- this.timer = 0;
- }
+ public void resetInformations() {
+ this.score = 0;
+ this.remainingsDiamonds = remainingsDiamonds;
+ this.timer = 0;
+ }
}
diff --git a/src/fr/enssat/BoulderDash/models/LevelModel.java b/src/fr/enssat/BoulderDash/models/LevelModel.java
index cbb5415a..3b133653 100644
--- a/src/fr/enssat/BoulderDash/models/LevelModel.java
+++ b/src/fr/enssat/BoulderDash/models/LevelModel.java
@@ -22,7 +22,7 @@ import java.util.Observable;
/**
* LevelModel
- *
+ *
* Levels are loaded from XML file. The view knows the model, the controller is
* going to modify the model in function of the game panel. The model notifies
* the view when there are changes on it.
@@ -31,344 +31,344 @@ import java.util.Observable;
* @since 2015-06-19
*/
public class LevelModel extends Observable implements Runnable {
- private DisplayableElementModel[][] groundGrid;
- private String levelName;
- private AudioLoadHelper audioLoadHelper;
- private int sizeWidth = 0;
- private int sizeHeight = 0;
- private int cursorXPosition = 0;
- private int cursorYPosition = 0;
- private boolean showCursor = false;
- private CursorModel cursorModel;
- private LevelLoadHelper levelLoadHelper;
- private RockfordModel rockford;
- private GameInformationModel gameInformationModel;
- private int rockfordPositionX, rockfordPositionY;
- private boolean gameRunning;
- private boolean gamePaused;
- // Are we in editor or game mode ?
- private String mode;
+ private DisplayableElementModel[][] groundGrid;
+ private String levelName;
+ private AudioLoadHelper audioLoadHelper;
+ private int sizeWidth = 0;
+ private int sizeHeight = 0;
+ private int cursorXPosition = 0;
+ private int cursorYPosition = 0;
+ private boolean showCursor = false;
+ private CursorModel cursorModel;
+ private LevelLoadHelper levelLoadHelper;
+ private RockfordModel rockford;
+ private GameInformationModel gameInformationModel;
+ private int rockfordPositionX, rockfordPositionY;
+ private boolean gameRunning;
+ private boolean gamePaused;
+ // Are we in editor or game mode ?
+ private String mode;
- /**
- * Sprite animation thread
- */
- private Thread spriteAnimator;
+ /**
+ * Sprite animation thread
+ */
+ private Thread spriteAnimator;
- /**
- * Animation speed
- */
- private final int DELAY = 25;
-
- /**
- * Class constructor
- *
- * @param levelName Level name
- * @param audioLoadHelper Audio load helper
- * @param mode Instance mode
- */
- public LevelModel(String levelName, AudioLoadHelper audioLoadHelper, String mode) {
- this.levelName = levelName;
- this.audioLoadHelper = audioLoadHelper;
- this.gamePaused = false;
- this.gameRunning = true;
- this.mode = mode;
-
- this.levelLoadHelper = new LevelLoadHelper(this.levelName);
-
- this.groundGrid = this.levelLoadHelper.getGroundGrid();
- this.sizeWidth = this.levelLoadHelper.getWidthSizeValue();
- this.sizeHeight = this.levelLoadHelper.getHeightSizeValue();
-
- this.cursorModel = new CursorModel();
- this.gameInformationModel = new GameInformationModel(this.levelLoadHelper.getDiamondsToCatch());
-
- this.createLimits();
-
- if(this.mode.equals("game")) {
- this.initRockford();
- this.initThreadAnimator();
- }
- }
+ /**
+ * Animation speed
+ */
+ private final int DELAY = 25;
/**
* Class constructor
*
- * @param levelName Level name
- * @param audioLoadHelper Audio load helper
+ * @param levelName Level name
+ * @param audioLoadHelper Audio load helper
+ * @param mode Instance mode
+ */
+ public LevelModel(String levelName, AudioLoadHelper audioLoadHelper, String mode) {
+ this.levelName = levelName;
+ this.audioLoadHelper = audioLoadHelper;
+ this.gamePaused = false;
+ this.gameRunning = true;
+ this.mode = mode;
+
+ this.levelLoadHelper = new LevelLoadHelper(this.levelName);
+
+ this.groundGrid = this.levelLoadHelper.getGroundGrid();
+ this.sizeWidth = this.levelLoadHelper.getWidthSizeValue();
+ this.sizeHeight = this.levelLoadHelper.getHeightSizeValue();
+
+ this.cursorModel = new CursorModel();
+ this.gameInformationModel = new GameInformationModel(this.levelLoadHelper.getDiamondsToCatch());
+
+ this.createLimits();
+
+ if (this.mode.equals("game")) {
+ this.initRockford();
+ this.initThreadAnimator();
+ }
+ }
+
+ /**
+ * Class constructor
+ *
+ * @param levelName Level name
+ * @param audioLoadHelper Audio load helper
*/
public LevelModel(String levelName, AudioLoadHelper audioLoadHelper) {
this(levelName, audioLoadHelper, "game");
}
- /**
- * Class constructor (editor mode)
- *
- * @param audioLoadHelper Audio load helper
- */
- public LevelModel(AudioLoadHelper audioLoadHelper) {
- this.audioLoadHelper = audioLoadHelper;
- this.gameRunning = false;
- this.mode = "editor";
+ /**
+ * Class constructor (editor mode)
+ *
+ * @param audioLoadHelper Audio load helper
+ */
+ public LevelModel(AudioLoadHelper audioLoadHelper) {
+ this.audioLoadHelper = audioLoadHelper;
+ this.gameRunning = false;
+ this.mode = "editor";
- this.sizeWidth = 25 + 2;
- this.sizeHeight = 25 + 2;
+ this.sizeWidth = 25 + 2;
+ this.sizeHeight = 25 + 2;
- // Generate dirt
- this.groundGrid = new DisplayableElementModel[this.sizeWidth][this.sizeHeight];
+ // Generate dirt
+ this.groundGrid = new DisplayableElementModel[this.sizeWidth][this.sizeHeight];
- for (int x = 0; x < this.sizeWidth; x++) {
- for (int y = 0; y < this.sizeHeight; y++) {
- this.groundGrid[x][y] = new DirtModel();
- }
- }
+ for (int x = 0; x < this.sizeWidth; x++) {
+ for (int y = 0; y < this.sizeHeight; y++) {
+ this.groundGrid[x][y] = new DirtModel();
+ }
+ }
- this.createLimits();
- }
+ this.createLimits();
+ }
- /**
- * Initializes the animator thread
- */
- private void initThreadAnimator() {
- this.spriteAnimator = new Thread(this);
- this.spriteAnimator.start();
- }
+ /**
+ * Initializes the animator thread
+ */
+ private void initThreadAnimator() {
+ this.spriteAnimator = new Thread(this);
+ this.spriteAnimator.start();
+ }
- /**
- * Initializes the Rockford position attributes
- */
- private void initRockford() {
- this.rockfordPositionX = this.levelLoadHelper.getRockfordPositionX();
- this.rockfordPositionY = this.levelLoadHelper.getRockfordPositionY();
- this.rockford = this.levelLoadHelper.getRockfordInstance();
- }
+ /**
+ * Initializes the Rockford position attributes
+ */
+ private void initRockford() {
+ this.rockfordPositionX = this.levelLoadHelper.getRockfordPositionX();
+ this.rockfordPositionY = this.levelLoadHelper.getRockfordPositionY();
+ this.rockford = this.levelLoadHelper.getRockfordInstance();
+ }
- /**
- * Creates the limits Puts steel walls all around the game panel
- */
- private void createLimits() {
- int maxWidth = this.sizeWidth - 1;
- int maxHeight = this.sizeHeight - 1;
+ /**
+ * Creates the limits Puts steel walls all around the game panel
+ */
+ private void createLimits() {
+ int maxWidth = this.sizeWidth - 1;
+ int maxHeight = this.sizeHeight - 1;
- for (int x = 0; x < this.sizeWidth; x++) {
- this.groundGrid[x][0] = new SteelWallModel();
- this.groundGrid[x][maxHeight] = new SteelWallModel();
- }
- for (int y = 0; y < this.sizeHeight; y++) {
- this.groundGrid[0][y] = new SteelWallModel();
- this.groundGrid[maxWidth][y] = new SteelWallModel();
- }
- }
+ for (int x = 0; x < this.sizeWidth; x++) {
+ this.groundGrid[x][0] = new SteelWallModel();
+ this.groundGrid[x][maxHeight] = new SteelWallModel();
+ }
+ for (int y = 0; y < this.sizeHeight; y++) {
+ this.groundGrid[0][y] = new SteelWallModel();
+ this.groundGrid[maxWidth][y] = new SteelWallModel();
+ }
+ }
- public void resetLevelModel() {
- this.groundGrid = this.levelLoadHelper.getGroundGrid();
- this.gameRunning = true;
- this.gameInformationModel.resetInformations();
- }
+ public void resetLevelModel() {
+ this.groundGrid = this.levelLoadHelper.getGroundGrid();
+ this.gameRunning = true;
+ this.gameInformationModel.resetInformations();
+ }
- /**
- * Updates the horizontal & vertical positions of Rockford in the model
- *
- * @param posX Horizontal position of Rockford
- * @param posY Vertical position of Rockford
- */
- public void updateRockfordPosition(int posX, int posY) {
- this.rockfordPositionY = posY;
- this.rockfordPositionX = posX;
- }
+ /**
+ * Updates the horizontal & vertical positions of Rockford in the model
+ *
+ * @param posX Horizontal position of Rockford
+ * @param posY Vertical position of Rockford
+ */
+ public void updateRockfordPosition(int posX, int posY) {
+ this.rockfordPositionY = posY;
+ this.rockfordPositionX = posX;
+ }
- /**
- * Checks whether position is out-of-bounds or not
- *
- * @param posX Horizontal position
- * @param posY Vertical position
- */
- private boolean isOutOfBounds(int posX, int posY) {
- if (posX > 0 && posY > 0 && posX < this.getLevelLoadHelper().getHeightSizeValue() && posY < this.getLevelLoadHelper().getWidthSizeValue()) {
- return false;
- }
+ /**
+ * Checks whether position is out-of-bounds or not
+ *
+ * @param posX Horizontal position
+ * @param posY Vertical position
+ */
+ private boolean isOutOfBounds(int posX, int posY) {
+ if (posX > 0 && posY > 0 && posX < this.getLevelLoadHelper().getHeightSizeValue() && posY < this.getLevelLoadHelper().getWidthSizeValue()) {
+ return false;
+ }
- return true;
- }
+ return true;
+ }
- /**
- * Plays collision sound
- */
- private void playCollisionSound(int posX, int posY) {
- String collisionSound = null;
+ /**
+ * Plays collision sound
+ */
+ private void playCollisionSound(int posX, int posY) {
+ String collisionSound = null;
- if (this.getRockford().isCollisionDone() == false) {
- // Out of bounds?
- if (this.isOutOfBounds(posX, posY) == true) {
- collisionSound = "touch";
- } else {
- DisplayableElementModel nextElement = this.groundGrid[posX][posY];
- collisionSound = nextElement.getCollideSound();
- }
+ if (this.getRockford().isCollisionDone() == false) {
+ // Out of bounds?
+ if (this.isOutOfBounds(posX, posY) == true) {
+ collisionSound = "touch";
+ } else {
+ DisplayableElementModel nextElement = this.groundGrid[posX][posY];
+ collisionSound = nextElement.getCollideSound();
+ }
- this.getRockford().setCollisionDone(true);
- }
+ this.getRockford().setCollisionDone(true);
+ }
- if (collisionSound != null) {
- this.audioLoadHelper.playSound(collisionSound);
- }
- }
+ if (collisionSound != null) {
+ this.audioLoadHelper.playSound(collisionSound);
+ }
+ }
- /**
- * Gets the horizontal position of Rockford from the model
- *
- * @return Horizontal position of Rockford
- */
- public int getRockfordPositionX() {
- return this.rockfordPositionX;
- }
+ /**
+ * Gets the horizontal position of Rockford from the model
+ *
+ * @return Horizontal position of Rockford
+ */
+ public int getRockfordPositionX() {
+ return this.rockfordPositionX;
+ }
- /**
- * Sets the new Rockford position
- *
- * @param posX Next horizontal position on the grid
- * @param posY Next vertical position on the grid
- */
- public void setPositionOfRockford(int posX, int posY) {
- int oldX = this.getRockfordPositionX();
- int oldY = this.getRockfordPositionY();
+ /**
+ * Sets the new Rockford position
+ *
+ * @param posX Next horizontal position on the grid
+ * @param posY Next vertical position on the grid
+ */
+ public void setPositionOfRockford(int posX, int posY) {
+ int oldX = this.getRockfordPositionX();
+ int oldY = this.getRockfordPositionY();
- if (this.groundGrid[posX][posY].getSpriteName() == "diamond") {
- this.gameInformationModel.incrementScore();
- this.gameInformationModel.decrementRemainingsDiamonds();
- if (this.gameInformationModel.getRemainingsDiamonds() == 0) {
- this.spawnExit();
- }
- }
- if (this.groundGrid[posX][posY].getSpriteName() == "door") {
- this.gameRunning = false;
- }
+ if (this.groundGrid[posX][posY].getSpriteName() == "diamond") {
+ this.gameInformationModel.incrementScore();
+ this.gameInformationModel.decrementRemainingsDiamonds();
+ if (this.gameInformationModel.getRemainingsDiamonds() == 0) {
+ this.spawnExit();
+ }
+ }
+ if (this.groundGrid[posX][posY].getSpriteName() == "door") {
+ this.gameRunning = false;
+ }
- this.playCollisionSound(posX, posY);
+ this.playCollisionSound(posX, posY);
- // Check that we are not out of bound...
- if (this.isOutOfBounds(posX, posY) == false) {
- // Create a new empty model in the old pos of Rockford
- this.groundGrid[oldX][oldY] = new EmptyModel();
+ // Check that we are not out of bound...
+ if (this.isOutOfBounds(posX, posY) == false) {
+ // Create a new empty model in the old pos of Rockford
+ this.groundGrid[oldX][oldY] = new EmptyModel();
- // Save the x / y pos of Rockford in the levelModel only
- this.updateRockfordPosition(posX, posY);
+ // Save the x / y pos of Rockford in the levelModel only
+ this.updateRockfordPosition(posX, posY);
- this.groundGrid[posX][posY] = this.getRockford();
- }
- }
+ this.groundGrid[posX][posY] = this.getRockford();
+ }
+ }
- /**
- * When there is no more diamonds to catch, spawn a exit door randomly in
- * the game
- */
- private void spawnExit() {
- int x = (int) (Math.random() * (this.getSizeHeight() - 2));
- int y = (int) (Math.random() * (this.getSizeWidth() - 2));
- this.groundGrid[x + 1][y + 1] = new DoorModel();
- }
+ /**
+ * When there is no more diamonds to catch, spawn a exit door randomly in
+ * the game
+ */
+ private void spawnExit() {
+ int x = (int) (Math.random() * (this.getSizeHeight() - 2));
+ int y = (int) (Math.random() * (this.getSizeWidth() - 2));
+ this.groundGrid[x + 1][y + 1] = new DoorModel();
+ }
- /**
- * Trigger block change with provided value
- *
- * @param blockValue New value
- */
- public void triggerBlockChange(String blockValue) {
+ /**
+ * Trigger block change with provided value
+ *
+ * @param blockValue New value
+ */
+ public void triggerBlockChange(String blockValue) {
// No block value?
- if(blockValue == null || blockValue.isEmpty()) {
+ if (blockValue == null || blockValue.isEmpty()) {
return;
}
// Cancel if Rockford is already in model
- if((blockValue.equals("Rockford") || blockValue.equals("rockford")) && this.isRockfordInModel()) {
+ if ((blockValue.equals("Rockford") || blockValue.equals("rockford")) && this.isRockfordInModel()) {
return;
}
- // Grab model value
- ModelConvertHelper modelConverter = new ModelConvertHelper();
- DisplayableElementModel targetModel;
- int xPos, yPos;
+ // Grab model value
+ ModelConvertHelper modelConverter = new ModelConvertHelper();
+ DisplayableElementModel targetModel;
+ int xPos, yPos;
- xPos = this.getCursorXPosition();
- yPos = this.getCursorYPosition();
+ xPos = this.getCursorXPosition();
+ yPos = this.getCursorYPosition();
- try {
- targetModel = modelConverter.toModel(blockValue, false);
+ try {
+ targetModel = modelConverter.toModel(blockValue, false);
// Apply new model in place of cursor
this.groundGrid[xPos + 1][yPos + 1] = targetModel;
// Disable cursor (important)
//this.setShowCursor(false);
- } catch (UnknownModelException e) {
- e.printStackTrace();
- }
- }
+ } catch (UnknownModelException e) {
+ e.printStackTrace();
+ }
+ }
- /**
- * Gets the vertical position of Rockford from the model
- *
- * @return Vertical position of Rockford
- */
- public int getRockfordPositionY() {
- return this.rockfordPositionY;
- }
+ /**
+ * Gets the vertical position of Rockford from the model
+ *
+ * @return Vertical position of Rockford
+ */
+ public int getRockfordPositionY() {
+ return this.rockfordPositionY;
+ }
- /**
- * Gets the Rockford object instance
- *
- * @return Rockford object
- */
- public RockfordModel getRockford() {
- return this.rockford;
- }
+ /**
+ * Gets the Rockford object instance
+ *
+ * @return Rockford object
+ */
+ public RockfordModel getRockford() {
+ return this.rockford;
+ }
- /**
- * Gets the displayable element at given positions
- *
- * @param x Block horizontal position
- * @param y Block vertical position
- * @return Displayable element at given positions
- */
- public DisplayableElementModel getDisplayableElement(int x, int y) {
- return this.groundGrid[x][y];
- }
+ /**
+ * Gets the displayable element at given positions
+ *
+ * @param x Block horizontal position
+ * @param y Block vertical position
+ * @return Displayable element at given positions
+ */
+ public DisplayableElementModel getDisplayableElement(int x, int y) {
+ return this.groundGrid[x][y];
+ }
- /**
- * Gets the image at given positions
- *
- * @param x Block horizontal position
- * @param y Block vertical position
- * @return Image at given positions
- */
- public BufferedImage getImage(int x, int y) {
+ /**
+ * Gets the image at given positions
+ *
+ * @param x Block horizontal position
+ * @param y Block vertical position
+ * @return Image at given positions
+ */
+ public BufferedImage getImage(int x, int y) {
DisplayableElementModel elementModel = this.getDisplayableElement(x, y);
- if(elementModel == null) {
+ if (elementModel == null) {
return new DirtModel().getSprite();
}
- return elementModel.getSprite();
- }
+ return elementModel.getSprite();
+ }
- /**
- * Gets the cursor image image
- *
- * @return Cursor image
- */
- public BufferedImage getCursorImage() {
+ /**
+ * Gets the cursor image image
+ *
+ * @return Cursor image
+ */
+ public BufferedImage getCursorImage() {
- if (this.cursorModel == null) {
- this.cursorModel = new CursorModel();
- }
+ if (this.cursorModel == null) {
+ this.cursorModel = new CursorModel();
+ }
- return this.cursorModel.getSprite();
- }
+ return this.cursorModel.getSprite();
+ }
/**
* Return whether rockford is in model or not
* Notice: not optimized, be careful
*
- * @return Whether rockford is in model or not
+ * @return Whether rockford is in model or not
*/
public boolean isRockfordInModel() {
boolean isInModel = false;
@@ -376,7 +376,7 @@ public class LevelModel extends Observable implements Runnable {
// Iterate and catch it!
for (int x = 0; x < this.getSizeWidth() && !isInModel; x++) {
for (int y = 0; y < this.getSizeHeight() && !isInModel; y++) {
- if(this.groundGrid[x][y] != null && this.groundGrid[x][y].getSpriteName() == "rockford") {
+ if (this.groundGrid[x][y] != null && this.groundGrid[x][y].getSpriteName() == "rockford") {
isInModel = true;
}
}
@@ -388,7 +388,7 @@ public class LevelModel extends Observable implements Runnable {
/**
* Returns number of diamonds
*
- * @return Number of diamonds
+ * @return Number of diamonds
*/
public int countDiamonds() {
int numberOfDiamonds = 0;
@@ -396,7 +396,7 @@ public class LevelModel extends Observable implements Runnable {
// Iterate and catch it!
for (int x = 0; x < this.getSizeWidth(); x++) {
for (int y = 0; y < this.getSizeHeight(); y++) {
- if(this.groundGrid[x][y] != null && this.groundGrid[x][y].getSpriteName() == "diamond") {
+ if (this.groundGrid[x][y] != null && this.groundGrid[x][y].getSpriteName() == "diamond") {
numberOfDiamonds += 1;
}
}
@@ -410,420 +410,420 @@ public class LevelModel extends Observable implements Runnable {
*/
public void checkConstraints() throws LevelConstraintNotRespectedException {
// Diamonds number?
- if(this.countDiamonds() < 3) {
+ if (this.countDiamonds() < 3) {
throw new LevelConstraintNotRespectedException("Add at least 3 diamonds!");
}
// Rockford in model?
- if(!this.isRockfordInModel()) {
+ if (!this.isRockfordInModel()) {
throw new LevelConstraintNotRespectedException("Add Rockford on the map!");
}
}
- /**
- * Gets the level horizontal size
- *
- * @return Horizontal size
- */
- public int getSizeWidth() {
- return this.sizeWidth;
- }
+ /**
+ * Gets the level horizontal size
+ *
+ * @return Horizontal size
+ */
+ public int getSizeWidth() {
+ return this.sizeWidth;
+ }
- /**
- * Sets the level horizontal size
- *
- * @param sizeWidth Horizontal size
- */
- public void setSizeWidth(int sizeWidth) {
- this.sizeWidth = sizeWidth;
- }
+ /**
+ * Sets the level horizontal size
+ *
+ * @param sizeWidth Horizontal size
+ */
+ public void setSizeWidth(int sizeWidth) {
+ this.sizeWidth = sizeWidth;
+ }
- /**
- * Gets the level vertical size
- *
- * @return Vertical size
- */
- public int getSizeHeight() {
- return this.sizeHeight;
- }
+ /**
+ * Gets the level vertical size
+ *
+ * @return Vertical size
+ */
+ public int getSizeHeight() {
+ return this.sizeHeight;
+ }
- /**
- * Sets the level vertical size
- *
- * @return sizeHeight Vertical size
- */
- public void setSizeHeight(int sizeHeight) {
- this.sizeHeight = sizeHeight;
- }
+ /**
+ * Sets the level vertical size
+ *
+ * @return sizeHeight Vertical size
+ */
+ public void setSizeHeight(int sizeHeight) {
+ this.sizeHeight = sizeHeight;
+ }
- /**
- * Gets the ground level model
- *
- * @return Ground level model
- */
- public DisplayableElementModel[][] getGroundLevelModel() {
- return groundGrid;
- }
+ /**
+ * Gets the ground level model
+ *
+ * @return Ground level model
+ */
+ public DisplayableElementModel[][] getGroundLevelModel() {
+ return groundGrid;
+ }
- /**
- * Notify observers about a model change
- */
- private void localNotifyObservers() {
- this.notifyObservers();
- this.setChanged();
- }
+ /**
+ * Notify observers about a model change
+ */
+ private void localNotifyObservers() {
+ this.notifyObservers();
+ this.setChanged();
+ }
- /**
- * Update the current sprite Notifies the observers
- *
- * @param x Sprite block horizontal position
- * @param y Sprite block vertical position
- */
- public void updateSprites(int x, int y) {
- if(groundGrid[x][y] == null) {
+ /**
+ * Update the current sprite Notifies the observers
+ *
+ * @param x Sprite block horizontal position
+ * @param y Sprite block vertical position
+ */
+ public void updateSprites(int x, int y) {
+ if (groundGrid[x][y] == null) {
groundGrid[x][y] = new DirtModel();
}
groundGrid[x][y].update(System.currentTimeMillis());
this.localNotifyObservers();
- }
+ }
- /**
- * Update all the sprites So that they can be animated
- */
- public void run() {
- while (gameRunning) {
- if (!gamePaused) {
- for (int x = 0; x < this.getSizeWidth(); x++) {
- for (int y = 0; y < this.getSizeHeight(); y++) {
- this.updateSprites(x, y);
- }
- }
- }
+ /**
+ * Update all the sprites So that they can be animated
+ */
+ public void run() {
+ while (gameRunning) {
+ if (!gamePaused) {
+ for (int x = 0; x < this.getSizeWidth(); x++) {
+ for (int y = 0; y < this.getSizeHeight(); y++) {
+ this.updateSprites(x, y);
+ }
+ }
+ }
- try {
- Thread.sleep(DELAY);
- } catch (InterruptedException e) {
- System.out.println("Interrupted: " + e.getMessage());
- }
- }
- }
+ try {
+ Thread.sleep(DELAY);
+ } catch (InterruptedException e) {
+ System.out.println("Interrupted: " + e.getMessage());
+ }
+ }
+ }
- /**
- * Increments the user score
- */
- public void incrementScore() {
- this.gameInformationModel.incrementScore();
- }
+ /**
+ * Increments the user score
+ */
+ public void incrementScore() {
+ this.gameInformationModel.incrementScore();
+ }
- /**
- * Gets the associated level load helper
- *
- * @return Level load helper
- */
- public LevelLoadHelper getLevelLoadHelper() {
- return this.levelLoadHelper;
- }
+ /**
+ * Gets the associated level load helper
+ *
+ * @return Level load helper
+ */
+ public LevelLoadHelper getLevelLoadHelper() {
+ return this.levelLoadHelper;
+ }
- /**
- * Gets the cursor position X value
- *
- * @return Cursor position X value
- */
- public int getCursorXPosition() {
- return this.cursorXPosition;
- }
+ /**
+ * Gets the cursor position X value
+ *
+ * @return Cursor position X value
+ */
+ public int getCursorXPosition() {
+ return this.cursorXPosition;
+ }
- /**
- * Gets the cursor position Y value
- *
- * @return Cursor position Y value
- */
- public int getCursorYPosition() {
- return this.cursorYPosition;
- }
+ /**
+ * Gets the cursor position Y value
+ *
+ * @return Cursor position Y value
+ */
+ public int getCursorYPosition() {
+ return this.cursorYPosition;
+ }
- /**
- * Increaments the cursor position X value
- *
- * @return Cursor position new X value
- */
- public int incrementCursorXPosition() {
- if (this.cursorXPosition < (this.getSizeWidth() - 1 - 2)) {
- this.cursorXPosition = this.cursorXPosition + 1;
- }
+ /**
+ * Increaments the cursor position X value
+ *
+ * @return Cursor position new X value
+ */
+ public int incrementCursorXPosition() {
+ if (this.cursorXPosition < (this.getSizeWidth() - 1 - 2)) {
+ this.cursorXPosition = this.cursorXPosition + 1;
+ }
- this.localNotifyObservers();
- return this.getCursorXPosition();
- }
+ this.localNotifyObservers();
+ return this.getCursorXPosition();
+ }
- /**
- * Decrements the cursor position X value
- *
- * @return Cursor position new X value
- */
- public int decrementCursorXPosition() {
- if (this.cursorXPosition > 0) {
- this.cursorXPosition = this.cursorXPosition - 1;
- }
+ /**
+ * Decrements the cursor position X value
+ *
+ * @return Cursor position new X value
+ */
+ public int decrementCursorXPosition() {
+ if (this.cursorXPosition > 0) {
+ this.cursorXPosition = this.cursorXPosition - 1;
+ }
- this.localNotifyObservers();
- return this.getCursorXPosition();
- }
+ this.localNotifyObservers();
+ return this.getCursorXPosition();
+ }
- /**
- * Increaments the cursor position Y value
- *
- * @return Cursor position new Y value
- */
- public int incrementCursorYPosition() {
- if (this.cursorYPosition < (this.getSizeHeight() - 1 - 2)) {
- this.cursorYPosition = this.cursorYPosition + 1;
- }
+ /**
+ * Increaments the cursor position Y value
+ *
+ * @return Cursor position new Y value
+ */
+ public int incrementCursorYPosition() {
+ if (this.cursorYPosition < (this.getSizeHeight() - 1 - 2)) {
+ this.cursorYPosition = this.cursorYPosition + 1;
+ }
- this.localNotifyObservers();
- return this.getCursorYPosition();
- }
+ this.localNotifyObservers();
+ return this.getCursorYPosition();
+ }
- /**
- * Decrements the cursor position Y value
- *
- * @return Cursor position new Y value
- */
- public int decrementCursorYPosition() {
- if (this.cursorYPosition > 0) {
- this.cursorYPosition = this.cursorYPosition - 1;
- }
+ /**
+ * Decrements the cursor position Y value
+ *
+ * @return Cursor position new Y value
+ */
+ public int decrementCursorYPosition() {
+ if (this.cursorYPosition > 0) {
+ this.cursorYPosition = this.cursorYPosition - 1;
+ }
- this.localNotifyObservers();
- return this.getCursorYPosition();
- }
+ this.localNotifyObservers();
+ return this.getCursorYPosition();
+ }
- /**
- * sets the game to a defined state
- *
- * @param gameRunning Whether game is running or not
- */
- public void setGameRunning(boolean gameRunning) {
- this.gameRunning = gameRunning;
- // Timer to refresh the view properly...
- try {
- Thread.sleep(200);
- } catch (InterruptedException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- this.localNotifyObservers();
- }
+ /**
+ * sets the game to a defined state
+ *
+ * @param gameRunning Whether game is running or not
+ */
+ public void setGameRunning(boolean gameRunning) {
+ this.gameRunning = gameRunning;
+ // Timer to refresh the view properly...
+ try {
+ Thread.sleep(200);
+ } catch (InterruptedException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ this.localNotifyObservers();
+ }
- /**
- * tells if the game is running
- *
- * @return whether the game is running or not
- */
- public boolean isGameRunning() {
- return gameRunning;
- }
+ /**
+ * tells if the game is running
+ *
+ * @return whether the game is running or not
+ */
+ public boolean isGameRunning() {
+ return gameRunning;
+ }
- /**
- * Gets whether cursor is to be shown or not
- *
- * @return whether cursor needs to be shown or not
- */
- public boolean getShowCursor() {
- return this.showCursor;
- }
+ /**
+ * Gets whether cursor is to be shown or not
+ *
+ * @return whether cursor needs to be shown or not
+ */
+ public boolean getShowCursor() {
+ return this.showCursor;
+ }
- /**
- * Sets whether cursor is to be shown or not
- *
- * @param showCursor whether cursor needs to be shown or not
- */
- public void setShowCursor(boolean showCursor) {
- this.showCursor = showCursor;
- }
+ /**
+ * Sets whether cursor is to be shown or not
+ *
+ * @param showCursor whether cursor needs to be shown or not
+ */
+ public void setShowCursor(boolean showCursor) {
+ this.showCursor = showCursor;
+ }
- /**
- * When a boulder is falling on Rockford there is an explosion around him
- *
- * @param x Object horizontal position
- * @param y Object vertical position
- */
- public void exploseGround(int x, int y) {
- this.groundGrid[x][y] = new EmptyModel();
- this.groundGrid[x + 1][y] = new EmptyModel();
- this.groundGrid[x - 1][y] = new EmptyModel();
- this.groundGrid[x][y + 1] = new EmptyModel();
- this.groundGrid[x + 1][y + 1] = new EmptyModel();
- this.groundGrid[x - 1][y + 1] = new EmptyModel();
- this.groundGrid[x][y - 1] = new EmptyModel();
- this.groundGrid[x + 1][y - 1] = new EmptyModel();
- this.groundGrid[x - 1][y - 1] = new EmptyModel();
- this.rockford.setHasExplosed(true);
+ /**
+ * When a boulder is falling on Rockford there is an explosion around him
+ *
+ * @param x Object horizontal position
+ * @param y Object vertical position
+ */
+ public void exploseGround(int x, int y) {
+ this.groundGrid[x][y] = new EmptyModel();
+ this.groundGrid[x + 1][y] = new EmptyModel();
+ this.groundGrid[x - 1][y] = new EmptyModel();
+ this.groundGrid[x][y + 1] = new EmptyModel();
+ this.groundGrid[x + 1][y + 1] = new EmptyModel();
+ this.groundGrid[x - 1][y + 1] = new EmptyModel();
+ this.groundGrid[x][y - 1] = new EmptyModel();
+ this.groundGrid[x + 1][y - 1] = new EmptyModel();
+ this.groundGrid[x - 1][y - 1] = new EmptyModel();
+ this.rockford.setHasExplosed(true);
- // Again a sleep to notify the observers properly
- try {
- Thread.sleep(50);
- } catch (InterruptedException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- this.localNotifyObservers();
- }
+ // Again a sleep to notify the observers properly
+ try {
+ Thread.sleep(50);
+ } catch (InterruptedException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ this.localNotifyObservers();
+ }
- /**
- * Makes the DisplayableElement[x][y] fall one box down
- *
- * @param x Object horizontal position
- * @param y Object vertical position
- */
- public void makeThisDisplayableElementFall(int x, int y) {
- this.groundGrid[x][y].setFalling(true);
- this.groundGrid[x][y + 1] = this.groundGrid[x][y];
- this.groundGrid[x][y] = new EmptyModel();
- }
+ /**
+ * Makes the DisplayableElement[x][y] fall one box down
+ *
+ * @param x Object horizontal position
+ * @param y Object vertical position
+ */
+ public void makeThisDisplayableElementFall(int x, int y) {
+ this.groundGrid[x][y].setFalling(true);
+ this.groundGrid[x][y + 1] = this.groundGrid[x][y];
+ this.groundGrid[x][y] = new EmptyModel();
+ }
- /**
- * Makes the BoulderModel[x][y] slide left
- *
- * @param x Object horizontal position
- * @param y Object vertical position
- */
- public void makeThisBoulderSlideLeft(int x, int y) {
- this.groundGrid[x][y].setFalling(true);
- this.groundGrid[x - 1][y + 1] = this.groundGrid[x][y];
- this.groundGrid[x][y] = new EmptyModel();
- }
+ /**
+ * Makes the BoulderModel[x][y] slide left
+ *
+ * @param x Object horizontal position
+ * @param y Object vertical position
+ */
+ public void makeThisBoulderSlideLeft(int x, int y) {
+ this.groundGrid[x][y].setFalling(true);
+ this.groundGrid[x - 1][y + 1] = this.groundGrid[x][y];
+ this.groundGrid[x][y] = new EmptyModel();
+ }
- /**
- * Makes the BoulderModel[x][y] slide right
- *
- * @param x Object horizontal position
- * @param y Object vertical position
- */
- public void makeThisBoulderSlideRight(int x, int y) {
- this.groundGrid[x][y].setFalling(true);
- this.groundGrid[x + 1][y + 1] = this.groundGrid[x][y];
- this.groundGrid[x][y] = new EmptyModel();
- }
+ /**
+ * Makes the BoulderModel[x][y] slide right
+ *
+ * @param x Object horizontal position
+ * @param y Object vertical position
+ */
+ public void makeThisBoulderSlideRight(int x, int y) {
+ this.groundGrid[x][y].setFalling(true);
+ this.groundGrid[x + 1][y + 1] = this.groundGrid[x][y];
+ this.groundGrid[x][y] = new EmptyModel();
+ }
- /**
- * Makes the BoulderModel[x][y] transform into a diamond
- *
- * @param x Object horizontal position
- * @param y Object vertical position
- */
- public void transformThisBoulderIntoADiamond(int x, int y) {
- this.groundGrid[x][y + 2] = new DiamondModel();
- this.groundGrid[x][y] = new EmptyModel();
- }
+ /**
+ * Makes the BoulderModel[x][y] transform into a diamond
+ *
+ * @param x Object horizontal position
+ * @param y Object vertical position
+ */
+ public void transformThisBoulderIntoADiamond(int x, int y) {
+ this.groundGrid[x][y + 2] = new DiamondModel();
+ this.groundGrid[x][y] = new EmptyModel();
+ }
- /**
- * Makes the BoulderModel[x][y] moving to right
- *
- * @param x Object horizontal position
- * @param y Object vertical position
- */
- public void moveThisBoulderToRight(int x, int y) {
- this.groundGrid[x + 1][y] = this.groundGrid[x][y];
- this.groundGrid[x][y] = new EmptyModel();
- }
+ /**
+ * Makes the BoulderModel[x][y] moving to right
+ *
+ * @param x Object horizontal position
+ * @param y Object vertical position
+ */
+ public void moveThisBoulderToRight(int x, int y) {
+ this.groundGrid[x + 1][y] = this.groundGrid[x][y];
+ this.groundGrid[x][y] = new EmptyModel();
+ }
- /**
- * Makes the BoulderModel[x][y] moving to left
- *
- * @param x Object horizontal position
- * @param y Object vertical position
- */
- public void moveThisBoulderToLeft(int x, int y) {
- this.groundGrid[x - 1][y] = this.groundGrid[x][y];
- this.groundGrid[x][y] = new EmptyModel();
- }
+ /**
+ * Makes the BoulderModel[x][y] moving to left
+ *
+ * @param x Object horizontal position
+ * @param y Object vertical position
+ */
+ public void moveThisBoulderToLeft(int x, int y) {
+ this.groundGrid[x - 1][y] = this.groundGrid[x][y];
+ this.groundGrid[x][y] = new EmptyModel();
+ }
- /**
- * Deletes the BoulderModel[x][y]
- *
- * @param x Object horizontal position
- * @param y Object vertical position
- */
- public void deleteThisBoulder(int x, int y) {
- this.groundGrid[x][y] = new EmptyModel();
- }
+ /**
+ * Deletes the BoulderModel[x][y]
+ *
+ * @param x Object horizontal position
+ * @param y Object vertical position
+ */
+ public void deleteThisBoulder(int x, int y) {
+ this.groundGrid[x][y] = new EmptyModel();
+ }
- /**
- * Gets gameInformationModel
- *
- * @return gameInfos like score, remainings Diamonds etc
- */
- public GameInformationModel getGameInformationModel() {
- return this.gameInformationModel;
- }
+ /**
+ * Gets gameInformationModel
+ *
+ * @return gameInfos like score, remainings Diamonds etc
+ */
+ public GameInformationModel getGameInformationModel() {
+ return this.gameInformationModel;
+ }
- /**
- * Explose the brick wall
- *
- * @param x
- * @param y
- */
- public void exploseThisBrickWall(int x, int y) {
- this.groundGrid[x][y] = new EmptyModel();
- this.groundGrid[x][y + 1] = new EmptyModel();
- }
+ /**
+ * Explose the brick wall
+ *
+ * @param x
+ * @param y
+ */
+ public void exploseThisBrickWall(int x, int y) {
+ this.groundGrid[x][y] = new EmptyModel();
+ this.groundGrid[x][y + 1] = new EmptyModel();
+ }
- /**
- * Expand the ExpandingWallModel to left
- *
- * @param x
- * @param y
- */
- public void expandThisWallToLeft(int x, int y) {
- this.groundGrid[x - 1][y] = new ExpandingWallModel();
- }
+ /**
+ * Expand the ExpandingWallModel to left
+ *
+ * @param x
+ * @param y
+ */
+ public void expandThisWallToLeft(int x, int y) {
+ this.groundGrid[x - 1][y] = new ExpandingWallModel();
+ }
- /**
- * Expand the ExpandingWallModel to right
- *
- * @param x
- * @param y
- */
- public void expandThisWallToRight(int x, int y) {
- this.groundGrid[x + 1][y] = new ExpandingWallModel();
- }
+ /**
+ * Expand the ExpandingWallModel to right
+ *
+ * @param x
+ * @param y
+ */
+ public void expandThisWallToRight(int x, int y) {
+ this.groundGrid[x + 1][y] = new ExpandingWallModel();
+ }
- /**
- * Set the gamePaused variable
- *
- * @param gamePaused
- */
- public void setGamePaused(boolean gamePaused) {
- this.gamePaused = gamePaused;
- }
+ /**
+ * Set the gamePaused variable
+ *
+ * @param gamePaused
+ */
+ public void setGamePaused(boolean gamePaused) {
+ this.gamePaused = gamePaused;
+ }
- /**
- * Get the gamePaused variable
- *
- * @return gamePaused
- */
- public boolean getGamePaused() {
- return this.gamePaused;
- }
+ /**
+ * Get the gamePaused variable
+ *
+ * @return gamePaused
+ */
+ public boolean getGamePaused() {
+ return this.gamePaused;
+ }
- /**
- * Get the mode where this levelModel is used
- *
- * @return mode
- */
- public String getMode() {
- return mode;
- }
+ /**
+ * Get the mode where this levelModel is used
+ *
+ * @return mode
+ */
+ public String getMode() {
+ return mode;
+ }
- /**
- * Set the mode where this levelModel is used
- *
- * @param mode
- */
- public void setMode(String mode) {
- this.mode = mode;
- }
+ /**
+ * Set the mode where this levelModel is used
+ *
+ * @param mode
+ */
+ public void setMode(String mode) {
+ this.mode = mode;
+ }
}
\ No newline at end of file
diff --git a/src/fr/enssat/BoulderDash/models/MagicWallModel.java b/src/fr/enssat/BoulderDash/models/MagicWallModel.java
index 366c3553..a2829834 100644
--- a/src/fr/enssat/BoulderDash/models/MagicWallModel.java
+++ b/src/fr/enssat/BoulderDash/models/MagicWallModel.java
@@ -8,84 +8,84 @@ import fr.enssat.BoulderDash.models.DisplayableElementModel;
/**
* MagicWallModel
- *
+ *
* Represents the magic wall.
*
- * @author Colin Leverger
- * @since 2015-06-19
+ * @author Colin Leverger
+ * @since 2015-06-19
*/
public class MagicWallModel extends DisplayableElementModel {
- private static String spriteName;
- private static boolean isDestructible;
- private static boolean canMove;
- private static boolean impactExplosive;
- private static boolean animate;
- private static int priority;
- private static boolean falling;
- private static String collideSound;
+ private static String spriteName;
+ private static boolean isDestructible;
+ private static boolean canMove;
+ private static boolean impactExplosive;
+ private static boolean animate;
+ private static int priority;
+ private static boolean falling;
+ private static String collideSound;
/**
* Stores the frames
* Used for the sprites
*/
- private ArrayList framesMagicWall;
+ private ArrayList framesMagicWall;
- private long previousTime;
- private int currentFrame;
- private long speed;
+ private long previousTime;
+ private int currentFrame;
+ private long speed;
/**
* Static dataset
* Specifies the physical parameters of the object
*/
- static {
- spriteName = "magicwall";
- isDestructible = false;
- canMove = false;
- impactExplosive = false;
- animate = false;
- priority = 3;
- falling = false;
- collideSound = "touch";
- }
+ static {
+ spriteName = "magicwall";
+ isDestructible = false;
+ canMove = false;
+ impactExplosive = false;
+ animate = false;
+ priority = 3;
+ falling = false;
+ collideSound = "touch";
+ }
/**
* Class constructor
*/
- public MagicWallModel() {
- super(isDestructible, canMove, spriteName, priority, impactExplosive, animate, falling, collideSound);
- this.currentFrame = 0;
- this.speed = 100;
- this.initSprites();
- }
+ public MagicWallModel() {
+ super(isDestructible, canMove, spriteName, priority, impactExplosive, animate, falling, collideSound);
+ this.currentFrame = 0;
+ this.speed = 100;
+ this.initSprites();
+ }
- /**
- * Function to animate the sprite
- */
- public void update(long time) {
- if (time - previousTime >= speed) {
- // Update animation
- previousTime = time;
+ /**
+ * Function to animate the sprite
+ */
+ public void update(long time) {
+ if (time - previousTime >= speed) {
+ // Update animation
+ previousTime = time;
- try {
- currentFrame += 1;
+ try {
+ currentFrame += 1;
- this.setSprite(framesMagicWall.get(this.currentFrame));
- } catch (IndexOutOfBoundsException e) {
- currentFrame = 0;
- }
- }
- }
-
- /**
- * Init the subimages
- */
- private void initSprites() {
- this.framesMagicWall = new ArrayList();
- /* INIT SPRITE FOR DIAMOND */
- framesMagicWall.add(grabSprite(loadSprite(spriteName), 0, 0, 16, 16));
- framesMagicWall.add(grabSprite(loadSprite(spriteName), 24, 0, 16, 16));
- framesMagicWall.add(grabSprite(loadSprite(spriteName), 48, 0, 16, 16));
- framesMagicWall.add(grabSprite(loadSprite(spriteName), 72, 0, 16, 16));
- }
+ this.setSprite(framesMagicWall.get(this.currentFrame));
+ } catch (IndexOutOfBoundsException e) {
+ currentFrame = 0;
+ }
+ }
+ }
+
+ /**
+ * Init the subimages
+ */
+ private void initSprites() {
+ this.framesMagicWall = new ArrayList();
+ /* INIT SPRITE FOR DIAMOND */
+ framesMagicWall.add(grabSprite(loadSprite(spriteName), 0, 0, 16, 16));
+ framesMagicWall.add(grabSprite(loadSprite(spriteName), 24, 0, 16, 16));
+ framesMagicWall.add(grabSprite(loadSprite(spriteName), 48, 0, 16, 16));
+ framesMagicWall.add(grabSprite(loadSprite(spriteName), 72, 0, 16, 16));
+ }
}
diff --git a/src/fr/enssat/BoulderDash/models/RockfordModel.java b/src/fr/enssat/BoulderDash/models/RockfordModel.java
index e958ebf4..79261d6f 100644
--- a/src/fr/enssat/BoulderDash/models/RockfordModel.java
+++ b/src/fr/enssat/BoulderDash/models/RockfordModel.java
@@ -8,182 +8,182 @@ import fr.enssat.BoulderDash.models.DisplayableElementModel;
/**
* RockfordModel
- *
+ *
* Represents the hero of the game.
*
- * @author Colin Leverger
- * @since 2015-06-19
+ * @author Colin Leverger
+ * @since 2015-06-19
*/
public class RockfordModel extends DisplayableElementModel {
- private static String spriteName;
- private static boolean isDestructible;
- private static boolean canMove;
- private static boolean impactExplosive;
- private static boolean animate;
- private static int priority;
- private static boolean falling;
- private static String collideSound;
+ private static String spriteName;
+ private static boolean isDestructible;
+ private static boolean canMove;
+ private static boolean impactExplosive;
+ private static boolean animate;
+ private static int priority;
+ private static boolean falling;
+ private static String collideSound;
/**
* Maps the sub images of the sprite file
*/
- private static ArrayList framesBlinking;
- private static ArrayList framesRunningLeft;
- private static ArrayList framesRunningRight;
- private static ArrayList framesRunningUpOrDown;
+ private static ArrayList framesBlinking;
+ private static ArrayList framesRunningLeft;
+ private static ArrayList framesRunningRight;
+ private static ArrayList framesRunningUpOrDown;
/**
* Defines the size of the sprite
*/
- private final int SIZ_X_OF_SPRITE = 16;
- private final int SIZ_Y_OF_SPRITE = 16;
+ private final int SIZ_X_OF_SPRITE = 16;
+ private final int SIZ_Y_OF_SPRITE = 16;
/**
* Defines the current speed of the object
*/
- private long speed;
+ private long speed;
/**
* Maps possible states for Rockford
*/
- private boolean isCollisionDone = false;
- private boolean isStaying = true;
- private boolean isRunningLeft = false;
- private boolean isRunningRight = false;
- private boolean isRunningUp = false;
- private boolean isRunningDown = false;
+ private boolean isCollisionDone = false;
+ private boolean isStaying = true;
+ private boolean isRunningLeft = false;
+ private boolean isRunningRight = false;
+ private boolean isRunningUp = false;
+ private boolean isRunningDown = false;
- private long previousTime;
- private int currentFrame;
- private boolean hasExploded;
+ private long previousTime;
+ private int currentFrame;
+ private boolean hasExploded;
/**
* Static dataset
* Specifies the physical parameters of the object
*/
- static {
- spriteName = "rockford";
- isDestructible = true;
- canMove = true;
- impactExplosive = true;
- animate = true;
- priority = 1;
- falling = false;
- collideSound = null;
- }
+ static {
+ spriteName = "rockford";
+ isDestructible = true;
+ canMove = true;
+ impactExplosive = true;
+ animate = true;
+ priority = 1;
+ falling = false;
+ collideSound = null;
+ }
/**
* Class constructor
*/
- public RockfordModel() {
- super(isDestructible, canMove, spriteName, priority, impactExplosive, animate, falling, collideSound);
- // Speed of the animation of the sprite
- this.setSpeed(100);
- // Init the sprites in arrays
- this.initSprites();
- this.hasExploded = false;
- }
+ public RockfordModel() {
+ super(isDestructible, canMove, spriteName, priority, impactExplosive, animate, falling, collideSound);
+ // Speed of the animation of the sprite
+ this.setSpeed(100);
+ // Init the sprites in arrays
+ this.initSprites();
+ this.hasExploded = false;
+ }
- public void setSpeed(int speed) {
- this.speed = speed;
- }
+ public void setSpeed(int speed) {
+ this.speed = speed;
+ }
- /**
- * Updates the sprite animation
+ /**
+ * Updates the sprite animation
* (And only that single thing)
- */
- public void update(long time) {
- if (time - this.previousTime >= this.speed) {
- // Update the animation
- this.previousTime = time;
- try {
- currentFrame += 1;
+ */
+ public void update(long time) {
+ if (time - this.previousTime >= this.speed) {
+ // Update the animation
+ this.previousTime = time;
+ try {
+ currentFrame += 1;
- if (isStaying()) {
- this.setSprite(framesBlinking.get(currentFrame));
- } else if (isRunningLeft()) {
- this.setSprite(framesRunningLeft.get(currentFrame));
- } else if (isRunningRight()) {
- this.setSprite(framesRunningRight.get(currentFrame));
- } else if (isRunningUpOrDown()) {
- this.setSprite(framesRunningUpOrDown.get(currentFrame));
- }
- } catch (IndexOutOfBoundsException e) {
- this.currentFrame = 0;
- }
- }
- }
+ if (isStaying()) {
+ this.setSprite(framesBlinking.get(currentFrame));
+ } else if (isRunningLeft()) {
+ this.setSprite(framesRunningLeft.get(currentFrame));
+ } else if (isRunningRight()) {
+ this.setSprite(framesRunningRight.get(currentFrame));
+ } else if (isRunningUpOrDown()) {
+ this.setSprite(framesRunningUpOrDown.get(currentFrame));
+ }
+ } catch (IndexOutOfBoundsException e) {
+ this.currentFrame = 0;
+ }
+ }
+ }
- /**
- * Stops the Rockford movement
- */
- public void startStaying() {
- isCollisionDone = false;
- isStaying = true;
- isRunningLeft = false;
- isRunningRight = false;
- isRunningUp = false;
- isRunningDown = false;
- previousTime = 0;
- currentFrame = 0;
- }
+ /**
+ * Stops the Rockford movement
+ */
+ public void startStaying() {
+ isCollisionDone = false;
+ isStaying = true;
+ isRunningLeft = false;
+ isRunningRight = false;
+ isRunningUp = false;
+ isRunningDown = false;
+ previousTime = 0;
+ currentFrame = 0;
+ }
- /**
- * Starts moving Rockford to the left
- */
- public void startRunningLeft() {
- isCollisionDone = false;
- isStaying = false;
- isRunningLeft = true;
- isRunningRight = false;
- isRunningUp = false;
- isRunningDown = false;
- previousTime = 0;
- }
+ /**
+ * Starts moving Rockford to the left
+ */
+ public void startRunningLeft() {
+ isCollisionDone = false;
+ isStaying = false;
+ isRunningLeft = true;
+ isRunningRight = false;
+ isRunningUp = false;
+ isRunningDown = false;
+ previousTime = 0;
+ }
- /**
- * Starts moving Rockford to the right
- */
- public void startRunningRight() {
- isCollisionDone = false;
- isStaying = false;
- isRunningLeft = false;
- isRunningRight = true;
- isRunningUp = false;
- isRunningDown = false;
- previousTime = 0;
- }
+ /**
+ * Starts moving Rockford to the right
+ */
+ public void startRunningRight() {
+ isCollisionDone = false;
+ isStaying = false;
+ isRunningLeft = false;
+ isRunningRight = true;
+ isRunningUp = false;
+ isRunningDown = false;
+ previousTime = 0;
+ }
- /**
- * Rockford running up
- */
- public void startRunningUp() {
- isCollisionDone = false;
- isStaying = false;
- isRunningLeft = false;
- isRunningRight = false;
- isRunningUp = true;
- isRunningDown = false;
- previousTime = 0;
- }
+ /**
+ * Rockford running up
+ */
+ public void startRunningUp() {
+ isCollisionDone = false;
+ isStaying = false;
+ isRunningLeft = false;
+ isRunningRight = false;
+ isRunningUp = true;
+ isRunningDown = false;
+ previousTime = 0;
+ }
- /**
- * Rockford running down
- */
- public void startRunningDown() {
- isCollisionDone = false;
- isStaying = false;
- isRunningLeft = false;
- isRunningRight = false;
- isRunningUp = false;
- isRunningDown = true;
- previousTime = 0;
- }
+ /**
+ * Rockford running down
+ */
+ public void startRunningDown() {
+ isCollisionDone = false;
+ isStaying = false;
+ isRunningLeft = false;
+ isRunningRight = false;
+ isRunningUp = false;
+ isRunningDown = true;
+ previousTime = 0;
+ }
/**
* Gets whether Rockford collision has been handled or not
*
- * @return Rockford collision handled or not
+ * @return Rockford collision handled or not
*/
public boolean isCollisionDone() {
return this.isCollisionDone;
@@ -192,111 +192,111 @@ public class RockfordModel extends DisplayableElementModel {
/**
* Sets whether Rockford collision has been handled or not
*
- * @param isCollisionDone Rockford collision handled or not
+ * @param isCollisionDone Rockford collision handled or not
*/
public void setCollisionDone(boolean isCollisionDone) {
this.isCollisionDone = isCollisionDone;
}
- /**
- * Gets whether Rockford is standing still or not
- *
- * @return Rockford staying or not
- */
- public boolean isStaying() {
- return this.isStaying;
- }
+ /**
+ * Gets whether Rockford is standing still or not
+ *
+ * @return Rockford staying or not
+ */
+ public boolean isStaying() {
+ return this.isStaying;
+ }
/**
* Gets whether Rockford is running to the left or not
*
- * @return Rockford running to the left or not
+ * @return Rockford running to the left or not
*/
- public boolean isRunningLeft() {
- return this.isRunningLeft;
- }
+ public boolean isRunningLeft() {
+ return this.isRunningLeft;
+ }
/**
* Gets whether Rockford is running to the right or not
*
- * @return Rockford running to the right or not
+ * @return Rockford running to the right or not
*/
- public boolean isRunningRight() {
- return this.isRunningRight;
- }
+ public boolean isRunningRight() {
+ return this.isRunningRight;
+ }
- /**
- * Gets whether Rockford is running up or not
- *
- * @return Rockford running up, or not
- */
- public boolean isRunningUp() {
- return this.isRunningUp;
- }
+ /**
+ * Gets whether Rockford is running up or not
+ *
+ * @return Rockford running up, or not
+ */
+ public boolean isRunningUp() {
+ return this.isRunningUp;
+ }
- /**
- * Gets whether Rockford is running down or not
- *
- * @return Rockford running down, or not
- */
- public boolean isRunningDown() {
- return this.isRunningDown;
- }
+ /**
+ * Gets whether Rockford is running down or not
+ *
+ * @return Rockford running down, or not
+ */
+ public boolean isRunningDown() {
+ return this.isRunningDown;
+ }
- /**
- * Gets whether Rockford is running up or down, or not
- *
- * @return Rockford running up or down, or not
- */
- public boolean isRunningUpOrDown() {
- return this.isRunningUp() || this.isRunningDown();
- }
+ /**
+ * Gets whether Rockford is running up or down, or not
+ *
+ * @return Rockford running up or down, or not
+ */
+ public boolean isRunningUpOrDown() {
+ return this.isRunningUp() || this.isRunningDown();
+ }
- /**
- * Initializes all sprites from the main image
+ /**
+ * Initializes all sprites from the main image
* Takes the sub images and append them into storage arrays
- */
- private void initSprites() {
- framesBlinking = new ArrayList();
- framesRunningLeft = new ArrayList();
- framesRunningRight = new ArrayList();
- framesRunningUpOrDown = new ArrayList();
+ */
+ private void initSprites() {
+ framesBlinking = new ArrayList();
+ framesRunningLeft = new ArrayList();
+ framesRunningRight = new ArrayList();
+ framesRunningUpOrDown = new ArrayList();
- /* INIT SPRITE ARRAYS FOR ROCKFORD */
- for (int i = 0; i < 8; i++) {
- framesBlinking.add(
- this.grabSprite(this.loadSprite(spriteName), 7 + (24 * i), 79, SIZ_X_OF_SPRITE, SIZ_Y_OF_SPRITE)
- );
+ /* INIT SPRITE ARRAYS FOR ROCKFORD */
+ for (int i = 0; i < 8; i++) {
+ framesBlinking.add(
+ this.grabSprite(this.loadSprite(spriteName), 7 + (24 * i), 79, SIZ_X_OF_SPRITE, SIZ_Y_OF_SPRITE)
+ );
- framesRunningLeft.add(
- this.grabSprite(this.loadSprite(spriteName), 7 + (24 * i), 103, SIZ_X_OF_SPRITE, SIZ_Y_OF_SPRITE)
- );
+ framesRunningLeft.add(
+ this.grabSprite(this.loadSprite(spriteName), 7 + (24 * i), 103, SIZ_X_OF_SPRITE, SIZ_Y_OF_SPRITE)
+ );
- framesRunningRight.add(
- this.grabSprite(this.loadSprite(spriteName), 7 + (24 * i), 127, SIZ_X_OF_SPRITE, SIZ_Y_OF_SPRITE)
- );
- }
+ framesRunningRight.add(
+ this.grabSprite(this.loadSprite(spriteName), 7 + (24 * i), 127, SIZ_X_OF_SPRITE, SIZ_Y_OF_SPRITE)
+ );
+ }
- framesRunningUpOrDown.add(
- this.grabSprite(this.loadSprite(spriteName), 7, 7, SIZ_X_OF_SPRITE, SIZ_Y_OF_SPRITE)
- );
- }
+ framesRunningUpOrDown.add(
+ this.grabSprite(this.loadSprite(spriteName), 7, 7, SIZ_X_OF_SPRITE, SIZ_Y_OF_SPRITE)
+ );
+ }
- /**
- * Return true if rockford has exploded (you = lose)
+ /**
+ * Return true if rockford has exploded (you = lose)
*
- * @return Whether Rockford has exploded or not
- */
- public boolean getHasExplosed() {
- return hasExploded;
- }
-
- /**
- * Set rockford exploded state
+ * @return Whether Rockford has exploded or not
+ */
+ public boolean getHasExplosed() {
+ return hasExploded;
+ }
+
+ /**
+ * Set rockford exploded state
*
- * @param hasExploded Whether Rockford has exploded or not
- */
- public void setHasExplosed(boolean hasExploded){
- this.hasExploded = hasExploded;
- }
+ * @param hasExploded Whether Rockford has exploded or not
+ */
+ public void setHasExplosed(boolean hasExploded) {
+ this.hasExploded = hasExploded;
+ }
}
diff --git a/src/fr/enssat/BoulderDash/models/SteelWallModel.java b/src/fr/enssat/BoulderDash/models/SteelWallModel.java
index 2696ac1e..ef3e66be 100644
--- a/src/fr/enssat/BoulderDash/models/SteelWallModel.java
+++ b/src/fr/enssat/BoulderDash/models/SteelWallModel.java
@@ -5,42 +5,42 @@ import fr.enssat.BoulderDash.models.DisplayableElementModel;
/**
* SteelWallModel
- *
+ *
* Represents the steelWall
*
- * @author Colin Leverger
- * @since 2015-06-19
+ * @author Colin Leverger
+ * @since 2015-06-19
*/
public class SteelWallModel extends DisplayableElementModel {
- private static String spriteName;
- private static boolean isDestructible;
- private static boolean canMove;
- private static boolean impactExplosive;
- private static boolean animate;
- private static int priority;
- private static boolean falling;
- private static String collideSound;
+ private static String spriteName;
+ private static boolean isDestructible;
+ private static boolean canMove;
+ private static boolean impactExplosive;
+ private static boolean animate;
+ private static int priority;
+ private static boolean falling;
+ private static String collideSound;
/**
* Static dataset
* Specifies the physical parameters of the object
*/
- static {
- spriteName = "steelwall";
- isDestructible = false;
- canMove = false;
- impactExplosive = false;
- animate = false;
- priority = 3;
- falling = false;
- collideSound = "touch";
- }
+ static {
+ spriteName = "steelwall";
+ isDestructible = false;
+ canMove = false;
+ impactExplosive = false;
+ animate = false;
+ priority = 3;
+ falling = false;
+ collideSound = "touch";
+ }
/**
* Class constructor
*/
- public SteelWallModel() {
- super(isDestructible, canMove, spriteName, priority, impactExplosive, animate, falling, collideSound);
- this.loadSprite(spriteName);
- }
+ public SteelWallModel() {
+ super(isDestructible, canMove, spriteName, priority, impactExplosive, animate, falling, collideSound);
+ this.loadSprite(spriteName);
+ }
}
diff --git a/src/fr/enssat/BoulderDash/views/AssetsLevelEditorComponent.java b/src/fr/enssat/BoulderDash/views/AssetsLevelEditorComponent.java
index 25645d47..2a1503cc 100644
--- a/src/fr/enssat/BoulderDash/views/AssetsLevelEditorComponent.java
+++ b/src/fr/enssat/BoulderDash/views/AssetsLevelEditorComponent.java
@@ -11,11 +11,11 @@ import fr.enssat.BoulderDash.views.LevelEditorView;
/**
* AssetsLevelEditorComponent
- *
+ *
* Information panel element.
*
- * @author Valerian Saliou
- * @since 2015-06-22
+ * @author Valerian Saliou
+ * @since 2015-06-22
*/
public class AssetsLevelEditorComponent extends JPanel implements ActionListener {
private LevelEditorView levelEditorView;
@@ -30,18 +30,18 @@ public class AssetsLevelEditorComponent extends JPanel implements ActionListener
/**
* Class constructor
*
- * @param levelEditorView Controller for level editor
+ * @param levelEditorView Controller for level editor
*/
public AssetsLevelEditorComponent(LevelEditorView levelEditorView) {
super(new BorderLayout());
- this.levelEditorView = levelEditorView;
+ this.levelEditorView = levelEditorView;
ButtonGroup buttonGroup = new ButtonGroup();
JPanel radioPanel = new JPanel(new GridLayout(0, 1));
String curListChoice;
- for(int i = 0; i < choiceList.size(); i++) {
+ for (int i = 0; i < choiceList.size(); i++) {
curListChoice = choiceList.get(i);
// Create radio buttons from list
@@ -66,7 +66,7 @@ public class AssetsLevelEditorComponent extends JPanel implements ActionListener
/**
* Listens for action events
*
- * @param e Action event
+ * @param e Action event
*/
public void actionPerformed(ActionEvent e) {
JRadioButton sourceButton = (JRadioButton) e.getSource();
diff --git a/src/fr/enssat/BoulderDash/views/GameGroundView.java b/src/fr/enssat/BoulderDash/views/GameGroundView.java
index 640e7fd2..e714ccb0 100644
--- a/src/fr/enssat/BoulderDash/views/GameGroundView.java
+++ b/src/fr/enssat/BoulderDash/views/GameGroundView.java
@@ -11,11 +11,11 @@ import java.awt.*;
/**
* GameFieldView
- *
+ *
* Game field view for the game itself.
*
- * @author Valerian Saliou
- * @since 2015-06-21
+ * @author Valerian Saliou
+ * @since 2015-06-21
*/
public class GameGroundView extends GroundView {
private GameController gameController;
@@ -23,8 +23,8 @@ public class GameGroundView extends GroundView {
/**
* Class constructor
*
- * @param gameController Game controller
- * @param levelModel Level model
+ * @param gameController Game controller
+ * @param levelModel Level model
*/
public GameGroundView(GameController gameController, LevelModel levelModel) {
super(levelModel);
diff --git a/src/fr/enssat/BoulderDash/views/GameView.java b/src/fr/enssat/BoulderDash/views/GameView.java
index 8874d528..84fbb8c6 100644
--- a/src/fr/enssat/BoulderDash/views/GameView.java
+++ b/src/fr/enssat/BoulderDash/views/GameView.java
@@ -14,34 +14,34 @@ import fr.enssat.BoulderDash.views.InformationPanel;
/**
* GameView
- *
+ *
* Specifies the game view itself.
*
- * @author Colin Leverger
- * @since 2015-06-19
+ * @author Colin Leverger
+ * @since 2015-06-19
*/
public class GameView extends JFrame implements Observer {
- private GameGroundView gameGroundView;
- private JPanel actionPanel;
- private JPanel informationPanel;
- private GameController gameController;
- private LevelModel levelModel;
+ private GameGroundView gameGroundView;
+ private JPanel actionPanel;
+ private JPanel informationPanel;
+ private GameController gameController;
+ private LevelModel levelModel;
/**
* Class constructor
*
- * @param gameController Game controller
- * @param levelModel Level model
+ * @param gameController Game controller
+ * @param levelModel Level model
*/
- public GameView(GameController gameController, LevelModel levelModel) {
- this.gameController = gameController;
- this.levelModel = levelModel;
-
+ public GameView(GameController gameController, LevelModel levelModel) {
+ this.gameController = gameController;
+ this.levelModel = levelModel;
+
this.initializeView();
this.createLayout();
this.gameGroundView.grabFocus();
- }
+ }
/**
* Initializes the view
@@ -84,36 +84,36 @@ public class GameView extends JFrame implements Observer {
/**
* Gets the game field view
*
- * @return Game field view
+ * @return Game field view
*/
- public GameGroundView getGameFieldView() {
- return this.gameGroundView;
- }
+ public GameGroundView getGameFieldView() {
+ return this.gameGroundView;
+ }
/**
* Creates the given button
*
- * @param name Button name
- * @return Created button
+ * @param name Button name
+ * @return Created button
*/
- public JButton createButton(String id, String name) {
- JButton button = new JButton(name);
- button.addActionListener(this.gameController);
- button.setActionCommand(id);
+ public JButton createButton(String id, String name) {
+ JButton button = new JButton(name);
+ button.addActionListener(this.gameController);
+ button.setActionCommand(id);
- this.actionPanel.add(button);
+ this.actionPanel.add(button);
- return button;
- }
+ return button;
+ }
- /**
+ /**
* Updates the frame
*
- * @param obs Observable item
- * @param obj Object item
+ * @param obs Observable item
+ * @param obj Object item
*/
- @Override
- public void update(Observable obs, Object obj) {
- // Nothing done.
- }
+ @Override
+ public void update(Observable obs, Object obj) {
+ // Nothing done.
+ }
}
\ No newline at end of file
diff --git a/src/fr/enssat/BoulderDash/views/GroundView.java b/src/fr/enssat/BoulderDash/views/GroundView.java
index 359bbcb4..e8a73189 100644
--- a/src/fr/enssat/BoulderDash/views/GroundView.java
+++ b/src/fr/enssat/BoulderDash/views/GroundView.java
@@ -10,101 +10,100 @@ import java.util.Observer;
/**
* FieldView
- *
+ *
* FieldView, created by controller; we notice that we don't need to make
* levelModel observable; Because of the sprites we have to refresh the game
* windows very often so don't need of observers/observable mechanism
*
* @author Colin Leverger
* @since 2015-06-19
- *
- * This view is basically drawing into the Frame the levelModel.
- *
+ *
+ * This view is basically drawing into the Frame the levelModel.
*/
public abstract class GroundView extends JPanel implements Observer {
- protected LevelModel levelModel;
+ protected LevelModel levelModel;
- /**
- * Class constructor
- *
- * @param levelModel Level model
- */
- public GroundView(LevelModel levelModel) {
- this.levelModel = levelModel;
- this.levelModel.addObserver(this);
- }
+ /**
+ * Class constructor
+ *
+ * @param levelModel Level model
+ */
+ public GroundView(LevelModel levelModel) {
+ this.levelModel = levelModel;
+ this.levelModel.addObserver(this);
+ }
- /**
- * Draws the map
- *
- * @param width Map width
- * @param height Map height
- * @param g Map graphical object
- */
- public void drawTerrain(int width, int height, Graphics g) {
- // Draw items
- if (this.levelModel.getMode() == "game") {
- for (int x = 0; x < width; x++) {
- for (int y = 0; y < height; y++) {
- g.drawImage(this.levelModel.getImage(x, y), (x * 16), (y * 16), this);
- }
- }
+ /**
+ * Draws the map
+ *
+ * @param width Map width
+ * @param height Map height
+ * @param g Map graphical object
+ */
+ public void drawTerrain(int width, int height, Graphics g) {
+ // Draw items
+ if (this.levelModel.getMode() == "game") {
+ for (int x = 0; x < width; x++) {
+ for (int y = 0; y < height; y++) {
+ g.drawImage(this.levelModel.getImage(x, y), (x * 16), (y * 16), this);
+ }
+ }
- if(!this.levelModel.isGameRunning()) {
- if(!this.levelModel.getRockford().getHasExplosed()) {
- this.displayWin();
- } else {
- this.displayLose();
- }
- }
- } else {
- for (int x = 0; x < width; x++) {
- for (int y = 0; y < height; y++) {
- g.drawImage(this.levelModel.getImage(x, y), (x * 16), (y * 16), this);
- }
- }
- if (this.levelModel.getShowCursor()) {
- g.drawImage(
- this.levelModel.getCursorImage(),
- ((this.levelModel.getCursorXPosition() + 1) * 16),
- ((this.levelModel.getCursorYPosition() + 1) * 16),
- this
- );
- }
- }
- }
+ if (!this.levelModel.isGameRunning()) {
+ if (!this.levelModel.getRockford().getHasExplosed()) {
+ this.displayWin();
+ } else {
+ this.displayLose();
+ }
+ }
+ } else {
+ for (int x = 0; x < width; x++) {
+ for (int y = 0; y < height; y++) {
+ g.drawImage(this.levelModel.getImage(x, y), (x * 16), (y * 16), this);
+ }
+ }
+ if (this.levelModel.getShowCursor()) {
+ g.drawImage(
+ this.levelModel.getCursorImage(),
+ ((this.levelModel.getCursorXPosition() + 1) * 16),
+ ((this.levelModel.getCursorYPosition() + 1) * 16),
+ this
+ );
+ }
+ }
+ }
- /**
- * Set the view to inform the user that he won
- */
- private void displayWin() {
+ /**
+ * Set the view to inform the user that he won
+ */
+ private void displayWin() {
new WinLoseView("win");
- }
+ }
- /**
- * Set the view to inform the user that he is not good at this game
- */
- private void displayLose() {
- new WinLoseView("lose");
- }
+ /**
+ * Set the view to inform the user that he is not good at this game
+ */
+ private void displayLose() {
+ new WinLoseView("lose");
+ }
- /**
- * Paints the map
- *
- * @param g Map graphical object
- */
- public void paint(Graphics g) {
- this.drawTerrain(this.levelModel.getSizeWidth(), this.levelModel.getSizeHeight(), g);
- }
+ /**
+ * Paints the map
+ *
+ * @param g Map graphical object
+ */
+ public void paint(Graphics g) {
+ this.drawTerrain(this.levelModel.getSizeWidth(), this.levelModel.getSizeHeight(), g);
+ }
- /**
- * Updates the view
- *
- * @param obs Observable item
- * @param obj Object item
- */
- @Override
- public void update(Observable obs, Object obj) {
- repaint();
- }
+ /**
+ * Updates the view
+ *
+ * @param obs Observable item
+ * @param obj Object item
+ */
+ @Override
+ public void update(Observable obs, Object obj) {
+ repaint();
+ }
}
\ No newline at end of file
diff --git a/src/fr/enssat/BoulderDash/views/HelpView.java b/src/fr/enssat/BoulderDash/views/HelpView.java
index f8175404..5134bd84 100644
--- a/src/fr/enssat/BoulderDash/views/HelpView.java
+++ b/src/fr/enssat/BoulderDash/views/HelpView.java
@@ -5,15 +5,15 @@ import java.awt.BorderLayout;
import javax.swing.JFrame;
import javax.swing.JTextArea;
-public class HelpView extends JFrame{
-
- /**
- * Generate the HelpView
- */
- public HelpView(){
- this.initializeView();
- this.createLayout();
- }
+public class HelpView extends JFrame {
+
+ /**
+ * Generate the HelpView
+ */
+ public HelpView() {
+ this.initializeView();
+ this.createLayout();
+ }
/**
* Initializes the view
@@ -33,18 +33,18 @@ public class HelpView extends JFrame{
/**
* Creates the view layout
*/
- private void createLayout() {
- JTextArea help = new JTextArea();
- help.setEditable(false);
- help.setText("To use the editor, you should :\n"
- + "- Select an item on the list,\n"
- + "- Move the RED cursur with the arrows\n"
- + "- To place the selected item on the field, use SPACEBAR.\n"
- + "If you want to lock the placement of the things, hit shift once (to unlock, rehit shift)\n"
- + "Then, you can save & load your creation on game.\n"
- + "You have to place at least 3 diamonds and 1 rockford!\n"
- + "Have fun ;-)");
-
+ private void createLayout() {
+ JTextArea help = new JTextArea();
+ help.setEditable(false);
+ help.setText("To use the editor, you should :\n"
+ + "- Select an item on the list,\n"
+ + "- Move the RED cursur with the arrows\n"
+ + "- To place the selected item on the field, use SPACEBAR.\n"
+ + "If you want to lock the placement of the things, hit shift once (to unlock, rehit shift)\n"
+ + "Then, you can save & load your creation on game.\n"
+ + "You have to place at least 3 diamonds and 1 rockford!\n"
+ + "Have fun ;-)");
+
this.add(help, BorderLayout.CENTER);
}
}
diff --git a/src/fr/enssat/BoulderDash/views/InformationPanel.java b/src/fr/enssat/BoulderDash/views/InformationPanel.java
index 95efc596..be80d26f 100644
--- a/src/fr/enssat/BoulderDash/views/InformationPanel.java
+++ b/src/fr/enssat/BoulderDash/views/InformationPanel.java
@@ -11,44 +11,44 @@ import fr.enssat.BoulderDash.models.LevelModel;
/**
* InformationPanel
- *
+ *
* Information panel element.
*
- * @author Colin Leverger
- * @since 2015-06-20
+ * @author Colin Leverger
+ * @since 2015-06-20
*/
public class InformationPanel extends JPanel implements Observer {
- private LevelModel levelModel;
- private JTextArea text;
+ private LevelModel levelModel;
+ private JTextArea text;
/**
* Class constructor
*/
- public InformationPanel(LevelModel levelModel) {
- this.levelModel = levelModel;
- this.text = new JTextArea();
- this.text.setEditable(false);
- this.levelModel.getGameInformationModel().addObserver(this);
+ public InformationPanel(LevelModel levelModel) {
+ this.levelModel = levelModel;
+ this.text = new JTextArea();
+ this.text.setEditable(false);
+ this.levelModel.getGameInformationModel().addObserver(this);
- this.text.setText(
+ this.text.setText(
"Score : " + levelModel.getGameInformationModel().getScore() +
- "\nRemaining diamonds : " + levelModel.getGameInformationModel().getRemainingsDiamonds()
+ "\nRemaining diamonds : " + levelModel.getGameInformationModel().getRemainingsDiamonds()
);
- this.add(this.text);
- }
+ this.add(this.text);
+ }
/**
* Updates the panel
*
- * @param o Observable item
- * @param arg Object item
+ * @param o Observable item
+ * @param arg Object item
*/
- @Override
- public void update(Observable o, Object arg) {
- this.text.setText(
+ @Override
+ public void update(Observable o, Object arg) {
+ this.text.setText(
"Score : " + this.levelModel.getGameInformationModel().getScore() +
- "\nRemaining diamonds : " + this.levelModel.getGameInformationModel().getRemainingsDiamonds()
+ "\nRemaining diamonds : " + this.levelModel.getGameInformationModel().getRemainingsDiamonds()
);
- }
+ }
}
diff --git a/src/fr/enssat/BoulderDash/views/LevelEditorGroundView.java b/src/fr/enssat/BoulderDash/views/LevelEditorGroundView.java
index 417a1b75..a4e69f6e 100644
--- a/src/fr/enssat/BoulderDash/views/LevelEditorGroundView.java
+++ b/src/fr/enssat/BoulderDash/views/LevelEditorGroundView.java
@@ -8,17 +8,17 @@ import fr.enssat.BoulderDash.models.LevelModel;
/**
* LevelEditorFieldView
- *
+ *
* Game field view for the level editor.
*
- * @author Valerian Saliou
- * @since 2015-06-21
+ * @author Valerian Saliou
+ * @since 2015-06-21
*/
public class LevelEditorGroundView extends GroundView {
/**
* Class constructor
*
- * @param levelModel Level model
+ * @param levelModel Level model
*/
public LevelEditorGroundView(LevelModel levelModel, LevelEditorView levelEditorView) {
super(levelModel);
diff --git a/src/fr/enssat/BoulderDash/views/LevelEditorView.java b/src/fr/enssat/BoulderDash/views/LevelEditorView.java
index d6e5557a..c74e943d 100644
--- a/src/fr/enssat/BoulderDash/views/LevelEditorView.java
+++ b/src/fr/enssat/BoulderDash/views/LevelEditorView.java
@@ -16,11 +16,11 @@ import fr.enssat.BoulderDash.views.MenuLevelSelector;
/**
* LevelEditorView
- *
+ *
* Specifies the level editor view.
*
- * @author Colin Leverger
- * @since 2015-06-19
+ * @author Colin Leverger
+ * @since 2015-06-19
*/
public class LevelEditorView extends JFrame implements Observer {
private LevelEditorGroundView fieldPanel;
@@ -39,23 +39,23 @@ public class LevelEditorView extends JFrame implements Observer {
/**
* Class constructor
*/
- public LevelEditorView(LevelEditorController levelEditorController, LevelModel levelModel, NavigationBetweenViewController nav) {
+ public LevelEditorView(LevelEditorController levelEditorController, LevelModel levelModel, NavigationBetweenViewController nav) {
this.levelEditorController = levelEditorController;
this.levelModel = levelModel;
this.nav = nav;
this.levelModel.addObserver(this);
- this.initializeView();
+ this.initializeView();
this.createLayout();
this.fieldPanel.grabFocus();
- }
+ }
/**
* Initializes the view layout
*/
- private void initializeView() {
+ private void initializeView() {
this.setFocusable(true);
this.setVisible(false);
this.setResizable(false);
@@ -70,18 +70,18 @@ public class LevelEditorView extends JFrame implements Observer {
Image appIcon = Toolkit.getDefaultToolkit().getImage("./res/app/app_icon.png");
this.setIconImage(appIcon);
- }
+ }
/**
* Creates the view layout
*/
- private void createLayout() {
+ private void createLayout() {
// List of levels
LevelSelectorHelper levelSelectorHelper = new LevelSelectorHelper(true, this);
this.menuLevelSelector = levelSelectorHelper.createLevelList();
// Field + select panels
- this.fieldPanel = new LevelEditorGroundView(this.levelModel, this);
+ this.fieldPanel = new LevelEditorGroundView(this.levelModel, this);
this.selectPanel = new JPanel();
this.assetsComponent = new AssetsLevelEditorComponent(this);
@@ -104,14 +104,14 @@ public class LevelEditorView extends JFrame implements Observer {
// Add top components
this.add(this.fieldPanel, BorderLayout.CENTER);
this.add(this.selectPanel, BorderLayout.WEST);
- }
+ }
/**
* Creates the given button
*
- * @param id Button identifier
- * @param name Button name
- * @return Created button
+ * @param id Button identifier
+ * @param name Button name
+ * @return Created button
*/
public JButton createButton(String id, String name) {
JButton button = new JButton(name);
@@ -124,7 +124,7 @@ public class LevelEditorView extends JFrame implements Observer {
/**
* Gets the level editor field view
*
- * @return Level editor field view
+ * @return Level editor field view
*/
public LevelEditorGroundView getLevelEditorGroundView() {
return this.fieldPanel;
@@ -133,7 +133,7 @@ public class LevelEditorView extends JFrame implements Observer {
/**
* Gets picked block value
*
- * @return Picked block value
+ * @return Picked block value
*/
public String getPickedBlockValue() {
return this.pickedBlockValue;
@@ -142,7 +142,7 @@ public class LevelEditorView extends JFrame implements Observer {
/**
* Sets picked block value
*
- * @param pickedBlockValue Picked block value
+ * @param pickedBlockValue Picked block value
*/
public void setPickedBlockValue(String pickedBlockValue) {
this.pickedBlockValue = pickedBlockValue;
@@ -151,8 +151,8 @@ public class LevelEditorView extends JFrame implements Observer {
/**
* Updates the view
*
- * @param obs Observable item
- * @param obj Object item
+ * @param obs Observable item
+ * @param obj Object item
*/
@Override
public void update(Observable obs, Object obj) {
@@ -162,12 +162,12 @@ public class LevelEditorView extends JFrame implements Observer {
/**
* Change opened level
*
- * @param selectedLevelValue Selected level value
+ * @param selectedLevelValue Selected level value
*/
public void openedLevelChange(String selectedLevelValue) {
LevelModel pickedLevelModel;
- if(selectedLevelValue != null && !selectedLevelValue.isEmpty()) {
+ if (selectedLevelValue != null && !selectedLevelValue.isEmpty()) {
// Load existing model
pickedLevelModel = new LevelModel(selectedLevelValue, this.nav.getAudioLoadHelper(), "editor");
} else {
@@ -195,13 +195,13 @@ public class LevelEditorView extends JFrame implements Observer {
/**
* Menu level selector change handler
*
- * @param changedSelector Changed selector
+ * @param changedSelector Changed selector
*/
public void menuLevelSelectorChanged(MenuLevelSelector changedSelector) {
String selectedLevelValue = changedSelector.getChoiceValue().toString();
// Value didn't change?
- if(selectedLevelValue.equals(this.getSelectedLevel())) {
+ if (selectedLevelValue.equals(this.getSelectedLevel())) {
return;
}
@@ -211,7 +211,7 @@ public class LevelEditorView extends JFrame implements Observer {
/**
* Gets selected level
*
- * @return Selected level
+ * @return Selected level
*/
public String getSelectedLevel() {
return this.selectedLevel;
@@ -220,9 +220,9 @@ public class LevelEditorView extends JFrame implements Observer {
/**
* Sets selected level
*
- * @param level Selected level
+ * @param level Selected level
*/
- public void setSelectedLevel(String level) {
- this.selectedLevel = level;
+ public void setSelectedLevel(String level) {
+ this.selectedLevel = level;
}
}
\ No newline at end of file
diff --git a/src/fr/enssat/BoulderDash/views/MenuImage.java b/src/fr/enssat/BoulderDash/views/MenuImage.java
index bc5e2dd0..7ee23f1c 100644
--- a/src/fr/enssat/BoulderDash/views/MenuImage.java
+++ b/src/fr/enssat/BoulderDash/views/MenuImage.java
@@ -10,11 +10,11 @@ import javax.swing.JPanel;
/**
* MenuImage
- *
+ *
* Specifies the menu image
*
- * @author Valerian Saliou
- * @since 2015-06-23
+ * @author Valerian Saliou
+ * @since 2015-06-23
*/
public class MenuImage extends JPanel {
private BufferedImage imageFile;
@@ -34,7 +34,7 @@ public class MenuImage extends JPanel {
/**
* Paints the component itself
*
- * @param g Graphics element
+ * @param g Graphics element
*/
@Override
protected void paintComponent(Graphics g) {
diff --git a/src/fr/enssat/BoulderDash/views/MenuLevelSelector.java b/src/fr/enssat/BoulderDash/views/MenuLevelSelector.java
index 9e67b0f9..792eddce 100644
--- a/src/fr/enssat/BoulderDash/views/MenuLevelSelector.java
+++ b/src/fr/enssat/BoulderDash/views/MenuLevelSelector.java
@@ -8,11 +8,11 @@ import fr.enssat.BoulderDash.views.LevelEditorView;
/**
* MenuLevelSelector
- *
+ *
* Specifies the menu level selector
*
- * @author Valerian Saliou
- * @since 2015-06-23
+ * @author Valerian Saliou
+ * @since 2015-06-23
*/
public class MenuLevelSelector extends JComboBox {
private String choiceValue;
@@ -33,13 +33,13 @@ public class MenuLevelSelector extends JComboBox {
/**
* Called when an action is performed
*
- * @param e Action event
+ * @param e Action event
*/
public void actionPerformed(ActionEvent e) {
JComboBox comboBoxSource = (JComboBox) e.getSource();
this.choiceValue = (String) comboBoxSource.getSelectedItem();
- if(this.levelEditorView != null) {
+ if (this.levelEditorView != null) {
this.levelEditorView.menuLevelSelectorChanged(this);
}
}
@@ -47,7 +47,7 @@ public class MenuLevelSelector extends JComboBox {
/**
* Gets the choice value
*
- * @return Choice value
+ * @return Choice value
*/
public String getChoiceValue() {
return this.choiceValue;
@@ -56,7 +56,7 @@ public class MenuLevelSelector extends JComboBox {
/**
* Selects a given value
*
- * @param value Value to be selected
+ * @param value Value to be selected
*/
public void setSelectedValue(String value) {
for (int i = 0; i < this.getItemCount(); i++) {
@@ -70,7 +70,7 @@ public class MenuLevelSelector extends JComboBox {
/**
* Sets the choice value
*
- * @param choiceValue Choice value
+ * @param choiceValue Choice value
*/
public void setChoiceValue(String choiceValue) {
this.choiceValue = choiceValue;
diff --git a/src/fr/enssat/BoulderDash/views/MenuView.java b/src/fr/enssat/BoulderDash/views/MenuView.java
index d6359e07..f1bf0325 100644
--- a/src/fr/enssat/BoulderDash/views/MenuView.java
+++ b/src/fr/enssat/BoulderDash/views/MenuView.java
@@ -12,27 +12,27 @@ import fr.enssat.BoulderDash.controllers.NavigationBetweenViewController;
/**
* MenuView
- *
+ *
* Menu view
*
- * @author Valerian Saliou
- * @since 2015-06-23
+ * @author Valerian Saliou
+ * @since 2015-06-23
*/
public class MenuView extends JFrame {
- private NavigationBetweenViewController navigationBetweenViewController;
+ private NavigationBetweenViewController navigationBetweenViewController;
private MenuImage menuImage;
private MenuLevelSelector menuLevelSelector;
- private JPanel actionPanel;
+ private JPanel actionPanel;
private JPanel targetPanel;
/**
* Class constructor
*/
- public MenuView(NavigationBetweenViewController navigationBetweenViewController) {
- this.navigationBetweenViewController = navigationBetweenViewController;
- this.initializeView();
- this.createLayout();
- }
+ public MenuView(NavigationBetweenViewController navigationBetweenViewController) {
+ this.navigationBetweenViewController = navigationBetweenViewController;
+ this.initializeView();
+ this.createLayout();
+ }
/**
* Initializes the view
@@ -60,8 +60,8 @@ public class MenuView extends JFrame {
this.targetPanel = new JPanel();
this.menuImage = new MenuImage();
- this.actionPanel = new JPanel();
-
+ this.actionPanel = new JPanel();
+
// Add some buttons on the actionPanel
this.createButton("game", "Game");
this.createButton("editor", "Editor");
@@ -77,23 +77,23 @@ public class MenuView extends JFrame {
/**
* Creates the given button
*
- * @param name Button name
- * @return Created button
+ * @param name Button name
+ * @return Created button
*/
- public JButton createButton(String id, String name) {
- JButton button = new JButton(name);
- button.addActionListener(this.navigationBetweenViewController);
+ public JButton createButton(String id, String name) {
+ JButton button = new JButton(name);
+ button.addActionListener(this.navigationBetweenViewController);
button.setActionCommand(id);
- this.actionPanel.add(button);
+ this.actionPanel.add(button);
- return button;
- }
+ return button;
+ }
/**
* Gets the selected level identifier!
*
- * @return Level identifier
+ * @return Level identifier
*/
public String getLevelIdentifier() {
return this.menuLevelSelector.getChoiceValue();
diff --git a/src/fr/enssat/BoulderDash/views/WinLoseView.java b/src/fr/enssat/BoulderDash/views/WinLoseView.java
index b0c85837..c74ae887 100644
--- a/src/fr/enssat/BoulderDash/views/WinLoseView.java
+++ b/src/fr/enssat/BoulderDash/views/WinLoseView.java
@@ -5,18 +5,18 @@ import java.awt.BorderLayout;
import javax.swing.JFrame;
import javax.swing.JTextArea;
-public class WinLoseView extends JFrame{
-
- private String winOrLose;
+public class WinLoseView extends JFrame {
- /**
- * Generate the HelpView
- */
- public WinLoseView(String winOrLose){
- this.winOrLose = winOrLose;
- this.initializeView();
- this.createLayout();
- }
+ private String winOrLose;
+
+ /**
+ * Generate the HelpView
+ */
+ public WinLoseView(String winOrLose) {
+ this.winOrLose = winOrLose;
+ this.initializeView();
+ this.createLayout();
+ }
/**
* Initializes the view
@@ -36,14 +36,14 @@ public class WinLoseView extends JFrame{
/**
* Creates the view layout
*/
- private void createLayout() {
- JTextArea help = new JTextArea();
- help.setEditable(false);
- if(winOrLose.equals("win"))
- help.setText("YOU WIN THE GAME :-)");
- else
- help.setText("YOU LOSE THE GAME :-( TRY AGAIN!");
-
+ private void createLayout() {
+ JTextArea help = new JTextArea();
+ help.setEditable(false);
+ if (winOrLose.equals("win"))
+ help.setText("YOU WIN THE GAME :-)");
+ else
+ help.setText("YOU LOSE THE GAME :-( TRY AGAIN!");
+
this.add(help);
}
}