chroma_solstice/generic_moveable.lua

44 lines
1.1 KiB
Lua
Raw Normal View History

2015-03-25 01:38:53 -04:00
require "entity"
GenericMoveable = class("GenericMoveable", Entity)
function GenericMoveable:initialize(x, y, color, sprite, name, cellShape, adhesion)
2015-03-25 01:38:53 -04:00
Entity.initialize(self, {
name = name,
2015-03-25 01:38:53 -04:00
x = x,
y = y,
color = color,
collision = "moveable",
sprite = sprite,
cellShape = cellShape,
adhesion = adhesion
2015-03-25 01:38:53 -04:00
})
end
function GenericMoveable:update()
end
-- Adhesion drives the look as well as the mechanic: gluey blocks get spiked
-- teeth on their true contour, sticky blocks get the wobbling goopy shader, and
-- plain moveables draw normally.
function GenericMoveable:draw(channel)
local sprite = self.sprites[channel]
if not sprite then return end
love.graphics.setColor(gColor[channel]:set())
local p = self:getDrawPos()
local x = p.x + self.drawOffset.x * drawScale
local y = p.y + self.drawOffset.y * drawScale
if self.adhesion == "gluey" and drawGlueySprite then
drawGlueySprite(sprite, self:getCellShape(), x, y, drawScale)
elseif self.adhesion == "sticky" and drawGoopySprite then
drawGoopySprite(sprite, x, y, drawScale)
else
love.graphics.draw(sprite, x, y, 0, drawScale, drawScale)
end
end
2015-03-25 01:38:53 -04:00
function GenericMoveable:tick()
end