forked from kanaad222/Jump-Dude
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJumpDude.java
More file actions
83 lines (59 loc) · 1.6 KB
/
JumpDude.java
File metadata and controls
83 lines (59 loc) · 1.6 KB
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
import java.awt.*;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.image.BufferedImage;
import java.io.File;
import javax.imageio.ImageIO;
import javax.swing.JFrame;
import javax.swing.JPanel;
public class JumpDude extends JPanel implements Runnable, KeyListener{
// Images
public static BufferedImage menu;
public static int gameState = 0;
public JumpDude() {
setPreferredSize(new Dimension(1280, 720));
setBackground(new Color(255, 255, 255));
try {
menu = ImageIO.read(new File("menu.png"));
}
catch(Exception e) {
System.out.println("IMAGE NOT FOUND");
}
addKeyListener(this);
this.setFocusable(true);
}
public static void main(String[] args) {
JFrame gameWindow = new JFrame("Game Name");
JumpDude gamePanel = new JumpDude();
gameWindow.add(gamePanel);
gameWindow.pack();
gameWindow.setVisible(true);
}
public void paintComponent(Graphics g) {
super.paintComponent(g);
if(gameState == 0) {
g.drawImage(menu, 0, 0, null);
}
}
@Override
public void keyTyped(KeyEvent e) {
// TODO Auto-generated method stub
}
@Override
public void keyPressed(KeyEvent e) {
if(gameState == 0) {
if(e.getKeyChar() == ' ') {
gameState = 1;
}
}
}
@Override
public void keyReleased(KeyEvent e) {
// TODO Auto-generated method stub
}
@Override
public void run() {
// TODO Auto-generated method stub
}
}
// https://medium.com/@brazmogu/physics-for-game-dev-a-platformer-physics-cheatsheet-f34b09064558