-
Notifications
You must be signed in to change notification settings - Fork 0
/
MoviTest
64 lines (47 loc) · 1.69 KB
/
MoviTest
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
package MoveTest;
import java.awt.DisplayMode;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
import java.awt.event.KeyEvent;
import java.util.LinkedList;
import java.util.List;
import javax.swing.JFrame;
public class MoveTest {
public static void main(String[] args) {
List<Bullet> bullets = new LinkedList<Bullet>();
Player player = new Player (300, 300,800, 600, bullets);
Background bg = new Background(0);
Frame f= new Frame(player, bg, bullets);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setSize(800, 600);
f.setUndecorated(true);
f.setVisible(true);
f.setResizable(false);
f.setLocationRelativeTo(null);
// DisplayMode displayMode = new DisplayMode (800, 600, 16, 75);
// GraphicsEnvironment environment = GraphicsEnvironment.getLocalGraphicsEnvironment();
// GraphicsDevice device = environment.getDefaultScreenDevice();
//
// device.setFullScreenWindow(f);
// device.setDisplayMode(displayMode);
f.makeStrat();
long lastFrame = System.currentTimeMillis();
while (true) {
if(Keyboard.isKeyDown(KeyEvent.VK_ESCAPE))System.exit(0);
long thisFrame = System.currentTimeMillis();
float timeSinceLastFrame = ((float)(thisFrame-lastFrame))/1000f;
lastFrame=thisFrame;
player.update(timeSinceLastFrame);
bg.update(timeSinceLastFrame);
f.repaintScreen();
for(int i = 0; i<bullets.size(); i++){
bullets.get(i).update(timeSinceLastFrame);
}
try {
Thread.sleep(15);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}