-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathanimations.p8
234 lines (223 loc) · 6.53 KB
/
animations.p8
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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
animations = {
basic_attack = function(self)
local target = self.opponent
local x_offset = 0
local y_offset = 0
local animation_frame = 0
for i = 0, 20 do
if (i == 0) sfx(1)
if (i == 10) animation_frame = 0
-- display sprite in the middle top of the target for 4 frames
if (animation_frame <= 2) x_offset = ((target.width - 1) / 2) - 3.5; y_offset = 0
-- display sprite in the right middle of the target for 4 frames
if (animation_frame > 2 and animation_frame <= 4) x_offset = target.width - 7; y_offset = ((target.height - 1) / 2) - 3.5
-- display sprite in the middle bottom of the target for 4 frames
if (animation_frame > 4 and animation_frame <= 6) x_offset = ((target.width - 1) / 2) - 3.5; y_offset = target.height - 7
-- display sprite in the left middle of the target for 4 frames
if (animation_frame > 6 and animation_frame <= 8) x_offset = 0; y_offset = ((target.height - 1) / 2) - 3.5
-- display sprite in the middle of the target for 4 frames
if (animation_frame > 8) x_offset = ((target.width - 1) / 2) - 3.5; y_offset = ((target.height - 1) / 2) - 3.5
animation_frame = animation_frame + 1
spr(19, target.x + x_offset, target.y + y_offset)
yield()
end
end,
screen_shake = function()
x = 20
travel = 1
for i = 0, 15 do
-- every 3 frames, alternate direction and reduce
-- shake by 20%
if (i % 3 == 0) x = x * -1 * travel; travel -= 0.2
camera(x, 0)
yield()
end
-- reset the camera back
camera(0, 0)
end,
bleed = function(self)
local target = self.opponent
local starting_positions = {
{target.x + 7, target.y + 10},
{target.x - 3, target.y + 13},
{target.x + 2, target.y + 17},
}
for i = 1, 3 do
local x = starting_positions[i][1]
local y = starting_positions[i][2]
for i = 1, 15 do
spr(16, x, y)
y += 1
yield()
end
end
end,
poison = function(self)
local target = self.opponent
local starting_positions = {
{target.x + 7, target.y + 10},
{target.x - 3, target.y + 13},
{target.x + 2, target.y + 17},
}
for i = 1, 3 do
local x = starting_positions[i][1]
local y = starting_positions[i][2]
for i = 1, 15 do
pal(8, 1)
spr(16, x, y)
pal()
y += 1
yield()
end
end
end,
rot = function(self)
local target = self.opponent
local starting_positions = {
{target.x + 7, target.y + 10},
{target.x - 3, target.y + 13},
{target.x + 2, target.y + 17},
}
for i = 1, 3 do
local x = starting_positions[i][1]
local y = starting_positions[i][2]
for i = 1, 15 do
pal(8, 5)
spr(16, x, y)
pal()
y += 1
yield()
end
end
end,
heal = function(self)
local target = self.candy
local origin_x = target.x + 15
local origin_y = target.y + 15
local radius = 20
local circles = {
{angle = 1, color = 7},
{angle = .96, color = 6},
{angle = .92, color = 14},
{angle = .88, color = 10},
}
local rotations = 0
local max_rotations = 2
sfx(35)
while (rotations < (max_rotations * #circles)) do
local rotated = false
for i = 1, #circles do
circles[i].angle -= 0.04
if (circles[i].angle < 0) then
circles[i].angle = 1
rotated = true
end
local x = origin_x + radius * cos(circles[i].angle)
local y = origin_y + radius * sin(circles[i].angle)
circfill(x, y, 2, circles[i].color)
end
if (rotated) then rotations += 1 end
yield()
end
end,
slice = function(self)
local target = self.opponent
local x = target.x
local y = target.y
local sword_x1 = x + 15
local sword_y1 = y + 10
local sword_x2 = sword_x1 + 5
local sword_y2 = sword_y1 - 10
local sprite_x = sword_x1 - 12
local sprite_y = sword_y1 - 12
for i = 1, 25 do
if (i == 6 or i == 16) then
sfx(36)
end
if (i <= 5) then
line(sword_x1, sword_y1, sword_x2, sword_y2, 7)
elseif (i > 5 and i <= 7) then
spr(196, sprite_x, sprite_y, 4, 4)
elseif (i > 7 and i <= 9) then
spr(200, sprite_x, sprite_y, 4, 4)
elseif (i > 9 and i <= 15) then
line(sword_x1, sword_y1, sword_x2, sword_y2, 7)
elseif (i > 15 and i <= 17) then
spr(196, sprite_x, sprite_y, 4, 4)
elseif (i > 17 and i <= 19) then
spr(200, sprite_x, sprite_y, 4, 4)
elseif (i > 19 and i <= 25) then
line(sword_x1, sword_y1, sword_x2, sword_y2, 7)
end
yield()
end
end,
debuff = function(self)
local target = self.opponent
local start_x = target.x - 5
local start_y = target.y - 5
for i = 1, 3 do
local x = start_x
local y = start_y
sfx(33)
for i = 1, 15 do
spr(49, x, y)
y += 1
yield()
end
end
end,
buff = function(self)
local target = self.candy
local start_x = target.x - 5
local start_y = target.y - 5 + 15
for i = 1, 3 do
local x = start_x
local y = start_y
sfx(34)
for i = 1, 15 do
pal(13, 12)
spr(49, x, y, 1, 1, false, true)
pal()
y -= 1
yield()
end
end
end,
explosion = function(self)
local target = self.opponent
local circle_x = target.x + 15
local circle_y = target.y + 15
local radius = 12
sfx(37)
for i = 1, 15 do
if (i <= 2) then
-- black circle
circfill(circle_x, circle_y, radius, 0)
elseif (i > 2 and i <= 4) then
-- white circle
circfill(circle_x, circle_y, radius, 7)
elseif (i > 4 and i <= 8) then
-- blast
spr(192, circle_x - radius, circle_y - radius, 4, 4)
elseif (i > 9 and i <= 13) then
-- smoke
circfill(target.x + 5, target.y + 5, 5, 5)
circfill(target.x + 15, target.y + 7, 5, 5)
circfill(target.x + 20, target.y + 15, 5, 5)
circfill(target.x + 7, target.y + 15, 5, 5)
circfill(target.x + 20, target.y + 25, 5, 5)
-- fire
circfill(target.x + 6, target.y + 6, 5, 9)
circfill(target.x + 17, target.y + 5, 5, 9)
circfill(target.x + 15, target.y + 20, 5, 9)
elseif (i > 13 and i <= 15) then
-- smoke
circfill(target.x + 7, target.y + 7, 5, 5)
circfill(target.x + 12, target.y + 10, 5, 5)
circfill(target.x + 20, target.y + 30, 5, 5)
end
yield()
end
end
}