Skip to content

Commit

Permalink
community: Formatting fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
obiwac committed Aug 10, 2024
1 parent fe636fb commit a44acb0
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 75 deletions.
16 changes: 8 additions & 8 deletions community/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,11 +151,11 @@ def __init__(self, **args):
if len(self.music) > 0:
self.media_player.queue(random.choice(self.music))
self.media_player.play()
self.media_player.standby = False # pyright: ignore
self.media_player.standby = False # pyright: ignore
else:
self.media_player.standby = True # pyright: ignore
self.media_player.standby = True # pyright: ignore

self.media_player.next_time = 0 # pyright: ignore
self.media_player.next_time = 0 # pyright: ignore

# GPU command syncs
self.fences = deque()
Expand Down Expand Up @@ -205,11 +205,11 @@ def update(self, delta_time):
self.update_f3(delta_time)

if not self.media_player.source and len(self.music) > 0:
if not self.media_player.standby: # pyright: ignore
self.media_player.standby = True # pyright: ignore
self.media_player.next_time = time.time() + random.randint(240, 360) # pyright: ignore
elif time.time() >= self.media_player.next_time: # pyright: ignore
self.media_player.standby = False # pyright: ignore
if not self.media_player.standby: # pyright: ignore
self.media_player.standby = True # pyright: ignore
self.media_player.next_time = time.time() + random.randint(240, 360) # pyright: ignore
elif time.time() >= self.media_player.next_time: # pyright: ignore
self.media_player.standby = False # pyright: ignore
self.media_player.queue(random.choice(self.music))
self.media_player.play()

Expand Down
12 changes: 6 additions & 6 deletions community/src/entity/entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,16 @@ def __init__(self, world):
self.jump_height = 1.25
self.flying = False

self.position = [0., 80., 0.]
self.rotation = [-math.tau / 4, 0.]
self.position = [0.0, 80.0, 0.0]
self.rotation = [-math.tau / 4, 0.0]

self.old_position = tuple(self.position)
self.old_rotation = tuple(self.rotation)

self.step = 1

self.velocity = [0., 0., 0.]
self.accel = [0., 0., 0.]
self.velocity = [0.0, 0.0, 0.0]
self.accel = [0.0, 0.0, 0.0]

# collision variables

Expand All @@ -56,7 +56,7 @@ def update_collider(self):

def teleport(self, pos: list[float]):
self.position = list(pos)
self.velocity = [0., 0., 0.] # to prevent collisions
self.velocity = [0.0, 0.0, 0.0] # to prevent collisions

def jump(self, height=None):
# obviously, we can't initiate a jump while in mid-air
Expand Down Expand Up @@ -89,7 +89,7 @@ def update(self, delta_time: float):
# apply input acceleration, and adjust for friction/drag

self.velocity = [v + a * f * delta_time for v, a, f in zip(self.velocity, self.accel, self.friction)]
self.accel = [0., 0., 0.]
self.accel = [0.0, 0.0, 0.0]

# compute collisions

