view sprite.lua @ 48:eeb43b94f625 default tip

merge
author Makdaam
date Sun, 16 Dec 2012 19:50:44 +0100
parents 98ab870293bc
children
line wrap: on
line source

local Sprite = {}

local function newSprite(x, y, image, animation)
    local sprite = setmetatable({
        x = x,
        y = y,
        image = image,
        animation = animation,
    }, { __index = Sprite })
    return sprite
end

function Sprite:draw()
    self.animation:draw(self.image, math.floor(self.x), math.floor(self.y))
end

function Sprite:update(dt)
    self.animation:update(dt)
end


local Shadow = {}

function newShadow(image, sprite)
    return setmetatable({
        image = image,
        sprite = sprite,
    }, { __index = Shadow })
end

function Shadow:draw()
    love.graphics.draw(self.image, math.floor(self.sprite.x), math.floor(self.sprite.y + 8))
end

function Shadow:update(dt)
end


local sprite = {
    newSprite = newSprite,
    Sprite = Sprite,
    newShadow = newShadow,
}

return sprite