-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathShitBomb.java
More file actions
86 lines (71 loc) · 2.09 KB
/
ShitBomb.java
File metadata and controls
86 lines (71 loc) · 2.09 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
84
85
86
package SaueSpillet;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.Rectangle;
import java.util.ArrayList;
import java.util.Arrays;
import javax.swing.ImageIcon;
public class ShitBomb extends GameObject {
private int width = 300;
private int height = 300;
private Image shitPic;
private int fuse;
public static ArrayList<ID> Entitys = new ArrayList<ID>(
Arrays.asList(ID.Player, ID.AdvancedFarmer, ID.BasicFarmer, ID.Star, ID.Boss, ID.BossProjectile, ID.StonesPickup, ID.Nuke));
public ShitBomb(float x, float y, ID id, Handler handler, int fuse) {
super(x, y, id, handler);
this.fuse = fuse;
loadpic();
Game.clamp(x, 0, Game.WIDTH);
Game.clamp(y, 0, Game.HEIGHT);
}
public Rectangle getBounds() {
return new Rectangle((int) x - 130, (int) y - 120, width, height);
}
public void loadpic() {
shitPic = new ImageIcon(
"C:\\Users\\Sjur\\tdt4100-2018-master\\git\\tdt4100-2018\\minegenkode\\GamepackRes\\shit.png")
.getImage();
}
public void tick() {
fuse--;
if (fuse <= 0) {
collisionExp();
handler.addObject(new Trail((int) x - 170, (int) y - 100, ID.ShitBoom, handler, 0.028));
handler.object.remove(this);
}
}
private void collisionExp() {
for (int i = 0; handler.object.size() > i; i++) {
GameObject obj = handler.object.get(i);
if (Entitys.contains(obj.getId())) {
if (getBounds() != null && obj.getBounds() != null) {
if (getBounds().intersects(obj.getBounds())) {
Hud.score += 5;
if (obj.getId() == ID.Player) {
Hud.health -= 3;
} else if (obj.getId() == ID.Boss) {
obj.hit = 1;
}
else if (obj.getId() == ID.Star) {
handler.removeObject(obj);
i--;
} else if (obj.getId() == ID.AdvancedFarmer || obj.getId() == ID.BasicFarmer) {
handler.removeObject(obj);
i--;
} else {
handler.removeObject(obj);
i--;
}
}
}
}
}
}
public void render(Graphics g) {
g.setColor(Color.red);
//g.drawRect((int) x - 130, (int) y - 120, width, height);
g.drawImage(shitPic, (int) x, (int) y, null);
}
}