-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetting.py
112 lines (101 loc) · 2.73 KB
/
setting.py
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
import os
import sys
# var
RIGHT = "right"
LEFT = "left"
DOWN = "down"
UP = "up"
MENU = "menu"
RESUME = "resume"
PLAY_AGAIN = "play-again"
UP_ARROW = 1073741906
DOWN_ARROW = 1073741905
LEFT_ARROW = 1073741904
RIGHT_ARROW = 1073741903
ENTER_KEY = 13
W_KEY = 119
A_KEY = 97
S_KEY = 115
D_KEY = 100
ESC_KEY = 27
SELF_OVERLAP = "selfoverlap"
OVERLAP = "overlap"
EMPTY = "empty"
# color
BLACK = 30, 30, 30
WHITE = 230, 230, 230
GREEN = 78, 245, 231
BLUE = 121, 205, 247
YELLOW = 226, 242, 133
# file
DIR = os.path.dirname(os.path.realpath(__file__))
if getattr(sys, "frozen", False):
DIR = os.path.dirname(sys.executable)
FONT = str(DIR) + "/files/OpenSans-Bold.ttf"
MENU_IMG = str(DIR) + "/files/menu-img.jpg"
# window
WIN_TITLE = "snake game"
WIN_BGCOLOR = "black"
WIN_WIDTH = 900
WIN_HEIGHT = WIN_WIDTH
FONT_SIZE_MAIN = round(WIN_WIDTH / 30)
FONT_SIZE_PAUSE = round(WIN_WIDTH / 50)
# menu
MENU_BGCOLOR = BLACK
OPTION_BGCOLOR = WHITE
OPTION_SELECT_COLOR = GREEN
OPTION_TXTCOLOR = BLACK
OPTION_BGLEN = width, height = WIN_WIDTH / 5, WIN_WIDTH / 15
OPTION_BGPOS = x, y = (WIN_WIDTH - OPTION_BGLEN[0]) / 2, WIN_HEIGHT / 1.5
OPTION_BGGAP = OPTION_BGLEN[1] / 10
# pause-menu
PAUSE_FRLEN = width, height = WIN_WIDTH / 2, WIN_HEIGHT / 2
PAUSE_FRPOS = x, y = (WIN_WIDTH - PAUSE_FRLEN[0]) / 2, (WIN_HEIGHT - PAUSE_FRLEN[1]) / 2
PAUSE_FRCOLOR = r, g, b = BLACK
PAUSE_OPCOLOR = r, g, b = WHITE
PAUSE_SELECT_COLOR = r, g, b = GREEN
PAUSE_TXTCOLOR = r, g, b = BLACK
PAUSE_OPLEN = width, height = PAUSE_FRLEN[0] / 4, PAUSE_FRLEN[1] / 10
PAUSE_OPGAP = PAUSE_FRLEN[0] / 30
PAUSE_OPPOS = x, y = (
PAUSE_FRPOS[0] + (PAUSE_FRLEN[0] - PAUSE_OPLEN[0]) / 2,
PAUSE_FRPOS[1] + (PAUSE_FRLEN[1] - 2 * (PAUSE_OPLEN[1] + PAUSE_OPGAP)) / 2,
)
# game-over
GO_FRLEN = width, height = WIN_WIDTH / 2, WIN_HEIGHT / 2
GO_FRPOS = x, y = (WIN_WIDTH - GO_FRLEN[0]) / 2, (WIN_HEIGHT - GO_FRLEN[1]) / 2
GO_FRCOLOR = BLACK
GO_FR_TXTCOLOR = r, g, b = 48, 90, 22
GO_OPCOLOR = WHITE
GO_SELECT_COLOR = GREEN
GO_TXTCOLOR = BLACK
GO_OPLEN = width, height = GO_FRLEN[0] / 4, GO_FRLEN[1] / 10
GO_OPGAP = GO_FRLEN[0] / 30
GO_OPPOS = x, y = (
GO_FRPOS[0] + (GO_FRLEN[0] - GO_OPLEN[0]) / 2,
GO_FRPOS[1] + GO_FRLEN[1] / 2,
)
# game
GAME_BGCOLOR = BLACK
GRID_COUNT = 50
GRID_SIZE = WIN_WIDTH / GRID_COUNT
FPS = 300
# snakes
SNAKES_SHAPE = ["square", "square"]
SNAKES_COLOR = [(BLUE), (YELLOW)]
SNAKES_INIT_LEN = [10, 10]
SNAKES_INIT_DIR = [DOWN, UP]
SNAKES_INIT_GRID = [(15, 10), (35, 40)]
SNAKES_THICKNESS = GRID_SIZE
SNAKES_KEYS = [
{LEFT: A_KEY, RIGHT: D_KEY, UP: W_KEY, DOWN: S_KEY},
{LEFT: LEFT_ARROW, RIGHT: RIGHT_ARROW, UP: UP_ARROW, DOWN: DOWN_ARROW},
]
SNAKES_MAX_COUNTER = [30, 30]
# key
PLAYER1_LEFT = 97 # a
PLAYER1_RIGHT = 100 # d
PLAYER1_UP = 119 # w
PLAYER1_DOWN = 115 # s
# food
FOOD_COLOR = WHITE