blob: aaadf7b2c99754feed58881cc754d338a88216e5 (
plain)
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
|
local physics = require "logic.physics"
local Loot = {}
Loot.__index = Loot
function Loot:new(name, x, y)
local obj = {
objectType = "loot",
x = x or nil,
y = y or nil,
type = name,
r = config.lootSize
}
setmetatable(obj, Loot)
G.BodyLifeCycleManager:create(obj, config.lootSize, "static", true)
return obj
end
function Loot:onContact(other)
local loots = G.currentRoom.objects.loots
if other.objectType == "player" then
local pickedLoot = table.remove(loots, utils.indexof(loots, self))
table.insert(G.player.hearts, pickedLoot.type)
G.BodyLifeCycleManager:destroy(self.physicsBody)
end
end
function Loot:update(dt)
-- nothing yet
end
return Loot
|