Expand Down
64 changes: 8 additions & 56 deletions community/src/entity/player.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,83 +122,35 @@ def check_in_frustum(self, chunk_pos):
_out = 0
normal = plane.xyz
w = plane.w
if (
glm.dot(
normal, center + glm.vec3(CHUNK_WIDTH / 2, CHUNK_HEIGHT / 2, CHUNK_LENGTH / 2)
)
+ w
< 0
):
if glm.dot(normal, center + glm.vec3(CHUNK_WIDTH / 2, CHUNK_HEIGHT / 2, CHUNK_LENGTH / 2)) + w < 0:
_out += 1
else:
_in += 1
if (
glm.dot(
normal, center + glm.vec3(-CHUNK_WIDTH / 2, CHUNK_HEIGHT / 2, CHUNK_LENGTH / 2)
)
+ w
< 0
):
if glm.dot(normal, center + glm.vec3(-CHUNK_WIDTH / 2, CHUNK_HEIGHT / 2, CHUNK_LENGTH / 2)) + w < 0:
_out += 1
else:
_in += 1
if (
glm.dot(
normal, center + glm.vec3(CHUNK_WIDTH / 2, CHUNK_HEIGHT / 2, -CHUNK_LENGTH / 2)
)
+ w
< 0
):
if glm.dot(normal, center + glm.vec3(CHUNK_WIDTH / 2, CHUNK_HEIGHT / 2, -CHUNK_LENGTH / 2)) + w < 0:
_out += 1
else:
_in += 1
if (
glm.dot(
normal, center + glm.vec3(-CHUNK_WIDTH / 2, CHUNK_HEIGHT / 2, -CHUNK_LENGTH / 2)
)
+ w
< 0
):
if glm.dot(normal, center + glm.vec3(-CHUNK_WIDTH / 2, CHUNK_HEIGHT / 2, -CHUNK_LENGTH / 2)) + w < 0:
_out += 1
else:
_in += 1
if (
glm.dot(
normal, center + glm.vec3(CHUNK_WIDTH / 2, -CHUNK_HEIGHT / 2, CHUNK_LENGTH / 2)
)
+ w
< 0
):
if glm.dot(normal, center + glm.vec3(CHUNK_WIDTH / 2, -CHUNK_HEIGHT / 2, CHUNK_LENGTH / 2)) + w < 0:
_out += 1
else:
_in += 1
if (
glm.dot(
normal, center + glm.vec3(-CHUNK_WIDTH / 2, -CHUNK_HEIGHT / 2, CHUNK_LENGTH / 2)
)
+ w
< 0
):
if glm.dot(normal, center + glm.vec3(-CHUNK_WIDTH / 2, -CHUNK_HEIGHT / 2, CHUNK_LENGTH / 2)) + w < 0:
_out += 1
else:
_in += 1
if (
glm.dot(
normal, center + glm.vec3(CHUNK_WIDTH / 2, -CHUNK_HEIGHT / 2, -CHUNK_LENGTH / 2)
)
+ w
< 0
):
if glm.dot(normal, center + glm.vec3(CHUNK_WIDTH / 2, -CHUNK_HEIGHT / 2, -CHUNK_LENGTH / 2)) + w < 0:
_out += 1
else:
_in += 1
if (
glm.dot(
normal, center + glm.vec3(-CHUNK_WIDTH / 2, -CHUNK_HEIGHT / 2, -CHUNK_LENGTH / 2)
)
+ w
< 0
):
if glm.dot(normal, center + glm.vec3(-CHUNK_WIDTH / 2, -CHUNK_HEIGHT / 2, -CHUNK_LENGTH / 2)) + w < 0:
_out += 1
else:
_in += 1
Expand Down
4 changes: 3 additions & 1 deletion community/src/renderer/block_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@

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):
def __init__(
self, texture_manager, name="unknown", block_face_textures={"all": "cobblestone"}, model: Any = models.cube
):
self.name = name
self.block_face_textures = block_face_textures
self.model = model
Expand Down
3 changes: 1 addition & 2 deletions community/src/renderer/shader.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
import glm


class ShaderError(Exception):
...
class ShaderError(Exception): ...


def create_shader(target, source_path):
Expand Down
5 changes: 3 additions & 2 deletions community/src/world.py
Original file line number Diff line number Diff line change
Expand Up @@ -519,8 +519,9 @@ def sort_chunks(self):
player_chunk_pos = self.get_chunk_position(self.player.position)
self.visible_chunks.sort(
key=cmp_to_key(
lambda a, b: int(math.dist(player_chunk_pos, a.chunk_position)
- math.dist(player_chunk_pos, b.chunk_position))
lambda a, b: int(
math.dist(player_chunk_pos, a.chunk_position) - math.dist(player_chunk_pos, b.chunk_position)
)
)
)
self.sorted_chunks = tuple(reversed(self.visible_chunks))
Expand Down

0 comments on commit a44acb0

Please sign in to comment.