-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshot_object.lua
48 lines (35 loc) · 930 Bytes
/
shot_object.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
40
41
42
43
44
45
46
47
48
local GameObject = require("game_object")
local ShotObject = GameObject:extend()
local inertTime = 0.1 -- won't damage again for this long
-- Abstract Shot class
function ShotObject:new(x, y, quadName, scale)
ShotObject.super.new(self, x, y, quadName, scale)
self.initX = x or 0
self.initY = y or 0
self.height = 5
self.width = 2
self.timeLastDamage = 0
self.inert = false
self.disable = false
end
function ShotObject:getInert()
return self.inert
end
function ShotObject:getDisable()
return self.disable
end
function ShotObject:getRemoveOnImpact()
return true
end
function ShotObject:hit()
self.inert = true
self.timeLastDamage = self.time
end
function ShotObject:update(dt, game_x, game_y)
ShotObject.super.update(self, dt)
if self.time > (self.timeLastDamage + inertTime) then
self.inert = false
end
return
end
return ShotObject