-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstarPowerup.java
More file actions
62 lines (48 loc) · 1.36 KB
/
starPowerup.java
File metadata and controls
62 lines (48 loc) · 1.36 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
package SaueSpillet;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.Rectangle;
import javax.swing.ImageIcon;
public class starPowerup extends GameObject {
private int width = 50;
private int height = 48;
public static Image starPic;
private boolean flimmer = false;
private long start, end;
private int fuse = 420;
public starPowerup(float x, float y, ID id, Handler handler) {
super(x, y, id, handler);
loadpic();
handler.addObject(new Trail((int) x -35, (int) y-30, ID.InitBoom, handler, 0.025f));
start = System.currentTimeMillis();
}
public Rectangle getBounds() {
return new Rectangle((int) x, (int) y, width, height);
}
public void tick() {
x = Game.clamp(x, 0, Game.WIDTH-300);
y = Game.clamp(y, 200, Game.HEIGHT - 132);
fuse--;
if (fuse < 50 && fuse %10 == 0) {
flimmer = true;
start = System.currentTimeMillis();
}
if (fuse <=0)
handler.removeObject(this);
}
public void loadpic() {
starPic = new ImageIcon(
"C:\\Users\\Sjur\\tdt4100-2018-master\\git\\tdt4100-2018\\minegenkode\\GamepackRes\\star.png")
.getImage();
}
public void render(Graphics g) {
end = System.currentTimeMillis();
if (!((end - start) / 10 < 5)) {
if ((end - start) / 10 > 10 && flimmer) {
start = System.currentTimeMillis();
flimmer = false;
}
g.drawImage(starPic, (int) x, (int) y, null);
}
}
}