-
Notifications
You must be signed in to change notification settings - Fork 0
/
frame
59 lines (42 loc) · 1.15 KB
/
frame
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
package MoveTest;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.image.BufferStrategy;
import java.util.List;
import javax.swing.JFrame;
import javax.swing.JLabel;
public class Frame extends JFrame {
final Player player;
final Background bg;
private BufferStrategy strat;
private List<Bullet> bullets;
public Frame(Player player, Background bg, List<Bullet> bullets) {
super ("HHUTest");
addKeyListener (new Keyboard());
this.player = player;
this.bg = bg;
this.bullets = bullets;
}
public void makeStrat(){
createBufferStrategy(2);
strat = getBufferStrategy();
}
public void repaintScreen (){
Graphics g = strat.getDrawGraphics();
draw(g);
g.dispose();
strat.show();
}
private void draw(Graphics g){
g.setColor(Color.BLUE);
g.drawImage(bg.getLook(), bg.getX(), 0, null);
g.drawImage(bg.getLook(), bg.getX()+bg.getLook().getWidth(), 0, null);
g.drawImage(player.getLook(), player.getBounding().x, player.getBounding().y, null);
for(int i = 0; i<bullets.size(); i++){
Bullet b = bullets.get(i);
g.drawImage(Bullet.getLook(), b.getBounding().x, b.getBounding().y, null);
}
}
}