mv levelModel field up to superclass
This commit is contained in:
parent
99db8d4956
commit
f896028199
@ -0,0 +1,11 @@
|
|||||||
|
package fr.enssat.BoulderDash.controllers;
|
||||||
|
|
||||||
|
import fr.enssat.BoulderDash.models.LevelModel;
|
||||||
|
|
||||||
|
public abstract class AbstractLevelController {
|
||||||
|
protected LevelModel levelModel;
|
||||||
|
|
||||||
|
public AbstractLevelController(LevelModel levelModel) {
|
||||||
|
this.levelModel = levelModel;
|
||||||
|
}
|
||||||
|
}
|
@ -7,7 +7,7 @@ import fr.enssat.BoulderDash.helpers.AudioLoadHelper;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* ElementPositionUpdateHelper
|
* ElementPositionUpdateHelper
|
||||||
*
|
* <p>
|
||||||
* Updates position of all elements displayed on the map, according to their
|
* 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
|
* 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.
|
* their power to destroy in the food chain. Sorry for that Darwinism.
|
||||||
@ -15,8 +15,7 @@ import fr.enssat.BoulderDash.helpers.AudioLoadHelper;
|
|||||||
* @author Colin Leverger <me@colinleverger.fr>
|
* @author Colin Leverger <me@colinleverger.fr>
|
||||||
* @since 2015-06-19
|
* @since 2015-06-19
|
||||||
*/
|
*/
|
||||||
public class BoulderAndDiamondController implements Runnable {
|
public class BoulderAndDiamondController extends AbstractLevelController implements Runnable {
|
||||||
private LevelModel levelModel;
|
|
||||||
private AudioLoadHelper audioLoadHelper;
|
private AudioLoadHelper audioLoadHelper;
|
||||||
private Thread elementMovingThread;
|
private Thread elementMovingThread;
|
||||||
|
|
||||||
@ -26,7 +25,7 @@ public class BoulderAndDiamondController implements Runnable {
|
|||||||
* @param levelModel Level model
|
* @param levelModel Level model
|
||||||
*/
|
*/
|
||||||
public BoulderAndDiamondController(LevelModel levelModel, AudioLoadHelper audioLoadHelper) {
|
public BoulderAndDiamondController(LevelModel levelModel, AudioLoadHelper audioLoadHelper) {
|
||||||
this.levelModel = levelModel;
|
super(levelModel);
|
||||||
this.audioLoadHelper = audioLoadHelper;
|
this.audioLoadHelper = audioLoadHelper;
|
||||||
|
|
||||||
// Start thread
|
// Start thread
|
||||||
@ -39,7 +38,7 @@ public class BoulderAndDiamondController implements Runnable {
|
|||||||
*/
|
*/
|
||||||
public void run() {
|
public void run() {
|
||||||
while (this.levelModel.isGameRunning()) {
|
while (this.levelModel.isGameRunning()) {
|
||||||
if(!this.levelModel.getGamePaused()){
|
if (!this.levelModel.getGamePaused()) {
|
||||||
this.manageFallingObject();
|
this.manageFallingObject();
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
@ -61,7 +60,7 @@ public class BoulderAndDiamondController implements Runnable {
|
|||||||
// Gets the spriteName of actual DisplayableElementModel object scanned
|
// Gets the spriteName of actual DisplayableElementModel object scanned
|
||||||
DisplayableElementModel elementModel = this.levelModel.getGroundLevelModel()[x][y];
|
DisplayableElementModel elementModel = this.levelModel.getGroundLevelModel()[x][y];
|
||||||
|
|
||||||
if(elementModel == null) {
|
if (elementModel == null) {
|
||||||
elementModel = new DirtModel();
|
elementModel = new DirtModel();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -70,8 +69,8 @@ public class BoulderAndDiamondController implements Runnable {
|
|||||||
// If it is a boulder or a diamond...
|
// If it is a boulder or a diamond...
|
||||||
if (spriteName == "boulder" || spriteName == "diamond") {
|
if (spriteName == "boulder" || spriteName == "diamond") {
|
||||||
this.manageFall(x, y);
|
this.manageFall(x, y);
|
||||||
} else if(spriteName == "expandingwall"){
|
} else if (spriteName == "expandingwall") {
|
||||||
if(this.expandWall(x,y).equals("left")){
|
if (this.expandWall(x, y).equals("left")) {
|
||||||
x -= 1;
|
x -= 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -92,12 +91,12 @@ public class BoulderAndDiamondController implements Runnable {
|
|||||||
String spriteNameRight = elementRight.getSpriteName();
|
String spriteNameRight = elementRight.getSpriteName();
|
||||||
|
|
||||||
String way = "";
|
String way = "";
|
||||||
if(spriteNameLeft == "black"){
|
if (spriteNameLeft == "black") {
|
||||||
this.levelModel.expandThisWallToLeft(x,y);
|
this.levelModel.expandThisWallToLeft(x, y);
|
||||||
way = "left";
|
way = "left";
|
||||||
}
|
}
|
||||||
if(spriteNameRight == "black"){
|
if (spriteNameRight == "black") {
|
||||||
this.levelModel.expandThisWallToRight(x,y);
|
this.levelModel.expandThisWallToRight(x, y);
|
||||||
way = "right";
|
way = "right";
|
||||||
}
|
}
|
||||||
return way;
|
return way;
|
||||||
@ -143,9 +142,9 @@ public class BoulderAndDiamondController implements Runnable {
|
|||||||
this.levelModel.setGameRunning(false);
|
this.levelModel.setGameRunning(false);
|
||||||
} else if (spriteNameBelow == "magicwall") {
|
} else if (spriteNameBelow == "magicwall") {
|
||||||
if (this.levelModel.getGroundLevelModel()[x][y].getSpriteName() == "boulder"
|
if (this.levelModel.getGroundLevelModel()[x][y].getSpriteName() == "boulder"
|
||||||
&& (this.levelModel.getGroundLevelModel()[x][y+2].getSpriteName() == "dirt" ||
|
&& (this.levelModel.getGroundLevelModel()[x][y + 2].getSpriteName() == "dirt" ||
|
||||||
this.levelModel.getGroundLevelModel()[x][y+2].getSpriteName() == "black")) {
|
this.levelModel.getGroundLevelModel()[x][y + 2].getSpriteName() == "black")) {
|
||||||
if(this.levelModel.getGroundLevelModel()[x][y].isConvertible()) {
|
if (this.levelModel.getGroundLevelModel()[x][y].isConvertible()) {
|
||||||
this.levelModel.transformThisBoulderIntoADiamond(x, y);
|
this.levelModel.transformThisBoulderIntoADiamond(x, y);
|
||||||
} else {
|
} else {
|
||||||
this.levelModel.deleteThisBoulder(x, y);
|
this.levelModel.deleteThisBoulder(x, y);
|
||||||
|
@ -2,7 +2,6 @@ package fr.enssat.BoulderDash.controllers;
|
|||||||
|
|
||||||
import fr.enssat.BoulderDash.models.LevelModel;
|
import fr.enssat.BoulderDash.models.LevelModel;
|
||||||
import fr.enssat.BoulderDash.helpers.AudioLoadHelper;
|
import fr.enssat.BoulderDash.helpers.AudioLoadHelper;
|
||||||
import fr.enssat.BoulderDash.controllers.NavigationBetweenViewController;
|
|
||||||
import fr.enssat.BoulderDash.views.MenuView;
|
import fr.enssat.BoulderDash.views.MenuView;
|
||||||
import fr.enssat.BoulderDash.views.GameView;
|
import fr.enssat.BoulderDash.views.GameView;
|
||||||
|
|
||||||
@ -12,15 +11,14 @@ import java.awt.event.ActionListener;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* GameController
|
* GameController
|
||||||
*
|
* <p>
|
||||||
* This system creates the view.
|
* This system creates the view.
|
||||||
* The game loop is also handled there.
|
* The game loop is also handled there.
|
||||||
*
|
*
|
||||||
* @author Colin Leverger <me@colinleverger.fr>
|
* @author Colin Leverger <me@colinleverger.fr>
|
||||||
* @since 2015-06-19
|
* @since 2015-06-19
|
||||||
*/
|
*/
|
||||||
public class GameController implements ActionListener {
|
public class GameController extends AbstractLevelController implements ActionListener {
|
||||||
private LevelModel levelModel;
|
|
||||||
private AudioLoadHelper audioLoadHelper;
|
private AudioLoadHelper audioLoadHelper;
|
||||||
private boolean firstClickOnPause;
|
private boolean firstClickOnPause;
|
||||||
private MenuView menuView;
|
private MenuView menuView;
|
||||||
@ -34,11 +32,12 @@ public class GameController implements ActionListener {
|
|||||||
* @param navigationBetweenViewController
|
* @param navigationBetweenViewController
|
||||||
*/
|
*/
|
||||||
public GameController(LevelModel levelModel, AudioLoadHelper audioLoadHelper, NavigationBetweenViewController navigationBetweenViewController) {
|
public GameController(LevelModel levelModel, AudioLoadHelper audioLoadHelper, NavigationBetweenViewController navigationBetweenViewController) {
|
||||||
|
super(levelModel);
|
||||||
|
|
||||||
this.firstClickOnPause = true;
|
this.firstClickOnPause = true;
|
||||||
|
|
||||||
this.navigationBetweenViewController = navigationBetweenViewController;
|
this.navigationBetweenViewController = navigationBetweenViewController;
|
||||||
|
|
||||||
this.levelModel = levelModel;
|
|
||||||
this.audioLoadHelper = audioLoadHelper;
|
this.audioLoadHelper = audioLoadHelper;
|
||||||
this.gameView = new GameView(this, levelModel);
|
this.gameView = new GameView(this, levelModel);
|
||||||
this.menuView = navigationBetweenViewController.getMenuView();
|
this.menuView = navigationBetweenViewController.getMenuView();
|
||||||
@ -53,11 +52,11 @@ public class GameController implements ActionListener {
|
|||||||
* @param event Action event
|
* @param event Action event
|
||||||
*/
|
*/
|
||||||
public void actionPerformed(ActionEvent event) {
|
public void actionPerformed(ActionEvent event) {
|
||||||
switch(event.getActionCommand()) {
|
switch (event.getActionCommand()) {
|
||||||
case "pause":
|
case "pause":
|
||||||
if(this.firstClickOnPause) {
|
if (this.firstClickOnPause) {
|
||||||
this.levelModel.setGamePaused(true);
|
this.levelModel.setGamePaused(true);
|
||||||
} else if(!this.firstClickOnPause) {
|
} else if (!this.firstClickOnPause) {
|
||||||
this.levelModel.setGamePaused(false);
|
this.levelModel.setGamePaused(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -85,7 +84,7 @@ public class GameController implements ActionListener {
|
|||||||
private void resetGame(String source) {
|
private void resetGame(String source) {
|
||||||
this.gameView.dispose();
|
this.gameView.dispose();
|
||||||
|
|
||||||
if(source.equals("restart")){
|
if (source.equals("restart")) {
|
||||||
this.levelModel = new LevelModel(this.navigationBetweenViewController.getPickedLevelIdentifier(), audioLoadHelper);
|
this.levelModel = new LevelModel(this.navigationBetweenViewController.getPickedLevelIdentifier(), audioLoadHelper);
|
||||||
this.gameView = new GameView(this, levelModel);
|
this.gameView = new GameView(this, levelModel);
|
||||||
this.gameView.setVisible(true);
|
this.gameView.setVisible(true);
|
||||||
@ -103,6 +102,7 @@ public class GameController implements ActionListener {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the game view
|
* Return the game view
|
||||||
|
*
|
||||||
* @return gameView
|
* @return gameView
|
||||||
*/
|
*/
|
||||||
public GameView getGameView() {
|
public GameView getGameView() {
|
||||||
@ -111,6 +111,7 @@ public class GameController implements ActionListener {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the gameView
|
* Set the gameView
|
||||||
|
*
|
||||||
* @param gameView
|
* @param gameView
|
||||||
*/
|
*/
|
||||||
public void setGameView(GameView gameView) {
|
public void setGameView(GameView gameView) {
|
||||||
|
@ -2,8 +2,6 @@ package fr.enssat.BoulderDash.controllers;
|
|||||||
|
|
||||||
import fr.enssat.BoulderDash.models.DisplayableElementModel;
|
import fr.enssat.BoulderDash.models.DisplayableElementModel;
|
||||||
import fr.enssat.BoulderDash.models.LevelModel;
|
import fr.enssat.BoulderDash.models.LevelModel;
|
||||||
import fr.enssat.BoulderDash.controllers.RockfordUpdateController;
|
|
||||||
import fr.enssat.BoulderDash.controllers.BoulderAndDiamondController;
|
|
||||||
import fr.enssat.BoulderDash.helpers.AudioLoadHelper;
|
import fr.enssat.BoulderDash.helpers.AudioLoadHelper;
|
||||||
|
|
||||||
import java.awt.event.KeyEvent;
|
import java.awt.event.KeyEvent;
|
||||||
@ -12,22 +10,22 @@ import java.awt.event.KeyListener;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* GameKeyController
|
* GameKeyController
|
||||||
*
|
* <p>
|
||||||
* Manages the key events controller.
|
* Manages the key events controller.
|
||||||
*
|
*
|
||||||
* @author Colin Leverger <me@colinleverger.fr>
|
* @author Colin Leverger <me@colinleverger.fr>
|
||||||
* @since 2015-06-19
|
* @since 2015-06-19
|
||||||
*/
|
*/
|
||||||
public class GameKeyController implements KeyListener {
|
public class GameKeyController extends AbstractLevelController implements KeyListener {
|
||||||
private LevelModel levelModel;
|
|
||||||
private RockfordUpdateController updatePosRockford;
|
private RockfordUpdateController updatePosRockford;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class constructor
|
* Class constructor
|
||||||
*
|
*
|
||||||
* @param levelModel Level model
|
* @param levelModel Level model
|
||||||
*/
|
*/
|
||||||
public GameKeyController(LevelModel levelModel, AudioLoadHelper audioLoadHelper) {
|
public GameKeyController(LevelModel levelModel, AudioLoadHelper audioLoadHelper) {
|
||||||
this.levelModel = levelModel;
|
super(levelModel);
|
||||||
new BoulderAndDiamondController(levelModel, audioLoadHelper);
|
new BoulderAndDiamondController(levelModel, audioLoadHelper);
|
||||||
this.updatePosRockford = new RockfordUpdateController(levelModel);
|
this.updatePosRockford = new RockfordUpdateController(levelModel);
|
||||||
}
|
}
|
||||||
|
@ -9,20 +9,18 @@ import fr.enssat.BoulderDash.helpers.LevelSaveHelper;
|
|||||||
import fr.enssat.BoulderDash.models.LevelModel;
|
import fr.enssat.BoulderDash.models.LevelModel;
|
||||||
import fr.enssat.BoulderDash.views.HelpView;
|
import fr.enssat.BoulderDash.views.HelpView;
|
||||||
import fr.enssat.BoulderDash.views.LevelEditorView;
|
import fr.enssat.BoulderDash.views.LevelEditorView;
|
||||||
import fr.enssat.BoulderDash.controllers.NavigationBetweenViewController;
|
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* LevelEditorController
|
* LevelEditorController
|
||||||
*
|
* <p>
|
||||||
* Manages the level editor controller.
|
* Manages the level editor controller.
|
||||||
*
|
*
|
||||||
* @author Valerian Saliou <valerian@valeriansaliou.name>
|
* @author Valerian Saliou <valerian@valeriansaliou.name>
|
||||||
* @since 2015-06-19
|
* @since 2015-06-19
|
||||||
*/
|
*/
|
||||||
public class LevelEditorController implements ActionListener {
|
public class LevelEditorController extends AbstractLevelController implements ActionListener {
|
||||||
private LevelModel levelModel;
|
|
||||||
private LevelEditorView levelEditorView;
|
private LevelEditorView levelEditorView;
|
||||||
private NavigationBetweenViewController nav;
|
private NavigationBetweenViewController nav;
|
||||||
|
|
||||||
@ -32,7 +30,7 @@ public class LevelEditorController implements ActionListener {
|
|||||||
* @param levelModel Level model
|
* @param levelModel Level model
|
||||||
*/
|
*/
|
||||||
public LevelEditorController(LevelModel levelModel, NavigationBetweenViewController nav) {
|
public LevelEditorController(LevelModel levelModel, NavigationBetweenViewController nav) {
|
||||||
this.levelModel = levelModel;
|
super(levelModel);
|
||||||
this.levelModel.setShowCursor(true);
|
this.levelModel.setShowCursor(true);
|
||||||
|
|
||||||
this.nav = nav;
|
this.nav = nav;
|
||||||
@ -50,7 +48,7 @@ public class LevelEditorController implements ActionListener {
|
|||||||
* @param event Action event
|
* @param event Action event
|
||||||
*/
|
*/
|
||||||
public void actionPerformed(ActionEvent event) {
|
public void actionPerformed(ActionEvent event) {
|
||||||
switch(event.getActionCommand()) {
|
switch (event.getActionCommand()) {
|
||||||
case "menu":
|
case "menu":
|
||||||
this.levelEditorView.setVisible(false);
|
this.levelEditorView.setVisible(false);
|
||||||
this.nav.setMenuView();
|
this.nav.setMenuView();
|
||||||
@ -67,7 +65,7 @@ public class LevelEditorController implements ActionListener {
|
|||||||
String levelId = this.levelEditorView.getSelectedLevel();
|
String levelId = this.levelEditorView.getSelectedLevel();
|
||||||
LevelSaveHelper levelSave;
|
LevelSaveHelper levelSave;
|
||||||
|
|
||||||
if(levelId == null || levelId.isEmpty()) {
|
if (levelId == null || levelId.isEmpty()) {
|
||||||
// Create a new level
|
// Create a new level
|
||||||
levelSave = new LevelSaveHelper(levelModel.getGroundLevelModel());
|
levelSave = new LevelSaveHelper(levelModel.getGroundLevelModel());
|
||||||
} else {
|
} else {
|
||||||
@ -79,7 +77,7 @@ public class LevelEditorController implements ActionListener {
|
|||||||
JOptionPane.showMessageDialog(frameDialog, "Level saved");
|
JOptionPane.showMessageDialog(frameDialog, "Level saved");
|
||||||
|
|
||||||
this.levelEditorView.openedLevelChange(levelSave.getLevelId());
|
this.levelEditorView.openedLevelChange(levelSave.getLevelId());
|
||||||
} catch(LevelConstraintNotRespectedException e) {
|
} catch (LevelConstraintNotRespectedException e) {
|
||||||
JFrame frameDialog = new JFrame("Error");
|
JFrame frameDialog = new JFrame("Error");
|
||||||
JOptionPane.showMessageDialog(frameDialog, e.getMessage());
|
JOptionPane.showMessageDialog(frameDialog, e.getMessage());
|
||||||
}
|
}
|
||||||
@ -90,7 +88,7 @@ public class LevelEditorController implements ActionListener {
|
|||||||
String levelId = this.levelEditorView.getSelectedLevel();
|
String levelId = this.levelEditorView.getSelectedLevel();
|
||||||
JFrame frameDialog = new JFrame("Info");
|
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!");
|
JOptionPane.showMessageDialog(frameDialog, "Level not yet saved, no need to delete it!");
|
||||||
} else {
|
} else {
|
||||||
new LevelRemoveHelper(levelId);
|
new LevelRemoveHelper(levelId);
|
||||||
|
@ -9,14 +9,13 @@ import java.awt.event.KeyListener;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* LevelEditorKeyController
|
* LevelEditorKeyController
|
||||||
*
|
* <p>
|
||||||
* Manages the key events controller.
|
* Manages the key events controller.
|
||||||
*
|
*
|
||||||
* @author Valerian Saliou <valerian@valeriansaliou.name>
|
* @author Valerian Saliou <valerian@valeriansaliou.name>
|
||||||
* @since 2015-06-21
|
* @since 2015-06-21
|
||||||
*/
|
*/
|
||||||
public class LevelEditorKeyController implements KeyListener {
|
public class LevelEditorKeyController extends AbstractLevelController implements KeyListener {
|
||||||
private LevelModel levelModel;
|
|
||||||
private LevelEditorView levelEditorView;
|
private LevelEditorView levelEditorView;
|
||||||
private boolean capLocks;
|
private boolean capLocks;
|
||||||
|
|
||||||
@ -27,7 +26,7 @@ public class LevelEditorKeyController implements KeyListener {
|
|||||||
* @param levelEditorView Level editor view
|
* @param levelEditorView Level editor view
|
||||||
*/
|
*/
|
||||||
public LevelEditorKeyController(LevelModel levelModel, LevelEditorView levelEditorView) {
|
public LevelEditorKeyController(LevelModel levelModel, LevelEditorView levelEditorView) {
|
||||||
this.levelModel = levelModel;
|
super(levelModel);
|
||||||
this.capLocks = false;
|
this.capLocks = false;
|
||||||
this.levelEditorView = levelEditorView;
|
this.levelEditorView = levelEditorView;
|
||||||
}
|
}
|
||||||
@ -72,7 +71,7 @@ public class LevelEditorKeyController implements KeyListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Hold block change (quick edit)
|
// Hold block change (quick edit)
|
||||||
if(capLocks) {
|
if (capLocks) {
|
||||||
this.levelModel.triggerBlockChange(this.levelEditorView.getPickedBlockValue());
|
this.levelModel.triggerBlockChange(this.levelEditorView.getPickedBlockValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,13 +13,11 @@ import fr.enssat.BoulderDash.controllers.GameController;
|
|||||||
* Controller to navigate between the different views
|
* Controller to navigate between the different views
|
||||||
*
|
*
|
||||||
* @author Colin Leverger <me@colinleverger.fr>
|
* @author Colin Leverger <me@colinleverger.fr>
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class NavigationBetweenViewController implements ActionListener {
|
public class NavigationBetweenViewController implements ActionListener {
|
||||||
private LevelEditorController levelEditorController;
|
private LevelEditorController levelEditorController;
|
||||||
private MenuView menuView;
|
private MenuView menuView;
|
||||||
private AudioLoadHelper audioLoadHelper;
|
private AudioLoadHelper audioLoadHelper;
|
||||||
private LevelModel levelModelForGame, levelModelForEditor;
|
|
||||||
private GameController gameController;
|
private GameController gameController;
|
||||||
private String pickedLevelIdentifier;
|
private String pickedLevelIdentifier;
|
||||||
|
|
||||||
@ -50,8 +48,8 @@ public class NavigationBetweenViewController implements ActionListener {
|
|||||||
|
|
||||||
case "editor":
|
case "editor":
|
||||||
// New blank model for editor
|
// New blank model for editor
|
||||||
this.levelModelForEditor = new LevelModel(audioLoadHelper);
|
LevelModel levelModelForEditor = new LevelModel(audioLoadHelper);
|
||||||
this.levelEditorController = new LevelEditorController(this.levelModelForEditor, this);
|
this.levelEditorController = new LevelEditorController(levelModelForEditor, this);
|
||||||
|
|
||||||
this.levelEditorController.getLevelEditorView().setVisible(true);
|
this.levelEditorController.getLevelEditorView().setVisible(true);
|
||||||
this.levelEditorController.getLevelEditorView().getLevelEditorGroundView().grabFocus();
|
this.levelEditorController.getLevelEditorView().getLevelEditorGroundView().grabFocus();
|
||||||
@ -66,7 +64,7 @@ public class NavigationBetweenViewController implements ActionListener {
|
|||||||
// Reinit the levelModelForGame...
|
// Reinit the levelModelForGame...
|
||||||
pickedLevelIdentifier = this.menuView.getLevelIdentifier();
|
pickedLevelIdentifier = this.menuView.getLevelIdentifier();
|
||||||
|
|
||||||
this.levelModelForGame = new LevelModel(pickedLevelIdentifier, audioLoadHelper);
|
LevelModel levelModelForGame = new LevelModel(pickedLevelIdentifier, audioLoadHelper);
|
||||||
this.gameController = new GameController(levelModelForGame, audioLoadHelper, this);
|
this.gameController = new GameController(levelModelForGame, audioLoadHelper, this);
|
||||||
|
|
||||||
if (levelEditorController != null) {
|
if (levelEditorController != null) {
|
||||||
|
@ -4,7 +4,7 @@ import fr.enssat.BoulderDash.models.LevelModel;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* ElementPositionUpdateHelper
|
* ElementPositionUpdateHelper
|
||||||
*
|
* <p>
|
||||||
* Updates position of all elements displayed on the map, according to their
|
* 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
|
* 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.
|
* their power to destroy in the food chain. Sorry for that Darwinism.
|
||||||
@ -12,8 +12,7 @@ import fr.enssat.BoulderDash.models.LevelModel;
|
|||||||
* @author Colin Leverger <me@colinleverger.fr>
|
* @author Colin Leverger <me@colinleverger.fr>
|
||||||
* @since 2015-06-19
|
* @since 2015-06-19
|
||||||
*/
|
*/
|
||||||
public class RockfordUpdateController implements Runnable {
|
public class RockfordUpdateController extends AbstractLevelController implements Runnable {
|
||||||
private LevelModel levelModel;
|
|
||||||
private Thread elementMovingThread;
|
private Thread elementMovingThread;
|
||||||
private int rockfordPositionX;
|
private int rockfordPositionX;
|
||||||
private int rockfordPositionY;
|
private int rockfordPositionY;
|
||||||
@ -25,7 +24,7 @@ public class RockfordUpdateController implements Runnable {
|
|||||||
* @param levelModel Level model
|
* @param levelModel Level model
|
||||||
*/
|
*/
|
||||||
public RockfordUpdateController(LevelModel levelModel) {
|
public RockfordUpdateController(LevelModel levelModel) {
|
||||||
this.levelModel = levelModel;
|
super(levelModel);
|
||||||
this.elementMovingThread = new Thread(this);
|
this.elementMovingThread = new Thread(this);
|
||||||
this.elementMovingThread.start();
|
this.elementMovingThread.start();
|
||||||
this.rockfordHasMoved = false;
|
this.rockfordHasMoved = false;
|
||||||
@ -36,7 +35,7 @@ public class RockfordUpdateController implements Runnable {
|
|||||||
*/
|
*/
|
||||||
public void run() {
|
public void run() {
|
||||||
while (this.levelModel.isGameRunning()) {
|
while (this.levelModel.isGameRunning()) {
|
||||||
if(!this.levelModel.getGamePaused()){
|
if (!this.levelModel.getGamePaused()) {
|
||||||
if (this.rockfordHasMoved) {
|
if (this.rockfordHasMoved) {
|
||||||
this.levelModel.setPositionOfRockford(rockfordPositionX, rockfordPositionY);
|
this.levelModel.setPositionOfRockford(rockfordPositionX, rockfordPositionY);
|
||||||
this.rockfordHasMoved = false;
|
this.rockfordHasMoved = false;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user