-
Notifications
You must be signed in to change notification settings - Fork 0
/
items.lua
49 lines (38 loc) · 791 Bytes
/
items.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
49
--
-- items.lua
-- a list of objects that the Player can pick up or use
--
Item = {}
Item.__index = Item
function Item.new(type, x, y)
local self = {}
setmetatable(self, Item)
local i = items[type]
-- position
self.x = x
self.y = y
self.width = i.width
self.height = i.height
self.offset = i.offset
self.rect = HC.rectangle(x+i.offset.x,y+i.offset.y,i.width,i.height)
-- descriptors
self.type = 'item'
self.name = i.name
self.img = i.image
self.description = i.description
self.health = i.health
self.action = i.action
self.pickedUp = false
self.active = true
return self
end
function Item:update()
-- do nothing
end
function Item:draw()
love.graphics.draw(self.img, self.x, self.y)
end
function Item:kill()
self.active = false
HC.remove(self.rect)
end