flowchart TB
subgraph JSON["JSON Approach"]
direction TB
J1["Game State\n201 bytes"]
J2["JSON.stringify()\n0.03ms"]
J3["Network Transfer\n50ms"]
J4["JSON.parse()\n0.05ms"]
J5["Object Creation\nGarbage Collection"]
flowchart TB
subgraph Server["Game Server"]
SAB[("SharedArrayBuffer\n(Game State)")]
Physics["Physics Engine"]
InputHandler["Input Handler"]
StateManager["State Manager"]
Physics -->|"Update"| SAB
InputHandler -->|"Update"| SAB
flowchart TB
subgraph MainThread["Main Thread"]
direction TB
Store["Pinia Store"]
Orchestrator["Worker Orchestrator"]
Monitor["Health Monitor"]
Metrics["Performance Metrics"]
Orchestrator --> Store
flowchart TB
subgraph MainThread["Main Thread"]
direction TB
Store["Pinia Store"]
Orchestrator["Worker Orchestrator"]
Monitor["Health Monitor"]
Metrics["Performance Metrics"]
Orchestrator --> Store
graph TD
subgraph Client
direction TB
eventListener(Event: User Input) -->|SharedArrayBuffer| WebWorker
WebWorker -->|SharedArrayBuffer: User Input| WebSocketClient
WebWorker -->|Render Shapes| OffscreenCanvas
WebSocketClient -->|User Input| WebSocketServer
WebSocketServer -->|Calculated Game State| WebSocketClient
WebSocketClient -->|SharedArrayBuffer: Ball & Paddles| WebWorker
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export class Vector2D implements Math.Vector2D { | |
static readonly #constructorSymbol = Symbol('Math.Vector2D') | |
static get zero(): Vector2D { | |
const zeroVector = Vector2D.create(0, 0) | |
return zeroVector | |
} | |
static create( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type Constructor<T = void> = new (...args: any[]) => T | |
type RenderCallback = (deltaTime: number) => void | |
type FPSUpdateCallback = (fps: number) => void | |
declare namespace Rendering { | |
type Context2D = OffscreenCanvasRenderingContext2D | CanvasRenderingContext2D | |
} | |
interface RendererContract<T extends Rendering.Context2D> { | |
context: T |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env zsh | |
alias rebasa="git rebase --interactive HEAD~$(git rev-list --count $(git branch --show-current) ^main)" | |
update_deps() { | |
# Stash changes including untracked files | |
if ! git stash push -u -m "Temporary stash before updating dependencies"; then | |
echo "Error: Failed to stash changes. Aborting update process." | |
return 1 | |
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { bench, describe } from 'vitest' | |
describe.each([ | |
{ time: 0, iterations: 100_000, warmupTime: 100, warmupIterations: 1_000 }, | |
{ time: 0, iterations: 100_000, warmupTime: 100, warmupIterations: 0 }, | |
])('vector2D operations with various inputs $warmupIterations', (benchOptions) => { | |
describe.each([ | |
{ name: 'Small integers', value: { x: 1, y: 2 } }, | |
{ name: 'Large integers', value: { x: 1000000, y: 2000000 } }, | |
{ name: 'Floating point', value: { x: 3.14159, y: 2.71828 } }, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export type Constructor<T> = new (...args: any[]) => T | |
export type Brand<T, B> = T & { __brand: B } | |
export type Scalar = number | |
export type Radian = number | |
export interface Coordinates2D { | |
x: number | |
y: number |
NewerOlder