32 lines
650 B
Lua
32 lines
650 B
Lua
|
local physics = require("physics")
|
||
|
|
||
|
local starfish = {
|
||
|
}
|
||
|
|
||
|
function starfish.new(x, y)
|
||
|
return {
|
||
|
x = x,
|
||
|
y = y,
|
||
|
width = 12,
|
||
|
height = 12,
|
||
|
update = starfish.update,
|
||
|
draw = starfish.draw,
|
||
|
sprite = love.graphics.newImage("sprites/starfish.png"),
|
||
|
value = 1,
|
||
|
}
|
||
|
end
|
||
|
|
||
|
function starfish.update(self, player, level, dt)
|
||
|
if physics.boxCollide(self, player) then
|
||
|
player.score = player.score + self.value
|
||
|
self.dead = true
|
||
|
end
|
||
|
end
|
||
|
|
||
|
function starfish.draw(self)
|
||
|
love.graphics.setColor(1, 1, 1)
|
||
|
love.graphics.draw(self.sprite, self.x, self.y);
|
||
|
end
|
||
|
|
||
|
return starfish
|