-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMark.java
36 lines (32 loc) · 1.01 KB
/
Mark.java
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
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Write a description of class Mark here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Mark extends GameObj
{
public boolean solidAgainst(GameObj obj) {
return !(obj instanceof Pushy || obj instanceof LaserRay);
}
public boolean solidAgainstPost(GameObj obj) {
if (obj instanceof Pushy) {
if (!obj.extraData.getBoolean("marked")) {
Sound.drop.play();
obj.extraData.setBoolean("marked", true);
}
}
return false;
}
public void onObjEvent(GameObj obj, String event) {
if (event.equals("pushyMove")) {
if (getWorld().getObjectsAt(obj.getX(), obj.getY(), null).size()==1 && ((Pushy)obj).extraData.getBoolean("marked")) {
new Mark().addToWorld(getWorld(), obj.getX(), obj.getY());
}
}
}
public int getId() {
return 11;
}
}