Skip to content

Instantly share code, notes, and snippets.

@mada360
Created March 4, 2014 10:45
Show Gist options
  • Save mada360/9344145 to your computer and use it in GitHub Desktop.
Save mada360/9344145 to your computer and use it in GitHub Desktop.
Breakout
// File [Main_java_BREAKOUT.html] MAS - last created: Mon 11 Nov 2013 15:40:29 GMT
package breakout;
/**
* Start the game
* The call to startGame() in the model starts the actual play of the game
* All issues of mutual exclusion on access to objects etc. are ignored
*/
public class Main{
public static void main( String args[] )
{
while(PlayState.getPlayState() != -1){
//Insert code to load main menu below
//Menu menu = new Menu();
if(PlayState.getPlayState() == 1){
Debug.trace("BreakOut");
ModelBreakout model = new ModelBreakout();
ViewBreakout view = new ViewBreakout();
new ControllerBreakout( model, view );
if(Sounds.getPlaySoundCheck() == true){
Sounds.music();
}
model.createGameObjects(); // Bricks/ bat/ ball
model.addObserver( view ); // Add observer to the model
view.setVisible(true); // Display view
model.startGame(); // Start play
break;
}else if(PlayState.getPlayState() == 2){
//Settings menu
PlayState.setPlayState(0);
}else if(PlayState.getPlayState() == 3){
//Level select
PlayState.setPlayState(0);
}else if(PlayState.getPlayState() == 4){
//Exit Game
System.out.println("Quit");
PlayState.setPlayState(-1);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment