-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathglobal_values.py
199 lines (150 loc) · 4.07 KB
/
global_values.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
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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
import pygame as p
import math as m
import ctypes
import os
import gc
def clear_surface_cache():
global surface_cache
surface_cache = {}
gc.collect()
def set_filtering(enable):
old_enable = g.FILTER_SCALING
g.FILTER_SCALING = enable
if old_enable != g.FILER_SCALING:
clear_surface_cache()
def get_default_surface():
width, height = 16,16
#create error surface
default_surface = p.Surface((width, height))
#purple and black grid
for x in range(width):
for y in range(height):
if (x%2) + (y%2) == 0:
colour = PURPLE
else:
colour = BLACK
default_surface.set_at((x,y), colour)
#add edge colour
default_surface.set_at((0,0), RED)
default_surface.set_at((1,0), RED)
default_surface.set_at((0,1), RED)
default_surface.set_at((width-1, 0), YELLOW)
default_surface.set_at((width-2, 0), YELLOW)
default_surface.set_at((width-1, 1), YELLOW)
default_surface.set_at((0,height-1), BLUE)
default_surface.set_at((1,height-1), BLUE)
default_surface.set_at((0,height-2), BLUE)
default_surface.set_at((width-1,height-1), GREEN)
default_surface.set_at((width-2,height-1), GREEN)
default_surface.set_at((width-1,height-2), GREEN)
return default_surface
WHITE = (255, 255, 255)
GRAY = (128, 128, 128)
BLACK = (0, 0, 0)
NEAR_BLACK = (1, 1, 1)
RED = (255, 0, 0)
DARK_RED = (128, 0, 0)
ORANGE = (255, 128, 0)
YELLOW = (255,255,0)
LIGHT_GREEN = (0, 255, 128)
GREEN = (0, 255, 0)
DARK_GREEN = (0, 128, 0)
CYAN = (0,255,255)
LIGHT_BLUE = (0, 128, 255)
BLUE = (0, 0, 255)
DARK_BLUE = (0, 0, 128)
PINK = (255, 0, 128)
PURPLE = (128,0,128)
MAGENTA = (255,0,255)
LIGHT_BROWN = (164, 96, 0)
BROWN = (128, 64, 0)
DARK_BROWN = (92, 32, 0)
BACKGROUND_COLOUR = WHITE
BACKGROUND_SURFACE = None
DRAW_BACKGROUND = True
TRANSPARENCY_COLOUR = (0,126,126)
SHOW_FPS = True
SHOW_NODE_MAPS = False
MONITOR_WIDTH = ctypes.windll.user32.GetSystemMetrics(0)
MONITOR_HEIGHT = ctypes.windll.user32.GetSystemMetrics(1)
WIDTH = int(900*1.2)#MONITOR_WIDTH#
HEIGHT = int(500*1.2)#MONITOR_HEIGHT#
SCREEN_RECT = p.Rect(0, 0, WIDTH, HEIGHT)
screen = None
display_screen = None
FILTER_SCALING = False
LEVEL_SCALE_X = 1
LEVEL_SCALE_Y = 1
ASPECT_RATIO = WIDTH/HEIGHT
main_dir = "files"+os.path.sep
gfx_dir = main_dir+"gfx"+os.path.sep
level_dir = main_dir+"level"+os.path.sep
sound_dir = main_dir+"sound"+os.path.sep
data_dir = main_dir+"data"+os.path.sep
internal_assets_dir = __file__+os.path.sep+"assets"+os.path.sep
is_setup = False
game_object_next_id = 0
CHUNK_WIDTH = 80
CHUNK_HEIGHT = 80
DEFAULT_LEVEL_SEGMENT_SIZE = 100
ENABLE_SEGMENT_ENTITY_THRESHOLD = 30
GLOBAL_VOLUME = 1
ENTITY_STEP_SNAP_THRESHOLD = 15
segmenting_in_levels = True
ENABLE_LIGHTING = False
ENABLE_COLOURED_LIGHTING = False
MIN_LIGHT_LEVEL = 200
darkness_surface = p.Surface((WIDTH, HEIGHT))
light_colour_surface = p.Surface((WIDTH, HEIGHT))
light_colour_surface.set_colorkey(BLACK)
MAX_SAVE_RECURSION = 10
MAX_TICK_RATE = 60
MAX_FRAME_RATE = 60
MIN_TICK_TIME = 1/MAX_TICK_RATE
MIN_FRAME_TIME = 1/MAX_FRAME_RATE
time_to_next_tick = MIN_TICK_TIME
time_to_next_frame = MIN_FRAME_TIME
tick_count = 0
frame_count = 0
tick_perf_counter = 0
frame_perf_counter = 0
tick_rate = 0
frame_rate = 0
clock = p.time.Clock()
game_objects = {}
animations = []
animation_systems = []
events = []
particle_spawners = []
pipes = {}
pipe_list = []
spritesheets = {}
fonts = {}
logs = {}
node_maps = set()
light_grids = set()
pressed_buttons = set()
surface_cache = {}
sound_properties = {}
pot_sounds = {}
saved_data_dicts = {}
saved_variables = []
internal_commands = []
pg_events = []
current_pressed_button = None
active_levels = []
structure_classes = {}
current_level = None
camera = None
player = None
keys, mx, my, ml, mm, mr, mp =\
[], 0, 0, False, False, False, (0,0)
tmx, tmy = 0, 0
rmx, rmy = 0, 0
mouse_locks = {i:0 for i in range(20)}
#game state
current_states = {"start"}
sound_dict = {}
default_surface = get_default_surface()
fps_text_box = None
current_music = None