-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.lua
89 lines (78 loc) · 2.03 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
require "animated_sprite"
require "bounding_box"
require "main_menu"
require "collision"
require "loader"
require "updater"
require "drawer"
require "sick"
require "highscore_table"
require "name_entry"
require "game_over"
require "credits"
function love.conf(t)
t.identity = "as-the-crow-flies"
t.version = "0.9.0"
end
function love.load()
loader()
end
function love.update(dt)
updater(dt)
end
function love.draw()
drawer()
end
function love.keypressed(key, isrepeat)
if key == "escape" then
highscore.save()
love.event.quit()
elseif state == States.Paused and key == " " then
state = States.Play
elseif state == States.Play and key == "p" then
state = States.Paused
elseif state == States.NameEntry and key == "backspace" then
name = name:sub(1, #name - 1)
end
end
function love.textinput(t)
if string.len(name) < 3 and t ~= " " then
name = name .. t
end
end
function love.mousepressed(x, y, button)
love.graphics.setFont(font)
if state ~= States.Play and button == "l" then
if state == States.Menu then clicked = main_menu:click(x,y) end
if state == States.Highscores then clicked = highscore_table:click(x,y) end
if state == States.NameEntry then clicked = name_entry:click(x,y) end
if state == States.GameOver then clicked = game_over:click(x,y) end
if state == States.Credits then clicked = credits:click(x,y) end
if clicked == Buttons.Play then
reset()
load_poem()
love.mouse.setVisible(false)
state = States.Paused
elseif clicked == Buttons.Credits then
load_credits()
state = States.Credits
elseif clicked == Buttons.Highscores then
state = States.Highscores
elseif clicked == Buttons.Menu then
state = States.Menu
elseif clicked == Buttons.Exit then
highscore.save()
love.event.quit()
end
end
end
function reset()
music:setPitch(1)
animation_x = (love.graphics.getWidth() - animation.width)/2
animation_y = (love.graphics.getHeight() - animation.height)/2
text_x = love.graphics.getWidth()
text_y = love.graphics.getHeight()/2
line = 1
text_speed = 200*scale
score = 0
end