Add TwoPlayerGameDriver
This commit is contained in:
41
TwoPlayerGameDriver
Normal file
41
TwoPlayerGameDriver
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
import javax.swing.*;
|
||||||
|
import java.awt.*;
|
||||||
|
|
||||||
|
public class TwoPlayerGameDriver
|
||||||
|
{
|
||||||
|
public static void main(String[] args)
|
||||||
|
{
|
||||||
|
JFrame frame = new JFrame();
|
||||||
|
frame.setTitle("Two Player Game");
|
||||||
|
|
||||||
|
// CardLayout
|
||||||
|
CardLayout layout = new CardLayout();
|
||||||
|
JPanel container = new JPanel(layout);
|
||||||
|
|
||||||
|
//Panels
|
||||||
|
GameFields gamePanel = new GameFields();
|
||||||
|
LvlManager levelMenu = new LvlManager(gamePanel);
|
||||||
|
MainMenu menuPanel = new MainMenu(gamePanel);
|
||||||
|
|
||||||
|
//add to cardLayout
|
||||||
|
container.add(menuPanel, "MENU"); //+ more
|
||||||
|
container.add(levelMenu, "LEVELS");
|
||||||
|
container.add(gamePanel, "GAME");
|
||||||
|
|
||||||
|
//switch screens
|
||||||
|
menuPanel.setContainer(container,layout); //+ more
|
||||||
|
levelMenu.setContainer(container,layout);
|
||||||
|
gamePanel.setContainer(container,layout);
|
||||||
|
|
||||||
|
frame.add(container);
|
||||||
|
frame.pack();
|
||||||
|
frame.setLocationRelativeTo(null);
|
||||||
|
//gamePanel.requestFocus();
|
||||||
|
frame.setVisible(true);
|
||||||
|
|
||||||
|
//frame
|
||||||
|
frame.setResizable(false);
|
||||||
|
frame.setSize(640, 360); //<-- change later
|
||||||
|
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user