-
Notifications
You must be signed in to change notification settings - Fork 6
/
Buckethead.java
167 lines (147 loc) · 5.31 KB
/
Buckethead.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Write a description of class BasicZombie here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Buckethead extends Zombie
{
/**
* Act - do whatever the BasicZombie wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public boolean bucket = true;
public GreenfootImage[] idle;
public GreenfootImage[] walk;
public GreenfootImage[] armless;
public GreenfootImage[] eat;
public GreenfootImage[] armlesseat;
public GreenfootImage[] buckethead;
public GreenfootImage[] bucketheadwalk;
public GreenfootImage[] bucketheadwalkd;
public GreenfootImage[] bucketheadwalkdd;
public GreenfootImage[] bucketheadeat;
public GreenfootImage[] bucketheadeatd;
public GreenfootImage[] bucketheadeatdd;
public Buckethead() {
idle = importSprites("zombieidle", 4);
walk = importSprites("zombiewalk", 7);
eat = importSprites("zombieeating", 7);
armlesseat = importSprites("armlesszombieeating", 7);
armless = importSprites("armlesszombie", 7);
//Conehead
bucketheadwalk = importSprites("bucketheadwalk", 7);
bucketheadwalkd = importSprites("bucketheadwalkd", 7);
bucketheadwalkdd = importSprites("bucketheadwalkdd", 7);
bucketheadeat = importSprites("bucketheadeat", 7);
bucketheadeatd = importSprites("bucketheadeatd", 7);
bucketheadeatdd = importSprites("bucketheadeatdd", 7);
walkSpeed = Random.Double(11, 14);
maxHp = 700;
hp = maxHp;
}
public void update() {
if (hp > 500) {
if (!isEating()) {
animate(bucketheadwalk, 350, true);
move(-walkSpeed);
} else {
animate(bucketheadeat, 200, true);
playEating();
}
} else if (hp > 300) {
if (!isEating()) {
animate(bucketheadwalkd, 350, true);
move(-walkSpeed);
} else {
animate(bucketheadeatd, 200, true);
playEating();
}
} else if (hp > 100) {
if (!isEating()) {
animate(bucketheadwalkdd, 350, true);
move(-walkSpeed);
} else {
animate(bucketheadeatdd, 200, true);
playEating();
}
} else {
if (bucket) {
bucket = false;
MyWorld.addObject(new Bucket(), getX(), getY()-25);
}
if (hp > 50) {
if (!isEating()) {
animate(walk, 350, true);
move(-walkSpeed);
} else {
animate(eat, 200, true);
playEating();
}
} else {
if (!fallen) {
fallen = true;
AudioPlayer.play(80, "limbs_pop.mp3");
MyWorld.addObject(new Arm(), getX()+8, getY()+20);
}
if (!isEating()) {
animate(armless, 350, true);
move(-walkSpeed);
} else {
animate(armlesseat, 200, true);
playEating();
}
}
}
}
public void hit(int dmg) {
if (bucket) {
AudioPlayer.play(70, "shieldhit.mp3", "shieldhit2.mp3");
} else {
AudioPlayer.play(70, "splat.mp3", "splat2.mp3", "splat3.mp3");
}
if (isLiving()) {
if (hp > 500) {
if (!isEating()) {
hitFlash(bucketheadwalk, "bucketheadwalk");
} else {
hitFlash(bucketheadeat, "bucketheadeat");
}
} else if (hp > 300) {
if (!isEating()) {
hitFlash(bucketheadwalkd, "bucketheadwalkd");
} else {
hitFlash(bucketheadeatd, "bucketheadeatd");
}
} else if (hp > 100) {
if (!isEating()) {
hitFlash(bucketheadwalkdd, "bucketheadwalkdd");
} else {
hitFlash(bucketheadeatdd, "bucketheadeatdd");
}
} else {
if (!fallen) {
if (!eating) {
hitFlash(walk, "zombiewalk");
} else {
hitFlash(eat, "zombieeating");
}
} else {
if (!eating) {
hitFlash(armless, "armlesszombie");
} else {
hitFlash(armlesseat, "armlesszombieeating");
}
}
}
hp -= dmg;
} else if (!finalDeath) {
if (!eating) {
hitFlash(headless, "zombieheadless");
} else {
hitFlash(headlesseating, "headlesszombieeating");
}
}
}
}