-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathPowerSwitch.java
42 lines (36 loc) · 910 Bytes
/
PowerSwitch.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
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Write a description of class PowerSwitch here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class PowerSwitch extends PowerObj
{
public boolean solidAgainst(GameObj obj) {
if (obj instanceof Pushy) {
Sound.klick.play();
setProvidePower(!isProvidingPower());
}
return true;
}
public void onPowerUpdate() {
if (isProvidingPower()) {
setImage("133.png");
} else {
setImage("132.png");
}
}
public boolean oneDirectionalProvider() {
return false;
}
public int getRenderOrder() {
return GameObj.R_Wire;
}
public int getId() {
return 128;
}
public boolean canProvidePower() {
return true;
}
}