1
0
Fork 0

Compare commits

..

No commits in common. "05a4463ba83a49ae91f537dbcafa8fe9aa003785" and "59fdc12e4f5636c8e5925d175d1915226bfc7497" have entirely different histories.

4 changed files with 7 additions and 52 deletions

View File

@ -136,7 +136,7 @@ public class Controller implements ActionListener, KeyListener {
case KeyEvent.VK_ESCAPE:
// exit current level
game.getLevel().setFinished(true);
toStartScreen(game.getLevel().getScore());
toStartScreen();
break;
}
@ -161,14 +161,10 @@ public class Controller implements ActionListener, KeyListener {
/**
* This method switches the view to the StartScreen view.
* @param score The player score
*/
public void toStartScreen(int score) {
public void toStartScreen() {
view.showScreen(StartScreen.class.getName());
view.getStartScreen().requestFocusInWindow();
view.getStartScreen().addScore(score);
view.getStartScreen().repaint();
}
/**

View File

@ -114,7 +114,7 @@ public class Game {
controller.toPlayground();
} else {
// tells the controller to switch to the startScreen of the game
controller.toStartScreen(level.getScore());
controller.toStartScreen();
}

View File

@ -272,11 +272,6 @@ public class Level extends Thread implements ILevel {
if(stone.getType() == 0) {
stones.remove(stone);
}
if(allStonesBroken()) {
setFinished(true);
nextLevel();
}
}
/**
@ -301,7 +296,7 @@ public class Level extends Thread implements ILevel {
// level failed
} else {
setFinished(true);
game.getController().toStartScreen(getScore());
game.getController().toStartScreen();
}
}
@ -337,13 +332,6 @@ public class Level extends Thread implements ILevel {
public int getLives() {
return lifeCounter;
}
/**
* switch to next level
*/
public void nextLevel() {
game.createLevel(++levelnr, score);
}
}

View File

@ -51,11 +51,6 @@ public class StartScreen extends JPanel {
*/
private JLabel error;
/**
* The scoreMenu
*/
private SectionPanel scoreMenu;
/**
* The constructor needs a view
@ -130,16 +125,16 @@ public class StartScreen extends JPanel {
*/
private void initializeScoreMenu() {
// The layout
scoreMenu = new SectionPanel(Color.WHITE);
SectionPanel scoreMenu = new SectionPanel(Color.WHITE);
scoreMenu.shady = false;
scoreMenu.setLayout(new MigLayout("", "10[center, grow, fill]10",
"5[center]5"));
// adding the components to the layout
// adding the compoenents to the layout
JLabel headline = new JLabel("Scores");
headline.setFont(new Font("Sans-serif", Font.PLAIN, 16));
headline.setHorizontalAlignment(SwingConstants.CENTER);
scoreMenu.add(headline, "cell 0 0, gaptop 5, wrap");
scoreMenu.add(headline, "cell 0 0, gaptop 5");
add(scoreMenu, "cell 1 0, gapleft 5");
}
@ -205,28 +200,4 @@ public class StartScreen extends JPanel {
error.setText("");
}
/**
* Adds a score to the scoreboard
* @param score
*/
public void addScore(int score) {
// adding the components to the layout
// name
JLabel lName = new JLabel(getPlayersName());
lName.setFont(new Font("Sans-serif", Font.PLAIN, 16));
lName.setHorizontalAlignment(SwingConstants.CENTER);
scoreMenu.add(lName, "gaptop 5");
// spacing
JLabel space = new JLabel();
scoreMenu.add(space);
// score
JLabel lScore = new JLabel(String.valueOf(score));
lScore.setFont(new Font("Sans-serif", Font.PLAIN, 16));
lScore.setHorizontalAlignment(SwingConstants.CENTER);
scoreMenu.add(lScore, "gaptop 5, wrap");
}
}