37 lines
1.1 KiB
Lua
37 lines
1.1 KiB
Lua
local spritesheets = {}
|
|
local player = {}
|
|
local game = {}
|
|
local camera = {}
|
|
|
|
function drawerinit(spritesheetst, playert, gamex, camerax)
|
|
spritesheets = spritesheetst
|
|
player = playert
|
|
game = gamex
|
|
camera = camerax
|
|
end
|
|
|
|
local function draw()
|
|
camera:attach()
|
|
--draw background
|
|
love.graphics.draw(game.levels[game.level].background, 0, 0)
|
|
--draw player_animation
|
|
player.animation:draw(player.x, player.y)
|
|
if player.state == "idle" then
|
|
spritesheets["player_idle"]:draw(player.x, player.y)
|
|
elseif player.state == "walk_left" then
|
|
spritesheets["player_walk_left"]:draw(player.x, player.y)
|
|
elseif player.state == "walk_right" then
|
|
spritesheets["player_walk_right"]:draw(player.x, player.y)
|
|
elseif player.state == "jump" then
|
|
spritesheets["player_jump"]:draw(player.x, player.y)
|
|
elseif player.state == "die" then
|
|
spritesheets["player_die"]:draw(player.x, player.y)
|
|
else
|
|
spritesheets["player_default"]:draw(player.x, player.y)
|
|
end
|
|
camera:detach()
|
|
end
|
|
return {
|
|
drawerinit = drawerinit,
|
|
draw = draw
|
|
} |