Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Community restructuring #113

Merged
merged 13 commits into from
Aug 12, 2024
26 changes: 26 additions & 0 deletions .github/workflows/community-lsp.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Community - Language server checks

on: push

jobs:
check_lsp:
runs-on: ubuntu-latest
defaults:
run:
working-directory: community
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.11"
- uses: abatilo/actions-poetry@v2
- name: Install dependencies
run: poetry install --no-root --with dev
- name: Cache venv created by poetry (configured to be in '.venv')
uses: actions/cache@v3
with:
path: ./.venv
key: venv-${{ runner.os }}-${{ hashFiles('poetry.lock') }}
- name: Run pyright
run: |
poetry run pyright
51 changes: 25 additions & 26 deletions community/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import random
import time
import os
from collections import deque

import pyglet

Expand All @@ -13,17 +14,15 @@
pyglet.options["audio"] = ("openal", "pulse", "directsound", "xaudio2", "silent")

import pyglet.gl as gl
import shader
import player
import texture_manager

import world

import options
from src.renderer.shader import Shader
from src.renderer.texture_manager import TextureManager
from src.world import World
from src.entity.player import Player
from src.controllers.joystick import JoystickController
from src.controllers.keyboard_mouse import KeyboardMouseController

import joystick
import keyboard_mouse
from collections import deque
import src.options as options


class InternalConfig:
Expand Down Expand Up @@ -80,24 +79,24 @@

logging.info("Compiling Shaders")
if not self.options.COLORED_LIGHTING:
self.shader = shader.Shader("shaders/alpha_lighting/vert.glsl", "shaders/alpha_lighting/frag.glsl")
self.shader = Shader("shaders/alpha_lighting/vert.glsl", "shaders/alpha_lighting/frag.glsl")
else:
self.shader = shader.Shader("shaders/colored_lighting/vert.glsl", "shaders/colored_lighting/frag.glsl")
self.shader = Shader("shaders/colored_lighting/vert.glsl", "shaders/colored_lighting/frag.glsl")
self.shader_sampler_location = self.shader.find_uniform(b"u_TextureArraySampler")
self.shader.use()

# create textures
logging.info("Creating Texture Array")
self.texture_manager = texture_manager.TextureManager(16, 16, 256)
self.texture_manager = TextureManager(16, 16, 256)

# create world

self.world = world.World(self.shader, None, self.texture_manager, self.options)
self.world = World(self.shader, None, self.texture_manager, self.options)
Dismissed Show dismissed Hide dismissed

# player stuff

logging.info("Setting up player & camera")
self.player = player.Player(self.world, self.shader, self.width, self.height)
self.player = Player(self.world, self.shader, self.width, self.height)
self.world.player = self.player

# pyglet stuff
Expand Down Expand Up @@ -130,10 +129,10 @@
self.controls = [0, 0, 0]

# joystick stuff
self.joystick_controller = joystick.Joystick_controller(self)
self.joystick_controller = JoystickController(self)

# mouse and keyboard stuff
self.keyboard_mouse = keyboard_mouse.Keyboard_Mouse(self)
self.keyboard_mouse = KeyboardMouseController(self)

# music stuff
logging.info("Loading audio")
Expand All @@ -152,11 +151,11 @@
if len(self.music) > 0:
self.media_player.queue(random.choice(self.music))
self.media_player.play()
self.media_player.standby = False
self.media_player.standby = False # pyright: ignore
else:
self.media_player.standby = True
self.media_player.standby = True # pyright: ignore

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

# GPU command syncs
self.fences = deque()
Expand All @@ -175,8 +174,8 @@
def update_f3(self, delta_time):
"""Update the F3 debug screen content"""

player_chunk_pos = world.get_chunk_position(self.player.position)
player_local_pos = world.get_local_position(self.player.position)
player_chunk_pos = self.world.get_chunk_position(self.player.position)
player_local_pos = self.world.get_local_position(self.player.position)
chunk_count = len(self.world.chunks)
visible_chunk_count = len(self.world.visible_chunks)
quad_count = sum(chunk.mesh_quad_count for chunk in self.world.chunks.values())
Expand Down Expand Up @@ -206,11 +205,11 @@
self.update_f3(delta_time)

if not self.media_player.source and len(self.music) > 0:
if not self.media_player.standby:
self.media_player.standby = True
self.media_player.next_time = time.time() + random.randint(240, 360)
elif time.time() >= self.media_player.next_time:
self.media_player.standby = False
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
Loading
Loading