-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathPowerTeleporter.java
45 lines (39 loc) · 1.03 KB
/
PowerTeleporter.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
39
40
41
42
43
44
45
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
import java.util.*;
/**
* Write a description of class PowerTeleporter here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class PowerTeleporter extends PowerObj
{
public void update() {
super.update();
}
public boolean solidAgainst(GameObj obj) {
if (obj instanceof Pushy || obj instanceof Apple || obj instanceof Key || obj instanceof LaserRay) {
return false;
}
return true;
}
public void onPowerUpdate() {
if (getPower()) {
teleport();
setImage("233.bmp");
} else {
setImage("232.bmp");
}
}
public int getRenderOrder() {
return GameObj.R_Bck;
}
public void teleport() {
for (Object obj : getWorld().getObjects(Pushy.class)) {
((Pushy)obj).setLocation(getX(), getY());
}
}
public int getId() {
return 170;
}
}