-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHealthPickup.java
More file actions
85 lines (61 loc) · 1.98 KB
/
HealthPickup.java
File metadata and controls
85 lines (61 loc) · 1.98 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
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.geom.Ellipse2D;
import java.awt.geom.Rectangle2D;
import java.awt.Image;
public class HealthPickup extends PowerUp{
public HealthPickup (GamePanel p, Car bat, int x, int y) {
panel = p;
backgroundColour = panel.getBackground ();
width = 25;
height = 25;
this.x = x;
this.y = y;
this.bat = bat;
soundManager = SoundManager.getInstance();
alienImage = ImageManager.loadImage ("images/health.png");
}
// public void draw (Graphics2D imageContext) {
// Graphics g = panel.getGraphics ();
// Graphics2D g2 = (Graphics2D) g;
// imageContext.drawImage(alienImage, x, y, width, height, null);
// g.dispose();
// }
// public void erase() {
// Graphics g = panel.getGraphics();
// Graphics2D g2 = (Graphics2D) g;
// g2.setColor (backgroundColour);
// g2.fill (new Ellipse2D.Double (x, y, width, height));
// g2.setColor(backgroundColour);
// g2.draw(new Ellipse2D.Double (x, y, width, height));
// g.dispose();
// }
public void move() {
boolean CarCollision = collidesWithCar();
if (!panel.isVisible ()) return;
if (CarCollision) {
soundManager.playClip("pickup", false);
System.out.println("Health Picked Up");
if(panel.getLifeTotal()>= 5){
panel.addPoints(5);
}else{
panel.addLife(2);
}
}
}
// public Rectangle2D.Double getBoundingRectangle() {
// return new Rectangle2D.Double (x, y, width, height);
// }
// public boolean collidesWithCar() {
// Rectangle2D.Double myRect = getBoundingRectangle();
// Rectangle2D.Double batRect = bat.getBoundingRectangle();
// return myRect.intersects(batRect);
// }
// public int getX(){
// return this.x;
// }
// public int getY(){
// return this.y;
// }
}