-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathresults.lua
More file actions
158 lines (138 loc) · 5.59 KB
/
results.lua
File metadata and controls
158 lines (138 loc) · 5.59 KB
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
function results_update(dt)
if results_timer_val ~= 0 then
results_timer_val = results_timer_val - dt
if results_timer_val < 0 then
results_timer_val = 0
if results_state == 0 then
results_timer_val = 1
results_state = 1
elseif results_state == 1 then
results_timer_val = 1
results_state = 2
end
end
end
end
function results_keypressed(key, scancode, isrepeat)
if results_state == 2 and key == 'r' then
sweet_spot = tonumber(string.format("%.2f", love.math.random() * (sweet_spot_range[2] - sweet_spot_range[1]) + sweet_spot_range[1]))
heat_val = 0
heat_direction = 0
timer_val = 0
hammer_cooldown_val = 0
hammer_held = 0
hammer_swing_count = hammer_swing_count_max
game_active = 0
score = 0
temp_scoring_bracket = ""
time_bonus = 0
scoring_bracket = ""
round_start_countdown = round_start_countdown_max
hammer_hit_history = {'-', '-', '-', '-', '-', '-', '-', '-', '-', '-'}
hammer_hit_quality_timer = hammer_hit_quality_timer_max
application_state = 1
results_state = 0
elseif results_state == 2 and key == 'escape' then
sweet_spot = tonumber(string.format("%.2f", love.math.random() * (sweet_spot_range[2] - sweet_spot_range[1]) + sweet_spot_range[1]))
heat_val = 0
heat_direction = 0
timer_val = 0
hammer_cooldown_val = 0
hammer_held = 0
hammer_swing_count = hammer_swing_count_max
game_active = 0
score = 0
temp_scoring_bracket = ""
time_bonus = 0
scoring_bracket = ""
round_start_countdown = round_start_countdown_max
hammer_hit_history = {'-', '-', '-', '-', '-', '-', '-', '-', '-', '-'}
hammer_hit_quality_timer = hammer_hit_quality_timer_max
application_state = 0
results_state = 0
music_direction = 1
music_fade_timer = music_fade_timer_max
menu_music:setVolume(1)
end
end
function results_keyreleased(key, scancode, isrepeat)
end
function draw_goblet(bracket)
love.graphics.setColor(1, 1, 1)
-- Goblet artwork
if bracket == "Elf-made" then
love.graphics.draw(goblet_elf, (love.graphics.getWidth() / 2) - 28, 200)
elseif bracket == "Decent" then
love.graphics.draw(goblet_decent, (love.graphics.getWidth() / 2) - 28, 200)
elseif bracket == "Fine" then
love.graphics.draw(goblet_fine, (love.graphics.getWidth() / 2) - 28, 200)
elseif bracket == "Exceptional" then
love.graphics.draw(goblet_exceptional, (love.graphics.getWidth() / 2) - 28, 200)
elseif bracket == "Masterful" then
love.graphics.draw(goblet_masterful, (love.graphics.getWidth() / 2) - 28, 200)
end
end
function draw_bracket(bracket)
-- Graphics for scoring bracket
if bracket == "Elf-made" then
love.graphics.setColor(1, 0, 0)
else
love.graphics.setColor(0, 1, 0)
end
love.graphics.printf(bracket, love.graphics.getWidth() / 2 - 150, 150, 300, "center")
end
function draw_timer()
-- Graphics for timer
love.graphics.setColor(0, 1, 0)
if timer_val > timer_positive_ceil then
love.graphics.setColor(1, 1, 1)
end
if timer_val > timer_negative_floor then
love.graphics.setColor(1, 0, 0)
end
love.graphics.printf(math.floor(timer_val / 60) .. ":" .. string.format("%02d", math.floor(timer_val % 60)) .. "." .. ("%03d"):format((timer_val % 1) * 1000), love.graphics.getWidth() / 2 - 50, 350, 100, "center")
end
function draw_time_bonus()
-- Graphics for time Bonus
love.graphics.setColor(0, 1, 0)
if time_bonus == 0 then
love.graphics.setColor(1, 1, 1)
elseif time_bonus == -10 then
love.graphics.setColor(1, 0, 0)
end
love.graphics.printf("Time Bonus: " .. time_bonus, love.graphics.getWidth() / 2 - 150, 370, 300, "center")
end
function results_draw()
love.graphics.setFont(menu_font)
if results_state == 0 then
-- Graphics for score
-- love.graphics.setColor(1, 1, 0)
-- love.graphics.print("Score: " .. score, 10, 130)
draw_bracket(temp_scoring_bracket)
draw_goblet(temp_scoring_bracket)
elseif results_state == 1 then
draw_bracket(temp_scoring_bracket)
draw_timer()
draw_time_bonus()
draw_goblet(temp_scoring_bracket)
elseif results_state == 2 then
draw_timer()
draw_time_bonus()
draw_bracket(scoring_bracket)
draw_goblet(scoring_bracket)
-- Graphics for win and lose
-- if game_active == 2 and score + time_bonus >= 20 then
-- love.graphics.print("You Win", 10, 210)
-- elseif game_active == 2 then
-- love.graphics.print("You Lose", 10, 210)
-- end
-- Graphics for play again prompt
if game_active == 2 then
love.graphics.setColor(1, 1, 1)
love.graphics.printf("Press R to play again\nEscape to return to menu", love.graphics.getWidth() / 2 - 250, 390, 500, "center")
end
end
-- Graphics for hit history
-- love.graphics.setColor(1, 1, 1)
-- love.graphics.print("Hammer Hit History: [" .. hammer_hit_history[1] .. "], [" .. hammer_hit_history[2] .. "], [" .. hammer_hit_history[3] .. "], [" .. hammer_hit_history[4] .. "], [" .. hammer_hit_history[5] .. "], [" .. hammer_hit_history[6] .. "], [" .. hammer_hit_history[7] .. "], [" .. hammer_hit_history[8] .. "], [" .. hammer_hit_history[9] .. "], [" .. hammer_hit_history[10] .. "]", 10, 250)
end