-
Notifications
You must be signed in to change notification settings - Fork 2
/
level0.py
314 lines (253 loc) · 13.3 KB
/
level0.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
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
from turtle import position
from ursina import *
from UrsinaLighting import *
from ursina.shaders import *
import items
import json
#initial variable stuff
wall_side_scale = 0.5
wall_spacing = 5
with open("data/program_info.json", "r") as f:
program_info = json.load(f)
chunk_types=[]
list_of_cords={}
hum = Audio("resources\levels\level 0\Backrooms sound.mp3", loop=True)
hum.volume = 0.1
hum.play()
#initial map stuff
wall = LitObject(model="cube",
texture=Texture("resources/levels/level 0/wall.png"),
scale=(0,0,0),
collider="box",
position=(5,0,5),
specularMap=load_texture("resources/levels/level 0/noreflect.png"),
cubemapIntensity=0)
floor = LitObject(model="cube",
texture=Texture("resources/levels/level 0/carpet.png"),
scale=(1000, 1, 1000),
collider="mesh",
tiling=(250,250),
position=(0,0,0),
specularMap=load_texture("resources/levels/level 0/noreflect.png"),
cubemapIntensity=0)
ceiling = LitObject(model="cube",
texture=Texture("resources/levels/level 0/ceiling.png"),
scale=(1000, 1, 1000),
tiling=(500,500),
collider="mesh",
position=(0,6,0),
specularMap=load_texture("resources/levels/level 0/noreflect.png"),
cubemapIntensity=0)
collider = Entity(collider="box")
light = Entity(model="cube", color=color.white, position=(100,-1,100), scale=(2.2,1.2,4))
#LitPointLight(position=Vec3(0,0,0), intensity=1, color=rgb(248, 252, 150))
#class stuff
class level:
def __init__(self, seed, chunks=5):
self.seed = seed
self.chunks = chunks
def generate():
print("hello")
class NormalChunk:
def __init__(self, x, y, z, size=20):
self.x = x
self.y = y
self.z = z
def place(self):
row = 0
collumn = 0
while row < self.size:
while collumn < self.size:
SubChunk(self.x + (collumn * wall_spacing), 0, self.z + (row * wall_spacing)).place()
class Chunk:
def __init__(self, size=20, type="normal", position=(0,0,0), varients=5):
self.size = size
self.type = type
self.position = position
self.varients = varients
def create(self):
global list_of_cords
global chunk_types
chunk_types.append(self.type)
new_chunk = []
while z <= self.size:
while x <= self.size:
cords = [x, z]
percent = int((z / self.size) * 100)
if percent < 0:
percent = 0
print(f"generating {self.position} varient {self.type}: {cords} {percent}%")
new_chunk.append(cords)
x += 1
x = min
z += 1
class SubChunk:
if program_info["graphics"]["quality"] == "high":
def __init__(self, x=0, y=0, z=0, has_item=None, has_pillar=None):
self.x = x
self.y = y
self.z = z
self.structure = Entity(position=(x, y, z))
self.light_object = LitObject(position=(x, y, z))
self.item = LitObject(position=(x, y, z))
self.random_value = random.randint(0, 100)
if has_item == None:
if self.random_value < 2:
self.has_item = True
else:
self.has_item = False
else:
self.has_item = has_item
if has_pillar == None:
if self.random_value <= 25:
self.has_pillar = True
else:
self.has_pillar = False
else:
self.has_pillar = has_pillar
def place_pillar(self, x=0, y=0, z=0):
duplicate(wall, position=(x,y,z), scale=(1,10,1))
def place_door(self, x=0, y=0, z=0, sideways=False):
if sideways == False:
duplicate(wall, position=(x-wall_spacing / 1.5, y, z), scale=(wall_spacing / 1.5, 8, wall_side_scale), shader=basic_lighting_shader, parent=self.structure)#left side of door
duplicate(wall, position=(x+wall_spacing / 1.5, y, z), scale=(wall_spacing / 1.5, 8, wall_side_scale), shader=basic_lighting_shader, parent=self.structure)#right side of door
duplicate(wall, position=(x, y+5, z), scale=(wall_spacing * 2, 2, wall_side_scale), shader=basic_lighting_shader, parent=self.structure)#top side of door
#duplicate(collider, position=(x-wall_spacing / 1.5, y, z), scale=(wall_spacing / 1.5, 8, wall_side_scale), shader=basic_lighting_shader, parent=self.collision_structure)
#duplicate(collider, position=(x+wall_spacing / 1.5, y, z), scale=(wall_spacing / 1.5, 8, wall_side_scale), shader=basic_lighting_shader, parent=self.collision_structure)
else:
duplicate(wall, position=(x, y, z-wall_spacing / 1.5), scale=(wall_side_scale, 8, wall_spacing / 1.5), shader=basic_lighting_shader, parent=self.structure)#left side of door
duplicate(wall, position=(x, y, z+wall_spacing / 1.5), scale=(wall_side_scale, 8, wall_spacing / 1.5), shader=basic_lighting_shader, parent=self.structure)#right side of door
duplicate(wall, position=(x, y+5, z), scale=(wall_side_scale, 2, wall_spacing * 2), shader=basic_lighting_shader, parent=self.structure)#top side of door
#duplicate(collider, position=(x, y, z-wall_spacing / 1.5), scale=(wall_side_scale, 8, wall_spacing / 1.5), shader=basic_lighting_shader, parent=self.collision_structure)
#duplicate(collider, position=(x, y, z+wall_spacing / 1.5), scale=(wall_side_scale, 8, wall_spacing / 1.5), shader=basic_lighting_shader, parent=self.collision_structure)
def place_wall(self, x=0, y=0, z=0, sideways=False):
if sideways == False:
duplicate(wall, position=(x, y, z), scale=(wall_spacing * 2, 20, wall_side_scale), shader=basic_lighting_shader, parent=self.structure)
#duplicate(collider, position=(x, y, z), scale=(wall_spacing * 2, 20, wall_side_scale), shader=basic_lighting_shader, parent=self.collision_structure)
else:
duplicate(wall, position=(x, y, z), scale=(wall_side_scale, 20, wall_spacing * 2), shader=basic_lighting_shader, parent=self.structure)
#duplicate(collider, position=(x, y, z), scale=(wall_side_scale, 20, wall_spacing * 2), shader=basic_lighting_shader, parent=self.collision_structure)
def place(self):
if self.has_item == True:
self.item = random.randint(1, 1)
if self.item == 1:
self.item = items.AlmondWater(self.x, self.y, self.z).spawn()
else:
self.item = Entity(position=(self.x, self.y, self.z))
else:
self.items = Entity(position=(self.x, self.y, self.z))
if self.has_pillar == True:
self.place_pillar(self.x, self.y, self.z)
light_level = random.randint(0, 1)
if light_level == 0:
self.light_object = Entity(model="cube",
scale=(2.2,1.2,4),
position=(self.x * 2 - wall_spacing, 5.8, self.z * 2 - wall_spacing),
texture=Texture("resources/levels/level 0/lightoff.png"))
else:
self.light_object = Entity(model="cube",
scale=(2.2,1.2,4),
position=(self.x * 2 - wall_spacing, 5.8, self.z * 2 - wall_spacing),
texture=Texture("resources/levels/level 0/light.png"))
left_rand = random.randint(0, 2)
if left_rand == 1:
self.place_door(self.x, self.y, self.z - wall_spacing, True)
elif left_rand == 2:
self.place_wall(self.x, self.y, self.z - wall_spacing, True)
else:
pass
top_rand = random.randint(0, 2)
if top_rand == 1:
self.place_door(self.x + wall_spacing, self.y, self.z, False)
elif top_rand == 2:
self.place_wall(self.x + wall_spacing, self.y, self.z, False)
else:
pass
else:
def __init__(self, x=0, y=0, z=0, has_item=None, has_pillar=None):
self.x = x
self.y = y
self.z = z
self.structure = Entity(position=(x, y, z))
self.collision_structure = Entity(position=(x, y, z))
self.light_structure = Entity(position=(x, y, z))
self.item = Entity(position=(x, y, z))
self.random_value = random.randint(0, 100)
if has_item == None:
if self.random_value < 2:
self.has_item = True
else:
self.has_item = False
else:
self.has_item = has_item
if has_pillar == None:
if self.random_value <= 25:
self.has_pillar = True
else:
self.has_pillar = False
else:
self.has_pillar = has_pillar
def place_pillar(self, x=0, y=0, z=0):
duplicate(wall, position=(x,y,z), scale=(1,10,1))
def place_door(self, x=0, y=0, z=0, sideways=False):
if sideways == False:
duplicate(wall, position=(x-wall_spacing / 1.5, y, z), scale=(wall_spacing / 1.5, 8, wall_side_scale), shader=basic_lighting_shader, parent=self.structure)#left side of door
duplicate(wall, position=(x+wall_spacing / 1.5, y, z), scale=(wall_spacing / 1.5, 8, wall_side_scale), shader=basic_lighting_shader, parent=self.structure)#right side of door
duplicate(wall, position=(x, y+5, z), scale=(wall_spacing * 2, 2, wall_side_scale), shader=basic_lighting_shader, parent=self.structure)#top side of door
duplicate(collider, position=(x-wall_spacing / 1.5, y, z), scale=(wall_spacing / 1.5, 8, wall_side_scale), shader=basic_lighting_shader, parent=self.collision_structure)
duplicate(collider, position=(x+wall_spacing / 1.5, y, z), scale=(wall_spacing / 1.5, 8, wall_side_scale), shader=basic_lighting_shader, parent=self.collision_structure)
else:
duplicate(wall, position=(x, y, z-wall_spacing / 1.5), scale=(wall_side_scale, 8, wall_spacing / 1.5), shader=basic_lighting_shader, parent=self.structure)#left side of door
duplicate(wall, position=(x, y, z+wall_spacing / 1.5), scale=(wall_side_scale, 8, wall_spacing / 1.5), shader=basic_lighting_shader, parent=self.structure)#right side of door
duplicate(wall, position=(x, y+5, z), scale=(wall_side_scale, 2, wall_spacing * 2), shader=basic_lighting_shader, parent=self.structure)#top side of door
duplicate(collider, position=(x, y, z-wall_spacing / 1.5), scale=(wall_side_scale, 8, wall_spacing / 1.5), shader=basic_lighting_shader, parent=self.collision_structure)
duplicate(collider, position=(x, y, z+wall_spacing / 1.5), scale=(wall_side_scale, 8, wall_spacing / 1.5), shader=basic_lighting_shader, parent=self.collision_structure)
def place_wall(self, x=0, y=0, z=0, sideways=False):
if sideways == False:
duplicate(wall, position=(x, y, z), scale=(wall_spacing * 2, 20, wall_side_scale), shader=basic_lighting_shader, parent=self.structure)
duplicate(collider, position=(x, y, z), scale=(wall_spacing * 2, 20, wall_side_scale), shader=basic_lighting_shader, parent=self.collision_structure)
else:
duplicate(wall, position=(x, y, z), scale=(wall_side_scale, 20, wall_spacing * 2), shader=basic_lighting_shader, parent=self.structure)
duplicate(collider, position=(x, y, z), scale=(wall_side_scale, 20, wall_spacing * 2), shader=basic_lighting_shader, parent=self.collision_structure)
def place(self):
if self.has_item == True:
self.item = random.randint(1, 1)
if self.item == 1:
self.item = items.AlmondWater(self.x - wall_spacing, self.y, self.z - wall_spacing).spawn()
else:
self.item = Entity(position=(self.x - wall_spacing, self.y, self.z - wall_spacing))
else:
self.items = Entity(position=(self.x - wall_spacing, self.y, self.z - wall_spacing))
if self.has_pillar == True:
self.place_pillar(self.x, self.y, self.z)
light_level = random.randint(0, 1)
if light_level == 0:
self.light_object = Entity(model="cube",
scale=(2.2,1.2,4),
position=(self.x - wall_spacing, 5.8, self.z - wall_spacing),
texture=Texture("resources/levels/level 0/lightoff.png"),
parent=self.light_structure)
else:
self.light_object = Entity(model="cube",
scale=(2.2,1.2,4),
position=(self.x - wall_spacing, 5.8, self.z - wall_spacing),
texture=Texture("resources/levels/level 0/light.png"),
parent=self.light_structure)
self.light = PointLight(position=(self.x - wall_spacing, 4, self.z - wall_spacing), shadows=True, parent=self.light_structure)
left_rand = random.randint(0, 2)
if left_rand == 1:
self.place_door(self.x, self.y, self.z - wall_spacing, True)
elif left_rand == 2:
self.place_wall(self.x, self.y, self.z - wall_spacing, True)
else:
pass
top_rand = random.randint(0, 2)
if top_rand == 1:
self.place_door(self.x + wall_spacing, self.y, self.z, False)
elif top_rand == 2:
self.place_wall(self.x + wall_spacing, self.y, self.z, False)
else:
pass
self.structure.combine()
self.structure.texture = "resources/levels/level 0/wall.png"
self.structure.shader = basic_lighting_shader