-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.lua
48 lines (39 loc) · 1006 Bytes
/
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
--[[
Flappy Bird Lua
CyanPiano - 2021/09/02
https://github.com/CyanPiano/Flappy-Bird-Lua
--]]
local Game = require("./objects/Game")
local Player = require("./objects/Player")
local Pipe = require("./objects/Pipe")
CONSTANTS = require("./consts")
function love.load()
game = Game:new()
game:init()
end
function love.update(dt)
if game.playstate == "playing" then
bird:update(dt)
updatePipes()
end
end
function love.draw()
if game.playstate == "playing" or game.playstate == "dead" then
drawPipes()
bird:draw()
game:drawPoints()
if game.playstate == "dead" then
game:drawDead()
end
elseif game.playstate == "waiting" then
game:drawAwait()
end
end
function love.keypressed(key)
if game.playstate == "playing" then
bird:fly()
elseif game.playstate == "waiting" or game.playstate == "dead" then
game:init()
game.playstate = "playing"
end
end