Weeeeee/modules/draw_callback.lua

33 lines
1015 B
Lua
Raw Normal View History

2022-03-02 18:36:52 +01:00
local spritesheets = {}
local player = {}
local game = {}
function drawerinit(spritesheetst, playert, gamex)
spritesheets = spritesheetst
player = playert
game = gamex
end
local function draw()
--draw background
love.graphics.draw(backgrounds[game.level], 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
end
return {
drawerinit = drawerinit,
draw = draw
}