-
Notifications
You must be signed in to change notification settings - Fork 0
/
bullet.lua
43 lines (41 loc) · 1.3 KB
/
bullet.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
local Bullet = {
new = function(self, x_pos, y_pos)
local table =
{
x = x_pos,
y = y_pos,
w = Map.tilesize/2,
h = Map.tilesize/8,
v = 500,
movement = 0,
update = function (self, dt)
-- Scale
self.w = Map.tilesize/2
self.h = Map.tilesize/8
-- Movement
self.movement = self.movement + self.v * dt
if self.movement >= Map.tilesize then
Map:MoveEntity(self, self.movement, 0)
self.movement = 0
end
end,
draw = function (self)
love.graphics.rectangle("fill", self.x, self.y, self.w, self.h)
end,
onScreenBounds = function (self)
Map:DeleteEntity(self)
end,
resolveCollision = function (self, entity)
if entity:__tostring() ~= "player" and entity:__tostring() ~= "bullet" then
print(entity:__tostring())
Map:DeleteEntity(self)
end
end,
__tostring = function ()
return "bullet"
end,
}
return table
end,
}
return Bullet