-
Notifications
You must be signed in to change notification settings - Fork 0
/
World
39 lines (30 loc) · 773 Bytes
/
World
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
import javax.swing.JFrame;
import javax.swing.Timer;
public class World{
private Frame frame;
private Timer timer;
private NPanel panel;
public World(){
panel = new NPanel(this);
frame = new JFrame("Catch");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(400, 400);
frame.setResizable(false);
frame.getContentPane().add(panel);
timer = new Timer(1000 / 60, new ActionListener(){
public void actionPerformed(ActionEvent e){
updateWorld();
}});
}
public void start(){
frame.setVisible(true);
timer.start();
}
updateWorld(){
//update character & falling blocks here
panel.repaint();
}
public static void main(String[] args){
new World().start();
}
}