-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathquit.py
More file actions
41 lines (36 loc) · 1.05 KB
/
quit.py
File metadata and controls
41 lines (36 loc) · 1.05 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
import sys
import pygame
import fonts
import music
import save
import variables
from classes.skilltree import (
get_coins,
get_skill_level,
)
game_data = save.load_game()
game_data = save.load_game()
old_high_score = game_data.get("high_score", 0)
current_score = variables.get_score()[0]
new_high_score = max(old_high_score, current_score)
def quit_game(username_input):
username = username_input.get_value()
save.save_game(
{
"difficulty": variables.get_difficulty(),
"coins": get_coins(),
"high_score": new_high_score,
"name": username,
"gems": variables.get_gem(),
"skilltree_hb": get_skill_level("health_boost"),
"skilltree_rf": get_skill_level("rapid_fire"),
"skilltree_ds": get_skill_level("double_shot"),
"skilltree_sh": get_skill_level("shield"),
"skilltree_su": get_skill_level("super_shot"),
}
)
music.stop_theme()
music.unload_theme()
fonts.quit_font()
pygame.quit()
sys.exit()