Loot = class() -- Free game by juaxix -- http://www.xixgames.com -- Copyright LGPL - 11/2011 function Loot:init(avoidy) if math.random(66)>33 then self.type = "life" self.life = math.random(1,45) else self.type = "powerup" local r = math.random(1,3) if r == 1 then self.acolor = color( 255, 253, 0, 255 ) elseif r == 2 then self.acolor = color(255, 0, 0, 255) elseif r == 3 then self.acolor = color(0, 0, 255, 255) end end self.position = vec2(WIDTH,math.max(math.abs(math.random(HEIGHT)-avoidy)),66) self.collected = false self.rise = 0 end function Loot:collect(point) if self.collected then return false end dtg = point:dist(self.position) if dtg < 50 and not self.collected then sound(SOUND_PICKUP, 195) self.collected = true return true end return false end function Loot:draw() self.position.x = self.position.x - 1.6 pushMatrix() translate(self.position.x, self.position.y + self.rise) if self.type == "powerup" then tint(self.acolor) sprite("Small World:Mote Sad") noTint() else sprite("Small World:Mote Happy") end popMatrix() if self.collected then self.rise = self.rise + 15 end end