view sprite.lua @ 0:716ff40413d2

initial commit
author Radomir Dopieralski <sheep-devel@sheep.art.pl>
date Sat, 15 Dec 2012 10:23:11 +0100
parents
children 0c46edeabad6
line wrap: on
line source

local Sprite = {}
local Sprite_mt = { __index = Sprite }

local function newSprite(x, y, image, animation)
    local sprite = setmetatable({
        x = x,
        y = y,
        image = image,
        animation = animation,
    }, Sprite_mt)
    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 sprite = {
    newSprite = newSprite,
}

return sprite