diff --git a/community/options.py b/community/options.py index cdd5dbe..d1b4d8c 100644 --- a/community/options.py +++ b/community/options.py @@ -31,9 +31,7 @@ # Recommended values are between 0 and 9 # Legacy Smooth FPS -SMOOTH_FPS = ( - False # Legacy way to force the flushing of command buffer and forces the CPU to wait for the GPU to finish rendering. -) +SMOOTH_FPS = False # Legacy way to force the flushing of command buffer and forces the CPU to wait for the GPU to finish rendering. # Incompatible Max CPU Ahead Frames (it won't be effective) # Enable this to test whether its impact is better. Similar to Max CPU Ahead frames to 0 diff --git a/community/save.py b/community/save.py index b9e58ab..2027e94 100644 --- a/community/save.py +++ b/community/save.py @@ -68,11 +68,9 @@ def save_chunk(self, chunk_position): for x in range(chunk.CHUNK_WIDTH): for y in range(chunk.CHUNK_HEIGHT): for z in range(chunk.CHUNK_LENGTH): - chunk_blocks[ - x * chunk.CHUNK_LENGTH * chunk.CHUNK_HEIGHT + z * chunk.CHUNK_HEIGHT + y - ] = self.world.chunks[ - chunk_position - ].blocks[x][y][z] + chunk_blocks[x * chunk.CHUNK_LENGTH * chunk.CHUNK_HEIGHT + z * chunk.CHUNK_HEIGHT + y] = ( + self.world.chunks[chunk_position].blocks[x][y][z] + ) # save the chunk file diff --git a/episode-11/save.py b/episode-11/save.py index 6125a86..7d75249 100644 --- a/episode-11/save.py +++ b/episode-11/save.py @@ -64,11 +64,9 @@ def save_chunk(self, chunk_position): for x in range(chunk.CHUNK_WIDTH): for y in range(chunk.CHUNK_HEIGHT): for z in range(chunk.CHUNK_LENGTH): - chunk_blocks[ - x * chunk.CHUNK_LENGTH * chunk.CHUNK_HEIGHT + z * chunk.CHUNK_HEIGHT + y - ] = self.world.chunks[ - chunk_position - ].blocks[x][y][z] + chunk_blocks[x * chunk.CHUNK_LENGTH * chunk.CHUNK_HEIGHT + z * chunk.CHUNK_HEIGHT + y] = ( + self.world.chunks[chunk_position].blocks[x][y][z] + ) # save the chunk file diff --git a/episode-12/save.py b/episode-12/save.py index 198a2a8..0d4f25e 100644 --- a/episode-12/save.py +++ b/episode-12/save.py @@ -64,11 +64,9 @@ def save_chunk(self, chunk_position): for x in range(chunk.CHUNK_WIDTH): for y in range(chunk.CHUNK_HEIGHT): for z in range(chunk.CHUNK_LENGTH): - chunk_blocks[ - x * chunk.CHUNK_LENGTH * chunk.CHUNK_HEIGHT + z * chunk.CHUNK_HEIGHT + y - ] = self.world.chunks[ - chunk_position - ].blocks[x][y][z] + chunk_blocks[x * chunk.CHUNK_LENGTH * chunk.CHUNK_HEIGHT + z * chunk.CHUNK_HEIGHT + y] = ( + self.world.chunks[chunk_position].blocks[x][y][z] + ) # save the chunk file diff --git a/episode-13/main.py b/episode-13/main.py index 645d084..3503386 100644 --- a/episode-13/main.py +++ b/episode-13/main.py @@ -208,7 +208,12 @@ class Game: def __init__(self): self.config = gl.Config(double_buffer=True, major_version=3, minor_version=3, depth_size=16) self.window = Window( - config=self.config, width=800, height=600, caption="Minecraft clone", resizable=True, vsync=False + config=self.config, + width=800, + height=600, + caption="Minecraft clone", + resizable=True, + vsync=False, ) def run(self): diff --git a/episode-13/models/cactus.py b/episode-13/models/cactus.py index b0d1835..3ea563e 100644 --- a/episode-13/models/cactus.py +++ b/episode-13/models/cactus.py @@ -5,12 +5,90 @@ colliders = [[(-0.4375, -0.5, -0.4375), (0.4375, 0.5, 0.4375)]] vertex_positions = [ - [0.4375, 0.5000, 0.5000, 0.4375, -0.5000, 0.5000, 0.4375, -0.5000, -0.5000, 0.4375, 0.5000, -0.5000], # right - [-0.4375, 0.5000, -0.5000, -0.4375, -0.5000, -0.5000, -0.4375, -0.5000, 0.5000, -0.4375, 0.5000, 0.5000], # left - [0.5000, 0.5000, 0.5000, 0.5000, 0.5000, -0.5000, -0.5000, 0.5000, -0.5000, -0.5000, 0.5000, 0.5000], # top - [-0.5000, -0.5000, 0.5000, -0.5000, -0.5000, -0.5000, 0.5000, -0.5000, -0.5000, 0.5000, -0.5000, 0.5000], # bottom - [-0.5000, 0.5000, 0.4375, -0.5000, -0.5000, 0.4375, 0.5000, -0.5000, 0.4375, 0.5000, 0.5000, 0.4375], # front - [0.5000, 0.5000, -0.4375, 0.5000, -0.5000, -0.4375, -0.5000, -0.5000, -0.4375, -0.5000, 0.5000, -0.4375], # back + [ + 0.4375, + 0.5000, + 0.5000, + 0.4375, + -0.5000, + 0.5000, + 0.4375, + -0.5000, + -0.5000, + 0.4375, + 0.5000, + -0.5000, + ], # right + [ + -0.4375, + 0.5000, + -0.5000, + -0.4375, + -0.5000, + -0.5000, + -0.4375, + -0.5000, + 0.5000, + -0.4375, + 0.5000, + 0.5000, + ], # left + [ + 0.5000, + 0.5000, + 0.5000, + 0.5000, + 0.5000, + -0.5000, + -0.5000, + 0.5000, + -0.5000, + -0.5000, + 0.5000, + 0.5000, + ], # top + [ + -0.5000, + -0.5000, + 0.5000, + -0.5000, + -0.5000, + -0.5000, + 0.5000, + -0.5000, + -0.5000, + 0.5000, + -0.5000, + 0.5000, + ], # bottom + [ + -0.5000, + 0.5000, + 0.4375, + -0.5000, + -0.5000, + 0.4375, + 0.5000, + -0.5000, + 0.4375, + 0.5000, + 0.5000, + 0.4375, + ], # front + [ + 0.5000, + 0.5000, + -0.4375, + 0.5000, + -0.5000, + -0.4375, + -0.5000, + -0.5000, + -0.4375, + -0.5000, + 0.5000, + -0.4375, + ], # back ] tex_coords = [ diff --git a/episode-13/models/crop.py b/episode-13/models/crop.py index 65d9373..65cd735 100644 --- a/episode-13/models/crop.py +++ b/episode-13/models/crop.py @@ -5,14 +5,118 @@ colliders = [] vertex_positions = [ - [0.25, 0.4375, 0.50, 0.25, -0.5625, 0.50, 0.25, -0.5625, -0.50, 0.25, 0.4375, -0.50], # right - [0.25, 0.4375, -0.50, 0.25, -0.5625, -0.50, 0.25, -0.5625, 0.50, 0.25, 0.4375, 0.50], # right - [-0.25, 0.4375, -0.50, -0.25, -0.5625, -0.50, -0.25, -0.5625, 0.50, -0.25, 0.4375, 0.50], # left - [-0.25, 0.4375, 0.50, -0.25, -0.5625, 0.50, -0.25, -0.5625, -0.50, -0.25, 0.4375, -0.50], # left - [-0.50, 0.4375, 0.25, -0.50, -0.5625, 0.25, 0.50, -0.5625, 0.25, 0.50, 0.4375, 0.25], # front - [0.50, 0.4375, 0.25, 0.50, -0.5625, 0.25, -0.50, -0.5625, 0.25, -0.50, 0.4375, 0.25], # front - [0.50, 0.4375, -0.25, 0.50, -0.5625, -0.25, -0.50, -0.5625, -0.25, -0.50, 0.4375, -0.25], # back - [-0.50, 0.4375, -0.25, -0.50, -0.5625, -0.25, 0.50, -0.5625, -0.25, 0.50, 0.4375, -0.25], # back + [ + 0.25, + 0.4375, + 0.50, + 0.25, + -0.5625, + 0.50, + 0.25, + -0.5625, + -0.50, + 0.25, + 0.4375, + -0.50, + ], # right + [ + 0.25, + 0.4375, + -0.50, + 0.25, + -0.5625, + -0.50, + 0.25, + -0.5625, + 0.50, + 0.25, + 0.4375, + 0.50, + ], # right + [ + -0.25, + 0.4375, + -0.50, + -0.25, + -0.5625, + -0.50, + -0.25, + -0.5625, + 0.50, + -0.25, + 0.4375, + 0.50, + ], # left + [ + -0.25, + 0.4375, + 0.50, + -0.25, + -0.5625, + 0.50, + -0.25, + -0.5625, + -0.50, + -0.25, + 0.4375, + -0.50, + ], # left + [ + -0.50, + 0.4375, + 0.25, + -0.50, + -0.5625, + 0.25, + 0.50, + -0.5625, + 0.25, + 0.50, + 0.4375, + 0.25, + ], # front + [ + 0.50, + 0.4375, + 0.25, + 0.50, + -0.5625, + 0.25, + -0.50, + -0.5625, + 0.25, + -0.50, + 0.4375, + 0.25, + ], # front + [ + 0.50, + 0.4375, + -0.25, + 0.50, + -0.5625, + -0.25, + -0.50, + -0.5625, + -0.25, + -0.50, + 0.4375, + -0.25, + ], # back + [ + -0.50, + 0.4375, + -0.25, + -0.50, + -0.5625, + -0.25, + 0.50, + -0.5625, + -0.25, + 0.50, + 0.4375, + -0.25, + ], # back ] tex_coords = [ diff --git a/episode-13/models/fire.py b/episode-13/models/fire.py index dde4c2d..39db455 100644 --- a/episode-13/models/fire.py +++ b/episode-13/models/fire.py @@ -5,10 +5,62 @@ colliders = [] vertex_positions = [ - [-0.3536, 0.5000, 0.3536, -0.3536, -0.5000, 0.3536, 0.3536, -0.5000, -0.3536, 0.3536, 0.5000, -0.3536], - [-0.3536, 0.5000, -0.3536, -0.3536, -0.5000, -0.3536, 0.3536, -0.5000, 0.3536, 0.3536, 0.5000, 0.3536], - [0.3536, 0.5000, -0.3536, 0.3536, -0.5000, -0.3536, -0.3536, -0.5000, 0.3536, -0.3536, 0.5000, 0.3536], - [0.3536, 0.5000, 0.3536, 0.3536, -0.5000, 0.3536, -0.3536, -0.5000, -0.3536, -0.3536, 0.5000, -0.3536], + [ + -0.3536, + 0.5000, + 0.3536, + -0.3536, + -0.5000, + 0.3536, + 0.3536, + -0.5000, + -0.3536, + 0.3536, + 0.5000, + -0.3536, + ], + [ + -0.3536, + 0.5000, + -0.3536, + -0.3536, + -0.5000, + -0.3536, + 0.3536, + -0.5000, + 0.3536, + 0.3536, + 0.5000, + 0.3536, + ], + [ + 0.3536, + 0.5000, + -0.3536, + 0.3536, + -0.5000, + -0.3536, + -0.3536, + -0.5000, + 0.3536, + -0.3536, + 0.5000, + 0.3536, + ], + [ + 0.3536, + 0.5000, + 0.3536, + 0.3536, + -0.5000, + 0.3536, + -0.3536, + -0.5000, + -0.3536, + -0.3536, + 0.5000, + -0.3536, + ], ] tex_coords = [ diff --git a/episode-13/models/flat.py b/episode-13/models/flat.py index dfe9c72..b9cce78 100644 --- a/episode-13/models/flat.py +++ b/episode-13/models/flat.py @@ -5,8 +5,34 @@ colliders = [] vertex_positions = [ - [0.5, -0.4375, 0.5, 0.5, -0.4375, -0.5, -0.5, -0.4375, -0.5, -0.5, -0.4375, 0.5], # top - [-0.5, -0.4375, 0.5, -0.5, -0.4375, -0.5, 0.5, -0.4375, -0.5, 0.5, -0.4375, 0.5], # bottom + [ + 0.5, + -0.4375, + 0.5, + 0.5, + -0.4375, + -0.5, + -0.5, + -0.4375, + -0.5, + -0.5, + -0.4375, + 0.5, + ], # top + [ + -0.5, + -0.4375, + 0.5, + -0.5, + -0.4375, + -0.5, + 0.5, + -0.4375, + -0.5, + 0.5, + -0.4375, + 0.5, + ], # bottom ] tex_coords = [ diff --git a/episode-13/models/ladder.py b/episode-13/models/ladder.py index dde4c2d..39db455 100644 --- a/episode-13/models/ladder.py +++ b/episode-13/models/ladder.py @@ -5,10 +5,62 @@ colliders = [] vertex_positions = [ - [-0.3536, 0.5000, 0.3536, -0.3536, -0.5000, 0.3536, 0.3536, -0.5000, -0.3536, 0.3536, 0.5000, -0.3536], - [-0.3536, 0.5000, -0.3536, -0.3536, -0.5000, -0.3536, 0.3536, -0.5000, 0.3536, 0.3536, 0.5000, 0.3536], - [0.3536, 0.5000, -0.3536, 0.3536, -0.5000, -0.3536, -0.3536, -0.5000, 0.3536, -0.3536, 0.5000, 0.3536], - [0.3536, 0.5000, 0.3536, 0.3536, -0.5000, 0.3536, -0.3536, -0.5000, -0.3536, -0.3536, 0.5000, -0.3536], + [ + -0.3536, + 0.5000, + 0.3536, + -0.3536, + -0.5000, + 0.3536, + 0.3536, + -0.5000, + -0.3536, + 0.3536, + 0.5000, + -0.3536, + ], + [ + -0.3536, + 0.5000, + -0.3536, + -0.3536, + -0.5000, + -0.3536, + 0.3536, + -0.5000, + 0.3536, + 0.3536, + 0.5000, + 0.3536, + ], + [ + 0.3536, + 0.5000, + -0.3536, + 0.3536, + -0.5000, + -0.3536, + -0.3536, + -0.5000, + 0.3536, + -0.3536, + 0.5000, + 0.3536, + ], + [ + 0.3536, + 0.5000, + 0.3536, + 0.3536, + -0.5000, + 0.3536, + -0.3536, + -0.5000, + -0.3536, + -0.3536, + 0.5000, + -0.3536, + ], ] tex_coords = [ diff --git a/episode-13/models/liquid.py b/episode-13/models/liquid.py index 693638b..3926c43 100644 --- a/episode-13/models/liquid.py +++ b/episode-13/models/liquid.py @@ -8,12 +8,90 @@ colliders = [] vertex_positions = [ - [0.500, 0.375, 0.500, 0.500, -0.625, 0.500, 0.500, -0.625, -0.500, 0.500, 0.375, -0.500], # right - [-0.500, 0.375, -0.500, -0.500, -0.625, -0.500, -0.500, -0.625, 0.500, -0.500, 0.375, 0.500], # left - [0.500, 0.375, 0.500, 0.500, 0.375, -0.500, -0.500, 0.375, -0.500, -0.500, 0.375, 0.500], # top - [-0.500, -0.625, 0.500, -0.500, -0.625, -0.500, 0.500, -0.625, -0.500, 0.500, -0.625, 0.500], # bottom - [-0.500, 0.375, 0.500, -0.500, -0.625, 0.500, 0.500, -0.625, 0.500, 0.500, 0.375, 0.500], # front - [0.500, 0.375, -0.500, 0.500, -0.625, -0.500, -0.500, -0.625, -0.500, -0.500, 0.375, -0.500], # back + [ + 0.500, + 0.375, + 0.500, + 0.500, + -0.625, + 0.500, + 0.500, + -0.625, + -0.500, + 0.500, + 0.375, + -0.500, + ], # right + [ + -0.500, + 0.375, + -0.500, + -0.500, + -0.625, + -0.500, + -0.500, + -0.625, + 0.500, + -0.500, + 0.375, + 0.500, + ], # left + [ + 0.500, + 0.375, + 0.500, + 0.500, + 0.375, + -0.500, + -0.500, + 0.375, + -0.500, + -0.500, + 0.375, + 0.500, + ], # top + [ + -0.500, + -0.625, + 0.500, + -0.500, + -0.625, + -0.500, + 0.500, + -0.625, + -0.500, + 0.500, + -0.625, + 0.500, + ], # bottom + [ + -0.500, + 0.375, + 0.500, + -0.500, + -0.625, + 0.500, + 0.500, + -0.625, + 0.500, + 0.500, + 0.375, + 0.500, + ], # front + [ + 0.500, + 0.375, + -0.500, + 0.500, + -0.625, + -0.500, + -0.500, + -0.625, + -0.500, + -0.500, + 0.375, + -0.500, + ], # back ] tex_coords = [ diff --git a/episode-13/models/plant.py b/episode-13/models/plant.py index dde4c2d..39db455 100644 --- a/episode-13/models/plant.py +++ b/episode-13/models/plant.py @@ -5,10 +5,62 @@ colliders = [] vertex_positions = [ - [-0.3536, 0.5000, 0.3536, -0.3536, -0.5000, 0.3536, 0.3536, -0.5000, -0.3536, 0.3536, 0.5000, -0.3536], - [-0.3536, 0.5000, -0.3536, -0.3536, -0.5000, -0.3536, 0.3536, -0.5000, 0.3536, 0.3536, 0.5000, 0.3536], - [0.3536, 0.5000, -0.3536, 0.3536, -0.5000, -0.3536, -0.3536, -0.5000, 0.3536, -0.3536, 0.5000, 0.3536], - [0.3536, 0.5000, 0.3536, 0.3536, -0.5000, 0.3536, -0.3536, -0.5000, -0.3536, -0.3536, 0.5000, -0.3536], + [ + -0.3536, + 0.5000, + 0.3536, + -0.3536, + -0.5000, + 0.3536, + 0.3536, + -0.5000, + -0.3536, + 0.3536, + 0.5000, + -0.3536, + ], + [ + -0.3536, + 0.5000, + -0.3536, + -0.3536, + -0.5000, + -0.3536, + 0.3536, + -0.5000, + 0.3536, + 0.3536, + 0.5000, + 0.3536, + ], + [ + 0.3536, + 0.5000, + -0.3536, + 0.3536, + -0.5000, + -0.3536, + -0.3536, + -0.5000, + 0.3536, + -0.3536, + 0.5000, + 0.3536, + ], + [ + 0.3536, + 0.5000, + 0.3536, + 0.3536, + -0.5000, + 0.3536, + -0.3536, + -0.5000, + -0.3536, + -0.3536, + 0.5000, + -0.3536, + ], ] tex_coords = [ diff --git a/episode-13/models/pressure_plate.py b/episode-13/models/pressure_plate.py index dfe9c72..b9cce78 100644 --- a/episode-13/models/pressure_plate.py +++ b/episode-13/models/pressure_plate.py @@ -5,8 +5,34 @@ colliders = [] vertex_positions = [ - [0.5, -0.4375, 0.5, 0.5, -0.4375, -0.5, -0.5, -0.4375, -0.5, -0.5, -0.4375, 0.5], # top - [-0.5, -0.4375, 0.5, -0.5, -0.4375, -0.5, 0.5, -0.4375, -0.5, 0.5, -0.4375, 0.5], # bottom + [ + 0.5, + -0.4375, + 0.5, + 0.5, + -0.4375, + -0.5, + -0.5, + -0.4375, + -0.5, + -0.5, + -0.4375, + 0.5, + ], # top + [ + -0.5, + -0.4375, + 0.5, + -0.5, + -0.4375, + -0.5, + 0.5, + -0.4375, + -0.5, + 0.5, + -0.4375, + 0.5, + ], # bottom ] tex_coords = [ diff --git a/episode-13/models/sign.py b/episode-13/models/sign.py index dde4c2d..39db455 100644 --- a/episode-13/models/sign.py +++ b/episode-13/models/sign.py @@ -5,10 +5,62 @@ colliders = [] vertex_positions = [ - [-0.3536, 0.5000, 0.3536, -0.3536, -0.5000, 0.3536, 0.3536, -0.5000, -0.3536, 0.3536, 0.5000, -0.3536], - [-0.3536, 0.5000, -0.3536, -0.3536, -0.5000, -0.3536, 0.3536, -0.5000, 0.3536, 0.3536, 0.5000, 0.3536], - [0.3536, 0.5000, -0.3536, 0.3536, -0.5000, -0.3536, -0.3536, -0.5000, 0.3536, -0.3536, 0.5000, 0.3536], - [0.3536, 0.5000, 0.3536, 0.3536, -0.5000, 0.3536, -0.3536, -0.5000, -0.3536, -0.3536, 0.5000, -0.3536], + [ + -0.3536, + 0.5000, + 0.3536, + -0.3536, + -0.5000, + 0.3536, + 0.3536, + -0.5000, + -0.3536, + 0.3536, + 0.5000, + -0.3536, + ], + [ + -0.3536, + 0.5000, + -0.3536, + -0.3536, + -0.5000, + -0.3536, + 0.3536, + -0.5000, + 0.3536, + 0.3536, + 0.5000, + 0.3536, + ], + [ + 0.3536, + 0.5000, + -0.3536, + 0.3536, + -0.5000, + -0.3536, + -0.3536, + -0.5000, + 0.3536, + -0.3536, + 0.5000, + 0.3536, + ], + [ + 0.3536, + 0.5000, + 0.3536, + 0.3536, + -0.5000, + 0.3536, + -0.3536, + -0.5000, + -0.3536, + -0.3536, + 0.5000, + -0.3536, + ], ] tex_coords = [ diff --git a/episode-13/models/sign_post.py b/episode-13/models/sign_post.py index dde4c2d..39db455 100644 --- a/episode-13/models/sign_post.py +++ b/episode-13/models/sign_post.py @@ -5,10 +5,62 @@ colliders = [] vertex_positions = [ - [-0.3536, 0.5000, 0.3536, -0.3536, -0.5000, 0.3536, 0.3536, -0.5000, -0.3536, 0.3536, 0.5000, -0.3536], - [-0.3536, 0.5000, -0.3536, -0.3536, -0.5000, -0.3536, 0.3536, -0.5000, 0.3536, 0.3536, 0.5000, 0.3536], - [0.3536, 0.5000, -0.3536, 0.3536, -0.5000, -0.3536, -0.3536, -0.5000, 0.3536, -0.3536, 0.5000, 0.3536], - [0.3536, 0.5000, 0.3536, 0.3536, -0.5000, 0.3536, -0.3536, -0.5000, -0.3536, -0.3536, 0.5000, -0.3536], + [ + -0.3536, + 0.5000, + 0.3536, + -0.3536, + -0.5000, + 0.3536, + 0.3536, + -0.5000, + -0.3536, + 0.3536, + 0.5000, + -0.3536, + ], + [ + -0.3536, + 0.5000, + -0.3536, + -0.3536, + -0.5000, + -0.3536, + 0.3536, + -0.5000, + 0.3536, + 0.3536, + 0.5000, + 0.3536, + ], + [ + 0.3536, + 0.5000, + -0.3536, + 0.3536, + -0.5000, + -0.3536, + -0.3536, + -0.5000, + 0.3536, + -0.3536, + 0.5000, + 0.3536, + ], + [ + 0.3536, + 0.5000, + 0.3536, + 0.3536, + -0.5000, + 0.3536, + -0.3536, + -0.5000, + -0.3536, + -0.3536, + 0.5000, + -0.3536, + ], ] tex_coords = [ diff --git a/episode-13/models/snow.py b/episode-13/models/snow.py index 2a39aff..f77595d 100644 --- a/episode-13/models/snow.py +++ b/episode-13/models/snow.py @@ -5,8 +5,34 @@ colliders = [[(-0.5, -0.5000, -0.5), (0.5, -0.4375, 0.5)]] vertex_positions = [ - [0.5, -0.4375, 0.5, 0.5, -0.4375, -0.5, -0.5, -0.4375, -0.5, -0.5, -0.4375, 0.5], # top - [-0.5, -0.4375, 0.5, -0.5, -0.4375, -0.5, 0.5, -0.4375, -0.5, 0.5, -0.4375, 0.5], # bottom + [ + 0.5, + -0.4375, + 0.5, + 0.5, + -0.4375, + -0.5, + -0.5, + -0.4375, + -0.5, + -0.5, + -0.4375, + 0.5, + ], # top + [ + -0.5, + -0.4375, + 0.5, + -0.5, + -0.4375, + -0.5, + 0.5, + -0.4375, + -0.5, + 0.5, + -0.4375, + 0.5, + ], # bottom ] tex_coords = [ diff --git a/episode-13/models/torch.py b/episode-13/models/torch.py index cda41d2..2db2d26 100644 --- a/episode-13/models/torch.py +++ b/episode-13/models/torch.py @@ -5,12 +5,64 @@ colliders = [] vertex_positions = [ - [0.0625, 0.5, 0.5, 0.0625, -0.5, 0.5, 0.0625, -0.5, -0.5, 0.0625, 0.5, -0.5], # right - [-0.0625, 0.5, -0.5, -0.0625, -0.5, -0.5, -0.0625, -0.5, 0.5, -0.0625, 0.5, 0.5], # left + [ + 0.0625, + 0.5, + 0.5, + 0.0625, + -0.5, + 0.5, + 0.0625, + -0.5, + -0.5, + 0.0625, + 0.5, + -0.5, + ], # right + [ + -0.0625, + 0.5, + -0.5, + -0.0625, + -0.5, + -0.5, + -0.0625, + -0.5, + 0.5, + -0.0625, + 0.5, + 0.5, + ], # left [0.5, 0.125, 0.5, 0.5, 0.125, -0.5, -0.5, 0.125, -0.5, -0.5, 0.125, 0.5], # top [-0.5, -0.5, 0.5, -0.5, -0.5, -0.5, 0.5, -0.5, -0.5, 0.5, -0.5, 0.5], # bottom - [-0.5, 0.5, 0.0625, -0.5, -0.5, 0.0625, 0.5, -0.5, 0.0625, 0.5, 0.5, 0.0625], # front - [0.5, 0.5, -0.0625, 0.5, -0.5, -0.0625, -0.5, -0.5, -0.0625, -0.5, 0.5, -0.0625], # back + [ + -0.5, + 0.5, + 0.0625, + -0.5, + -0.5, + 0.0625, + 0.5, + -0.5, + 0.0625, + 0.5, + 0.5, + 0.0625, + ], # front + [ + 0.5, + 0.5, + -0.0625, + 0.5, + -0.5, + -0.0625, + -0.5, + -0.5, + -0.0625, + -0.5, + 0.5, + -0.0625, + ], # back ] tex_coords = [ diff --git a/episode-13/src/chunk/chunk.py b/episode-13/src/chunk/chunk.py index 91d07b0..b2049a2 100644 --- a/episode-13/src/chunk/chunk.py +++ b/episode-13/src/chunk/chunk.py @@ -3,7 +3,12 @@ import pyglet.gl as gl -from src.chunk.subchunk import SUBCHUNK_HEIGHT, SUBCHUNK_LENGTH, SUBCHUNK_WIDTH, Subchunk +from src.chunk.subchunk import ( + SUBCHUNK_HEIGHT, + SUBCHUNK_LENGTH, + SUBCHUNK_WIDTH, + Subchunk, +) CHUNK_WIDTH = 16 CHUNK_HEIGHT = 128 diff --git a/episode-13/src/chunk/subchunk.py b/episode-13/src/chunk/subchunk.py index 4ef16a7..1683a96 100644 --- a/episode-13/src/chunk/subchunk.py +++ b/episode-13/src/chunk/subchunk.py @@ -71,7 +71,11 @@ def add_face(face): if block_number: block_type = self.world.block_types[block_number] - x, y, z = (self.position[0] + local_x, self.position[1] + local_y, self.position[2] + local_z) + x, y, z = ( + self.position[0] + local_x, + self.position[1] + local_y, + self.position[2] + local_z, + ) def can_render_face(position): if not self.world.is_opaque_block(position): diff --git a/episode-13/src/entity/entity.py b/episode-13/src/entity/entity.py index 5bad89d..d3ed3ee 100644 --- a/episode-13/src/entity/entity.py +++ b/episode-13/src/entity/entity.py @@ -109,7 +109,11 @@ def update(self, delta_time): for i in range(x - step_x * (steps_xz + 1), cx + step_x * (steps_xz + 2), step_x): for j in range(y - step_y * (steps_y + 2), cy + step_y * (steps_y + 3), step_y): - for k in range(z - step_z * (steps_xz + 1), cz + step_z * (steps_xz + 2), step_z): + for k in range( + z - step_z * (steps_xz + 1), + cz + step_z * (steps_xz + 2), + step_z, + ): pos = (i, j, k) num = self.world.get_block_number(pos) diff --git a/episode-13/src/physics/collider.py b/episode-13/src/physics/collider.py index 75dbd8d..7d4f114 100644 --- a/episode-13/src/physics/collider.py +++ b/episode-13/src/physics/collider.py @@ -9,7 +9,10 @@ def __init__(self, pos1=(None,) * 3, pos2=(None,) * 3): def __add__(self, pos): x, y, z = pos - return Collider((self.x1 + x, self.y1 + y, self.z1 + z), (self.x2 + x, self.y2 + y, self.z2 + z)) + return Collider( + (self.x1 + x, self.y1 + y, self.z1 + z), + (self.x2 + x, self.y2 + y, self.z2 + z), + ) def __and__(self, collider): x = min(self.x2, collider.x2) - max(self.x1, collider.x1) diff --git a/episode-13/src/renderer/block_type.py b/episode-13/src/renderer/block_type.py index 395cdd7..3f5ac0a 100644 --- a/episode-13/src/renderer/block_type.py +++ b/episode-13/src/renderer/block_type.py @@ -6,7 +6,11 @@ class BlockType: # new optional model argument (cube model by default) def __init__( - self, texture_manager, name="unknown", block_face_textures={"all": "cobblestone"}, model: Any = models.cube + self, + texture_manager, + name="unknown", + block_face_textures={"all": "cobblestone"}, + model: Any = models.cube, ): self.name = name self.block_face_textures = block_face_textures @@ -71,4 +75,7 @@ def set_block_face(face, texture): set_block_face(5, texture_index) else: - set_block_face(["right", "left", "top", "bottom", "front", "back"].index(face), texture_index) + set_block_face( + ["right", "left", "top", "bottom", "front", "back"].index(face), + texture_index, + ) diff --git a/episode-13/src/renderer/matrix.py b/episode-13/src/renderer/matrix.py index 16ecf04..b3b965f 100644 --- a/episode-13/src/renderer/matrix.py +++ b/episode-13/src/renderer/matrix.py @@ -127,7 +127,14 @@ def perspective(self, fovy, aspect, near, far): frustum_y = math.tan(math.radians(fovy) / 2) frustum_x = frustum_y * aspect - self.frustum(-frustum_x * near, frustum_x * near, -frustum_y * near, frustum_y * near, near, far) + self.frustum( + -frustum_x * near, + frustum_x * near, + -frustum_y * near, + frustum_y * near, + near, + far, + ) def orthographic(self, left, right, bottom, top, near, far): deltax = right - left diff --git a/episode-13/src/renderer/shader.py b/episode-13/src/renderer/shader.py index 5c48a41..610c710 100644 --- a/episode-13/src/renderer/shader.py +++ b/episode-13/src/renderer/shader.py @@ -2,8 +2,7 @@ import pyglet.gl as gl -class ShaderError(Exception): - ... +class ShaderError(Exception): ... def create_shader(target, source_path): @@ -16,7 +15,8 @@ def create_shader(target, source_path): source_buffer = ctypes.create_string_buffer(source) buffer_pointer = ctypes.cast( - ctypes.pointer(ctypes.pointer(source_buffer)), ctypes.POINTER(ctypes.POINTER(ctypes.c_char)) + ctypes.pointer(ctypes.pointer(source_buffer)), + ctypes.POINTER(ctypes.POINTER(ctypes.c_char)), ) # compile shader diff --git a/episode-13/src/save.py b/episode-13/src/save.py index d38522a..9fbc40a 100644 --- a/episode-13/src/save.py +++ b/episode-13/src/save.py @@ -13,7 +13,12 @@ def chunk_position_to_path(self, chunk_position): x, _, z = chunk_position chunk_path = "/".join( - (self.path, base36.dumps(x % 64), base36.dumps(z % 64), f"c.{base36.dumps(x)}.{base36.dumps(z)}.dat") + ( + self.path, + base36.dumps(x % 64), + base36.dumps(z % 64), + f"c.{base36.dumps(x)}.{base36.dumps(z)}.dat", + ) ) return chunk_path diff --git a/episode-5/block_type.py b/episode-5/block_type.py index a931fce..a78bbbb 100644 --- a/episode-5/block_type.py +++ b/episode-5/block_type.py @@ -8,9 +8,7 @@ def __init__(self, texture_manager, name="unknown", block_face_textures={"all": # set our block type's vertex positions, texture coordinates, and indices to the default values in our numbers.py file self.vertex_positions = numbers.vertex_positions - self.tex_coords = ( - numbers.tex_coords.copy() - ) # we need to create a copy of this, since we need to modify our texture coordinates in a different way for each block type (to have different textures per block) + self.tex_coords = numbers.tex_coords.copy() # we need to create a copy of this, since we need to modify our texture coordinates in a different way for each block type (to have different textures per block) self.indices = numbers.indices def set_block_face(face, texture): # set a specific face of the block to a certain texture