Advertisement
fewfw

Untitled

May 31st, 2020
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.70 KB | None | 0 0
  1. package userinterface;
  2.  
  3. import javax.swing.JFrame;
  4.  
  5. public class GameWindow extends JFrame {
  6.  
  7.     public static final int SCREEN_WIDTH = 600;
  8.     private GameScreen gameScreen;
  9.  
  10.     public GameWindow() {
  11.         super("Java T-Rex game");
  12.         setSize(SCREEN_WIDTH, 175);
  13.         setLocation(400, 200);
  14.         setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  15.         setResizable(false);
  16.         gameScreen = new GameScreen();
  17.         addKeyListener(gameScreen);
  18.         add(gameScreen);
  19.     }
  20.  
  21.     public void startGame() {
  22.         setVisible(true);
  23.         gameScreen.startGame();
  24.     }
  25.  
  26.     public static void main(String args[]) {
  27.         (new GameWindow()).startGame();
  28.     }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement