-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.lua
56 lines (53 loc) · 1.54 KB
/
main.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
local bump = require 'lib.bump.bump'
local player = require 'parts.player'
local platforms = require 'parts.platforms'
local floor = require 'parts.floor'
local hud = require 'parts.hud'
local background = require 'parts.background'
local audio = require 'assets.audio'
local animations = require 'parts.animations'
local globals = require 'globals'
local gameover = require 'parts.gameover'
local start = require 'parts.start'
local fonts = require 'parts.fonts'
function love.load()
world = bump.newWorld(16)
fonts.init()
globals.init()
animations.init()
floor.init(world)
platforms.init(world)
player.init(world)
audio.init()
end
function love.update(dt)
if globals.playing and globals.started then
player.update(dt)
platforms.update(player, dt)
elseif love.keyboard.isDown("return") and globals.started then
love.load()
elseif love.keyboard.isDown("return") and not globals.started then
globals.started = true
end
animations.update()
end
function love.draw()
local xOffset = 0
local yOffset = -player.y + love.graphics.getHeight() - 170
if animations.hurt.playing then
xOffset = love.math.random(-10, 10)
yOffset = yOffset + love.math.random(-10, 10)
end
love.graphics.translate(xOffset, yOffset)
background.draw(yOffset)
floor.draw()
platforms.draw()
player.draw()
hud.draw(yOffset)
if not globals.playing then
gameover.draw(yOffset)
end
if not globals.started then
start.draw(yOffset)
end
end