-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.java
59 lines (50 loc) · 1.25 KB
/
main.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/**
* @(#)realRun.java
*
*
* @author
* @version 1.00 2018/5/15
*/
import java.awt.*;
import java.util.ArrayList;
import java.awt.event.*;
import javax.swing.*;
import java.awt.geom.*;
import java.awt.image.*;
import java.io.*;
import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
public class main extends JFrame implements ActionListener, KeyListener {
Timer myTimer;
GamePanel game;
int screenX = 1900;
int screenY = 1000;
public main() {
super("Super Mario Bros");
setSize(screenX, screenY);
myTimer = new Timer (10, this);
myTimer.start();
game = new GamePanel();
add(game);
addKeyListener(this);
setResizable(false);
setVisible(true);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public void actionPerformed(ActionEvent e) {
if(game != null){
game.refresh();
game.repaint();
}
}
public void keyTyped(KeyEvent e) {}
public void keyPressed(KeyEvent e) {
game.setKey(e.getKeyCode(), true);
}
public void keyReleased(KeyEvent e) {
game.setKey(e.getKeyCode(), false);
}
public static void main(String[]args){
new main();
}
}