-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathBonus.java
More file actions
49 lines (39 loc) · 818 Bytes
/
Bonus.java
File metadata and controls
49 lines (39 loc) · 818 Bytes
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
import java.awt.*;
import javax.swing.*;
public class Bonus extends GameEntity {
int id;
Space space;
double y_vel = 5;
public Bonus(int x,int y,int id) {
super(x,y);
this.id = id;
setImage();
}
public void update(Space space) {
if (y >= space.HEIGHT){
space.bonuses.remove(this);
return;
}
y += y_vel;
if (img == null) space.bonuses.remove(this);
bounds.setLocation(getX(),getY());
}
public String getImg() {
switch(id) {
case 0:
image = "images/health.png";
break;
case 1:
image = "images/weapon_upgrade.png";
break;
case 2:
image = "images/shield.png";
break;
default: image = "";
}
return image;
}
public void draw(Graphics2D g) {
g.drawImage(img,getX(),getY(),null);
}
}