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 pygame
import sys
# === CONFIGURABLE SETTINGS ===
WINDOW_WIDTH = 512
WINDOW_HEIGHT = 240
UPSCALED_WIDTH = 1920
UPSCALED_HEIGHT = 1080
FONT_SIZE = 10
TEXT_SCALE = 4
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>3D Room with Controls</title>
<style>
html, body {
margin: 0;
overflow: hidden;
height: 100%;
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>3D Room FPS Style</title>
<style>
body { margin: 0; overflow: hidden; }
canvas { display: block; background: #000; }
</style>
</head>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>3D Room FPS Style</title>
<style>
body { margin: 0; overflow: hidden; }
canvas { display: block; background: #000; }
</style>
</head>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>3D Room FPS Style</title>
<style>
body { margin: 0; overflow: hidden; }
canvas { display: block; background: #000; }
</style>
</head>
<canvas id="canvas" width="800" height="600"></canvas>
<script>
// ========== Vector Class ==========
class Vec3 {
constructor(x=0, y=0, z=0) { this.x=x; this.y=y; this.z=z; }
add(v) { return new Vec3(this.x+v.x, this.y+v.y, this.z+v.z); }
sub(v) { return new Vec3(this.x-v.x, this.y-v.y, this.z-v.z); }
rotateY(a) {
const cos = Math.cos(a), sin = Math.sin(a);
return new Vec3(this.x * cos - this.z * sin, this.y, this.x * sin + this.z * cos);
<canvas id="canvas" width="800" height="600"></canvas>
<script>
// Basic 3D Vector class
class Vector3 {
constructor(x = 0, y = 0, z = 0) {
this.x = x; this.y = y; this.z = z;
}
add(v) { return new Vector3(this.x + v.x, this.y + v.y, this.z + v.z); }
subtract(v) { return new Vector3(this.x - v.x, this.y - v.y, this.z - v.z); }
<canvas id="canvas" width="800" height="600"></canvas>
<script>
// --- Vector3 Class ---
class Vector3 {
constructor(x = 0, y = 0, z = 0) {
this.x = x; this.y = y; this.z = z;
}
add(v) {
return new Vector3(this.x + v.x, this.y + v.y, this.z + v.z);
<canvas id="canvas" width="600" height="600"></canvas>
<script>
// ----- 1. 3D Vector System -----
class Vector3 {
constructor(x = 0, y = 0, z = 0) {
this.x = x; this.y = y; this.z = z;
}
add(v) {
return new Vector3(this.x + v.x, this.y + v.y, this.z + v.z);
class RandomStringGenerator {
constructor(seed = Date.now()) {
this.seed = seed;
}
// Linear Congruential Generator (LCG) for pseudo-random values
_random() {
// Parameters from Numerical Recipes
this.seed = (1664525 * this.seed + 1013904223) % 4294967296;
return this.seed / 4294967296;