Underground 2 Revived
Play Need for Speed: Underground 2 (2004) in Chrome and Firefox with WebGPU graphics, Web Audio, up to 120 fps widescreen, controller support, free roam and Online races with friends. Fan project, not
翻譯準備中
尚未偵測到更新。GitHub 發布版本後會顯示在這裡。
個人 GitHub 帳號下公開儲存庫的擁有者可以登入並驗證所有權,自行管理介紹,無需管理員核准。
登入並產生驗證檔案,在 30 分鐘內將其提交至此儲存庫的預設分支。其他分支或分叉儲存庫中的檔案無效。然後在下方檢查檔案,即可無需管理員核准直接管理專案。請保留檔案以維持管理權限。
如需登入,將前往登入頁面。登入後請回到此處,再次點擊所選的驗證按鈕。
在專案資料夾中執行 /nomorevibe verify,即可驗證所有權並自行管理介紹。
一分鐘完成驗證正在載入完整 README。 以下為已儲存的摘錄。
A modern rebuild of Pong with clean architecture, precise physics, and a path to online multiplayer
This isn't just another Pong clone. It's a learning exercise in rebuilding a classic game with modern software engineering principles, testing a "Vibe Coding Workflow" that balances AI-assisted development with deep technical understanding.
1. Architecture Matters - The original game loop had variable timestep issues and scattered state. This rebuild implements a fixed-timestep game loop and centralized state management from day one.檢視完整 README ↗A modern rebuild of Pong with clean architecture, precise physics, and a path to online multiplayer
This isn't just another Pong clone. It's a learning exercise in rebuilding a classic game with modern software engineering principles, testing a "Vibe Coding Workflow" that balances AI-assisted development with deep technical understanding.
Architecture Matters - The original game loop had variable timestep issues and scattered state. This rebuild implements a fixed-timestep game loop and centralized state management from day one.
Future-Proof Design - Every architectural decision (ES6 modules, state serialization, input buffering) is made with online multiplayer in mind, even though that's not yet implemented.
Learning Through Constraints - By choosing vanilla JavaScript with no frameworks, every decision is explicit and every pattern is learned, not abstracted away.
Quality Over Speed - 4-6 hour estimated time budget (TRD.md), but willing to go deeper to get the physics right. Stage 2 alone included building a full collision test harness.
▶️ Play Live Demo | 📖 View Source
No installation required - runs directly in your browser!
requestAnimationFrame with accumulator pattern (60Hz updates)npm test runs in Node.js)Key Achievement: All collision tests pass. Physics feel tight and predictable.
See build-plan.md for the complete roadmap (13 of 16 stages complete, 81%).
Why it matters: Prevents frame-rate dependent physics bugs. Critical for future network synchronization.
// main.js:8-44
const TIMESTEP = 1000 / 60; // 16.67ms per update
let accumulator = 0;
function gameLoop(currentTime) {
let deltaTime = currentTime - lastTime;
deltaTime = Math.min(deltaTime, 250); // Spiral of death protection
accumulator += deltaTime;
while (accumulator >= TIMESTEP) {
updateGame(TIMESTEP); // Fixed 60Hz physics
accumulator -= TIMESTEP;
}
render();
requestAnimationFrame(gameLoop);
}
Why it matters: Single source of truth. State is serializable for debugging and future networking.
All game entities (paddles, ball, scores) live in one object (game-state.js). No scattered globals.
Module structure:
main.js - Entry point, game loop orchestrationgame-state.js - State management, update logicpaddle.js - Paddle entity and movementball.js - Ball physics, serving, bounce angle computationcollision.js - AABB detection and positional correctionrenderer.js - Canvas drawing (separate from logic)input.js - Keyboard event bufferingRule: No object allocation inside the game loop. Reuse objects to prevent GC spikes.
Philosophy: Collision bugs are expensive. Build test infrastructure early.
The collision system has:
This lets us refactor physics confidently without breaking gameplay feel.
No build system required. Serve the project locally:
# Option 1: http-server (recommended)
npx http-server .
# Option 2: serve
npx serve .
# Option 3: VS Code Live Server
# Install "Live Server" extension, then right-click index.html → "Open with Live Server"
Then open http://localhost:8080 (or whatever port is shown) and visit index.html.
Controls:
# Headless collision tests (Node.js)
npm test
# or directly:
node test/run_collision_tests.mjs
# Browser tests (visual feedback)
# Serve the project, then open:
# - test/collision.unit.html (automated suite)
# - test/collision-debug.html (interactive debug harness)
Debug Harness Features:
Bounce angle varies based on where the ball hits the paddle:
// ball.js:52-60
function computeBounceAngle(ballY, paddleY, paddleHeight, direction) {
const offset = ballY - paddleY;
const normalized = offset / (paddleHeight / 2); // -1 to 1
// Apply center deadzone (5% = ±0.05)
const adjustedNorm = Math.abs(normalized) < 0.05 ? 0 : normalized;
const maxDeflection = 50 * (Math.PI / 180); // 50 degrees in radians
const angle = adjustedNorm * maxDeflection;
return { x: Math.cos(angle) * direction, y: Math.sin(angle) };
}
Design choice: Center deadzone makes the game more forgiving. Without it, perfectly centered hits can feel unpredictable.
// collision.js:8-32
export function detectBallPaddleCollision(ball, paddle) {
// Find closest point on rectangle to circle center
const closestX = Math.max(paddle.x - paddle.w/2,
Math.min(ball.x, paddle.x + paddle.w/2));
const closestY = Math.max(paddle.y - paddle.h/2,
Math.min(ball.y, paddle.y + paddle.h/2));
const dx = ball.x - closestX;
const dy = ball.y - closestY;
const distSq = dx*dx + dy*dy;
if (distSq < ball.radius * ball.radius) {
// Collision! Apply positional correction to prevent sticking
const dist = Math.sqrt(distSq);
const overlap = ball.radius - dist;
if (dist > 0) {
ball.x += (dx / dist) * overlap; // Push ball out
}
return true;
}
return false;
}
Why positional correction matters: Without it, the ball "sticks" to the paddle for multiple frames. By explicitly moving the ball out of penetration, we ensure clean bounces.
// game-state.js:42-44
const maxDist = Math.abs(ball.vx * deltaTime / 1000);
if (Math.abs(ball.x - leftPaddle.x) < leftPaddle.w / 2 + ball.radius + maxDist) {
// Only check collision if ball is near paddle (prevents tunneling)
}
Problem: At high speeds, the ball can move more than its diameter in one frame, passing through the paddle between updates.
Solution: Guard collision checks with distance-based proximity test. If the ball could potentially overlap in this frame, check collision. Otherwise skip.
Tradeoff: Slightly more complex loop logic (accumulator pattern) vs. naive deltaTime scaling.
pong-redux/
├── index.html # Entry point
├── styles.css # Minimal styling
├── src/
│ ├── main.js # Game loop (fixed timestep, 60Hz)
│ ├── game-state.js # Centralized state & update logic
│ ├── paddle.js # Paddle entity factory
│ ├── ball.js # Ball physics & serving
│ ├── collision.js # AABB collision + correction
│ ├── renderer.js # Canvas drawing
│ └── input.js # Keyboard event buffering
├── test/
│ ├── run_collision_tests.mjs # Headless Node.js tests
│ ├── collision.unit.html # Browser test suite
│ └── collision-debug.html # Interactive debug harness
├── .github/
│ └── workflows/ci.yml # GitHub Actions (runs tests on push)
├── README.md # You are here
├── build-plan.md # 16-stage roadmap (Stages 1-2 complete)
├── TRD.md # Technical Requirements Document
└── CLAUDE.md # Project instructions for Claude Code
Key files for understanding the codebase:
Architecture for scale: Built from day one with online multiplayer in mind (state serialization, fixed timestep, input buffering) - even though multiplayer isn't implemented, the foundation is ready.
Test-first physics: Most Pong clones tweak collision until it "feels right." This project has automated tests, visual debug harness, and comprehensive edge-case handling.
Documented learning journey: build-plan.md, TRD.md, and CHANGELOG.md capture the complete thought process, not just the final code.
No shortcuts on fundamentals: Implemented proper fixed-timestep loop, positional correction, swept collision detection, and animation system—patterns you'd find in commercial game engines.
Production-ready polish: Extensive customization (paddles, balls, difficulty), procedural sound system, smooth animations, particle effects, and comprehensive testing - all with solid 60fps performance.
🎉 v1.0.0 Released - Portfolio Ready!
See build-plan.md for detailed breakdown. High-level progress:
Phase 1: Core Mechanics (Stages 1-4) - ✅ COMPLETE
Phase 2: Game Modes (Stages 5-7) - ✅ COMPLETE
Phase 3: Customization (Stages 8-11) - ✅ COMPLETE
Phase 4: Polish (Stages 12-16) - ✅ COMPLETE
📊 Completion: 13 of 16 stages (81%) - Portfolio Ready
Future Enhancements (optional, post-v1.0.0):
This is a personal learning project, but feedback on architecture decisions, physics tuning, or test coverage is welcome!
Interesting areas for discussion:
Open an issue or PR if you spot bugs, physics edge cases, or have suggestions for the AI implementation (Stage 6).
MIT License - Feel free to learn from, fork, or build upon this code.
Attribution appreciated but not required. If you use the collision detection algorithm or test harness setup in your own projects, a link back would be cool!
Current Status: Rugby Mode Refinements Complete ✅ Progress: 13 of 16 stages complete (81%) - Portfolio Ready! Last Updated: 2026-02-13