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