25
25
26
26
def tick args
27
27
args . lowrez . background_color = [ 91 , 110 , 225 ]
28
- # args.lowrez.background_color = [255,255,255]
29
28
30
29
background_image args
31
30
init_state args
@@ -36,7 +35,6 @@ def tick args
36
35
reset_game_state args
37
36
38
37
main_loop args
39
-
40
38
# render_debug args
41
39
end
42
40
@@ -57,12 +55,16 @@ def background_image args
57
55
end
58
56
59
57
def init_state args
58
+ if args . state . tick_count == 0
59
+ args . outputs . sounds << "sound/tiny-tty-theme.ogg"
60
+ end
60
61
args . state . wrong_key ||= false
61
62
args . state . score ||= 0
62
63
args . state . player_name ||= ""
63
64
args . state . leader_fetch ||= nil
64
65
args . state . leaders ||= [ ]
65
66
args . state . prefetch ||= $gtk. http_get "https://tiny-tty-server.herokuapp.com"
67
+ args . state . muted ||= false
66
68
end
67
69
68
70
def main_loop args
@@ -118,12 +120,12 @@ def main_loop args
118
120
h : 24 ,
119
121
path : "sprites/logo.png" ,
120
122
}
121
- args . lowrez . labels << { x : 33 , y : 30 , text : "and enter" ,
123
+ args . lowrez . labels << { x : 33 , y : 30 , text : "enter" ,
122
124
size_enum : LOWREZ_FONT_SM , alignment_enum : 1 ,
123
125
r : 153 , g : 229 , b : 80 , a : 255 ,
124
126
font : "fonts/pixel-4x5.ttf" }
125
127
126
- args . lowrez . labels << { x : 33 , y : 23 , text : "the keys " ,
128
+ args . lowrez . labels << { x : 33 , y : 23 , text : "the letters " ,
127
129
size_enum : LOWREZ_FONT_SM , alignment_enum : 1 ,
128
130
r : 153 , g : 229 , b : 80 , a : 255 ,
129
131
font : "fonts/pixel-4x5.ttf" }
@@ -282,7 +284,6 @@ def main_loop args
282
284
end
283
285
284
286
if ratio_done >= 1
285
- # reset_game_state(args, true)
286
287
args . state . screen = :game_over
287
288
end
288
289
end
@@ -296,12 +297,14 @@ def chosen_key?(args)
296
297
args . state . time_passed = 0 # countdown for subsequent keys
297
298
args . state . correct_keys += 1 # countdown for subsequent keys
298
299
args . state . score += DIFFICULTY_SCORE [ args . state . difficulty ] * 100
300
+ args . gtk . queue_sound "sound/g5drum.ogg" if !args . state . muted
299
301
elsif @chosen_key && args . inputs . keyboard . key_down . truthy_keys . length > 0 && args . inputs . keyboard . key_down . truthy_keys [ 0 ] == :char
300
302
args . state . wrong_key = true
301
303
args . state . wrong_key_time = args . state . tick_count
302
304
if args . state . score > 0
303
305
args . state . score -= DIFFICULTY_SCORE [ args . state . difficulty ] * 100
304
306
end
307
+ args . gtk . queue_sound "sound/c5drum.ogg" if !args . state . muted
305
308
end
306
309
307
310
@chosen_key ||= ALLOWED_KEYS . sample
@@ -348,6 +351,10 @@ def reset_game_state(args, force = false)
348
351
elsif args . inputs . keyboard . key_down . space! && args . state . screen != :game && args . state . screen != :game_over
349
352
args . state . leader_post = { complete : true } # stub POST of score
350
353
args . state . screen = :leaderboard
354
+ elsif args . inputs . keyboard . key_down . m && args . state . screen != :game && args . state . screen != :game_over
355
+ args . gtk . stop_music
356
+ args . state . muted = !args . state . muted
357
+ args . outputs . sounds << "sound/tiny-tty-theme.ogg" if !args . state . muted
351
358
end
352
359
end
353
360
0 commit comments