Skip to content

Instantly share code, notes, and snippets.

View EncodeTheCode's full-sized avatar
💭
Coding useful tools for workflow.

EncodeTheCode

💭
Coding useful tools for workflow.
View GitHub Profile
import numpy as np
import sounddevice as sd
import wave
class PS1Audio:
def __init__(self, sample_rate=22050, bit_depth=16):
"""
PS1Audio class for playing audio with PS1 characteristics.
:param sample_rate: Audio sample rate (Hz), 22050 for PS1 weapon SFX
:param bit_depth: Bit depth (8 or 16)
import numpy as np
import sounddevice as sd
from pydub import AudioSegment
class PS1Audio:
def __init__(self, sample_rate=22050):
"""
PS1Audio class to play audio files with PS1-style characteristics.
:param sample_rate: Default playback rate (Hz). 22050 for PS1 SFX.
"""
import numpy as np
import sounddevice as sd
from pydub import AudioSegment
import wave
class PS1Audio:
def __init__(self, default_sample_rate=22050, bit_depth=16):
"""
Initialize PS1Audio
:param default_sample_rate: Playback sample rate (default 22050 Hz)
"""
PS1-style audio manager: non-blocking, simultaneous playback, multi-format support.
Dependencies:
- numpy
- sounddevice
- pydub (and ffmpeg installed system-wide)
"""
import threading
import uuid
# room_minimal_camera_projection.py
# Projection + camera code moved outside main() for a tiny main loop.
# Features: FOV=45, 60FPS cap, flipped textures, floor fits walls, WASD + LMB look.
import ctypes, sys, math, numpy as np, pygame
from OpenGL.GL import *
from PIL import Image
# ---------- config ----------
W, H = 1280, 720
# room_functions_projection.py
# Projection/matrix/GL helper functions are outside main().
# Main loop only handles input, camera update and calls render_frame().
import ctypes, sys, math, numpy as np, pygame
from OpenGL.GL import *
from PIL import Image
# ---------- Config ----------
W, H = 1280, 720
# room_compact.py — compact single-file 3D room (FOV=45, 60FPS cap, flipped textures, floor fits walls)
import ctypes, sys, math, numpy as np, pygame
from OpenGL.GL import *
from PIL import Image
# -------- config ----------
W, H = 1280, 720
FPS_CAP, DT_MAX = 60, 0.05
FOV, NEAR, FAR = 45.0, 0.1, 200.0
TFILES = ["wall1.png","wall2.png","wall3.png","wall4.png","floor.png"]
# room_configured_vars.py
# Same feature set as before but with many numeric literals replaced by named variables/constants.
# FOV=45, textures rotated 180°, floor covers walls, 60 FPS cap, WASD + hold-LMB look.
# Requires: pygame, PyOpenGL, numpy, Pillow
import ctypes
import pygame, sys, math, numpy as np
from OpenGL.GL import *
from PIL import Image
# room_fullfloor_fixed.py
# Floor now correctly stretches to reach walls (no bridge). FOV=45, textures rotated 180°, 60FPS cap.
# Requires: pygame PyOpenGL numpy Pillow
import pygame, sys, math, numpy as np
from OpenGL.GL import *
from PIL import Image
def compile_shader(vs, fs):
def _c(src, t):
import math
from typing import Union, Tuple, Callable
Number = Union[int, float]
Vector = Tuple[Number, ...]
Color = Tuple[Number, Number, Number, Number] # RGBA
class Interpolator:
def __init__(self):
# Huge collection of easing functions used in game development