-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMobbyHitbox.java
More file actions
50 lines (46 loc) · 1.29 KB
/
MobbyHitbox.java
File metadata and controls
50 lines (46 loc) · 1.29 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
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
import java.util.List;
/**
* Write a description of class MobsterHitbox here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class MobbyHitbox extends SmoothMover
{
GreenfootImage body;
int offsetX;
int offsetY;
Actor host;
public MobbyHitbox(Actor a, int w, int h, int dx, int dy, boolean visible)
{
host = a;
offsetX = dx;
offsetY = dy;
body = new GreenfootImage(w, h);
if (visible) {
body.setColor(Color.RED);
body.setTransparency(100); //0-255
body.fill();
}
setImage(body);
}
public void act()
{
if (host.getWorld() != null) {
setLocation(host.getX() + offsetX, host.getY() + offsetY);
}
else {
getWorld().removeObject(this);
}
}
public List getBulletIntersections() {
return getIntersectingObjects(Bullet.class);
}
public List getPlateIntersections() {
return getIntersectingObjects(Plate.class);
}
public List getBoxIntersections() {
return getIntersectingObjects(PileOfBoxes.class);
}
}