-
Notifications
You must be signed in to change notification settings - Fork 0
/
fireball.lua
39 lines (32 loc) · 888 Bytes
/
fireball.lua
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
local rect = require "rect"
local sliding = require "sliding"
local fireball = {}
setmetatable(fireball,fireball)
function fireball:__index(key)
return rawget(fireball,key)
end
function fireball:__call(target,x,y,width,height,vel,c1)
local nt = {target = target, hitb = rect(x,y,width,height), vel = vel, c1 = c1}
setmetatable(nt,fireball)
return nt
end
function fireball:update()
if self.hitb then
self.hitb:setX(self.hitb.x + self.vel/60)
for k,v in ipairs(self.target.state.hurtboxes) do
if self.hitb and self.hitb:collide(v) then
for k,v in ipairs(entities) do
if v == self then
table.remove(entities,k)
return
end
end
end
end
end
end
function fireball:draw()
love.graphics.setColor(0,255,255)
if self.hitb then love.graphics.rectangle("line",self.hitb.x,self.hitb.y,self.hitb.width,self.hitb.height) end
end
return fireball