瀏覽代碼

First Commit

Kenneth van Ewijk 10 年之前
父節點
當前提交
e3a1ad7866
共有 7 個文件被更改,包括 155 次插入0 次删除
  1. 5 0
      control/Button.java
  2. 48 0
      control/GameControl.java
  3. 5 0
      control/JoyStick.java
  4. 9 0
      main/Main.java
  5. 45 0
      main/Window.java
  6. 13 0
      model/GameModel.java
  7. 30 0
      view/GameView.java

+ 5 - 0
control/Button.java

@@ -0,0 +1,5 @@
+package control;
+
+public class Button {
+
+}

+ 48 - 0
control/GameControl.java

@@ -0,0 +1,48 @@
+package control;
+
+import java.awt.event.KeyEvent;
+import java.awt.event.KeyListener;
+import java.awt.event.MouseEvent;
+import java.awt.event.MouseListener;
+import java.awt.event.WindowEvent;
+import java.awt.event.WindowFocusListener;
+
+import model.GameModel;
+import view.GameView;
+
+public class GameControl implements MouseListener, KeyListener, WindowFocusListener{
+	
+	GameModel model;
+	GameView view;
+	
+	public GameControl(GameModel model, GameView view)
+	{
+		this.model = model;
+		this.view = view;
+	}
+
+	public void keyPressed(KeyEvent e) {}
+
+	public void keyReleased(KeyEvent e) {
+		if(e.getKeyCode() == KeyEvent.VK_ESCAPE)
+		{
+			System.exit(0);
+		}
+	}
+
+	public void keyTyped(KeyEvent e) {}
+
+	public void mouseClicked(MouseEvent e) {}
+
+	public void mouseEntered(MouseEvent e) {}
+
+	public void mouseExited(MouseEvent e) {}
+
+	public void mousePressed(MouseEvent e) {}
+
+	public void mouseReleased(MouseEvent e) {}
+
+	public void windowGainedFocus(WindowEvent e) {}
+
+	public void windowLostFocus(WindowEvent e) {}
+}

+ 5 - 0
control/JoyStick.java

@@ -0,0 +1,5 @@
+package control;
+
+public class JoyStick {
+
+}

+ 9 - 0
main/Main.java

@@ -0,0 +1,9 @@
+package main;
+
+public class Main {
+
+	public static void main(String[] args) {
+		new Window();
+	}
+
+}

+ 45 - 0
main/Window.java

@@ -0,0 +1,45 @@
+package main;
+
+import java.awt.event.WindowAdapter;
+import java.awt.event.WindowEvent;
+
+import javax.swing.JFrame;
+
+import model.GameModel;
+import view.GameView;
+import control.GameControl;
+
+public class Window extends JFrame {
+	public Window()
+	{
+		//Create window
+		super("Arcade");
+		setSize(500,600);
+		
+		//Set window close listener
+		setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
+		addWindowListener(new WindowAdapter(){
+			public void windowClosing(WindowEvent e) {
+				System.exit(0);
+			}
+		});
+		
+		//Set window to fullscreen
+		setExtendedState(getExtendedState() | JFrame.MAXIMIZED_BOTH);
+		setUndecorated(true);
+		
+		//Create Instances
+		GameView view = new GameView();
+		GameModel model = new GameModel(view);
+		GameControl control = new GameControl(model, view);
+		setContentPane(view);
+		
+		addKeyListener(control);
+		addMouseListener(control);
+		addWindowFocusListener(control);
+		
+		//Display
+		pack();
+		setVisible(true);
+	}
+}

+ 13 - 0
model/GameModel.java

@@ -0,0 +1,13 @@
+package model;
+
+import view.GameView;
+
+public class GameModel {
+	
+	GameView view;
+	
+	public GameModel(GameView view)
+	{
+		this.view = view;
+	}
+}

+ 30 - 0
view/GameView.java

@@ -0,0 +1,30 @@
+package view;
+
+import java.awt.Graphics;
+import java.awt.Graphics2D;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+
+import javax.swing.JPanel;
+import javax.swing.Timer;
+
+public class GameView extends JPanel implements ActionListener{
+	
+	Timer t;
+	
+	public GameView()
+	{
+		t = new Timer(1000/30, this);
+		t.start();
+	}
+
+	public void actionPerformed(ActionEvent arg0) {
+		repaint();
+	}
+	
+	public void paintComponent(Graphics g)
+	{
+		super.paintComponent(g);
+		Graphics2D g2d = (Graphics2D) g;
+	}
+}