First Commit
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
package control;
|
||||
|
||||
public class Button {
|
||||
|
||||
}
|
||||
@@ -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) {}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package control;
|
||||
|
||||
public class JoyStick {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package main;
|
||||
|
||||
public class Main {
|
||||
|
||||
public static void main(String[] args) {
|
||||
new Window();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package model;
|
||||
|
||||
import view.GameView;
|
||||
|
||||
public class GameModel {
|
||||
|
||||
GameView view;
|
||||
|
||||
public GameModel(GameView view)
|
||||
{
|
||||
this.view = view;
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user