-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathApple.java
38 lines (32 loc) · 844 Bytes
/
Apple.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
37
38
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Write a description of class Apple here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Apple extends GameObj
{
public boolean solidAgainst(GameObj obj) {
return !(obj instanceof Pushy || obj instanceof LaserRay);
}
public boolean solidAgainstPost(GameObj obj) {
if (obj instanceof Pushy) {
remove();
Sound.drop.play();
}
return false;
}
public boolean pushable(GameObj obj) {
return (obj instanceof PowerPistonHead);
}
public void created() {
getWorld().openGoal();
}
public void onRemove() {
getWorld().closeGoal();
}
public int getId() {
return 21;
}
}