-
Notifications
You must be signed in to change notification settings - Fork 3
/
GRASS.java
53 lines (46 loc) · 1.13 KB
/
GRASS.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
46
47
48
49
50
51
52
53
import greenfoot.*;
/**
* Write a description of class GRASS here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class GRASS extends BLOCK
{
// instance variables - replace the example below with your own
private GreenfootImage icon;
/**
* Constructor for objects of class GRASS
*/
public GRASS(){
icon = new GreenfootImage("blocks/grass/grass_small_1.png");
}
public void use(TOOL tool){
if(tool.get_kind() == TOOLKIND.HOE){
MAINWORLD world = (MAINWORLD) getWorld();
world.delete_block(this);
FIELD field = new FIELD();
world.add_entity(field);
} else {
super.use(tool);
}
}
public GreenfootImage get_icon(){
return icon;
}
public GreenfootImage get_image(){
return icon;
}
public boolean is_stackable(){
return true;
}
public String get_name(){
return "Grass";
}
public int will_drop_item(TOOL tool){
return -1;
}
public boolean is_placeable(){
return false;
}
}