-
Notifications
You must be signed in to change notification settings - Fork 0
/
world.py
37 lines (28 loc) · 1.06 KB
/
world.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
from settings import *
from world_objects.chunk import Chunk
class World:
def __init__(self, app):
self.app = app
self.chunks = [None for _ in range(WORLD_VOL)]
self.voxels = np.empty([WORLD_VOL, CHUNK_VOL], 'uint8')
self.build_chunks()
self.build_chunk_mesh()
def build_chunks(self):
for x in range(WORLD_W):
for z in range(WORLD_D):
for y in range(WORLD_H):
chunk = Chunk(self, position=(x, y, z))
chunk_index = x + WORLD_W * z + WORLD_AREA * y
self.chunks[chunk_index] = chunk
# put the chunk voxels in a separate array
self.voxels[chunk_index] = chunk.build_voxels()
# get pointer to voxels
chunk.voxels = self.voxels[chunk_index]
def build_chunk_mesh(self):
for chunk in self.chunks:
chunk.build_mesh()
def update(self):
pass
def render(self):
for chunk in self.chunks:
chunk.render()