A Roblox-style 3D block building game built with TypeScript, Next.js, and Three.js - perfect for learning game development together!
- Bun (already installed)
- Node.js 18+
# Install dependencies
bun install
# Start the development server
bun devThen open http://localhost:3000 in your browser.
- W, A, S, D: Move your character (red block)
- Space: Jump
- Mouse: Look around (drag to rotate camera)
- Mouse Click: Place blocks
- Mouse Scroll: Zoom in/out
- 3D world with physics
- Block placement system
- Different colored blocks
- Character movement and jumping
- Save/Load game (coming soon)
src/
โโโ app/ # Next.js app directory
โ โโโ page.tsx # Main game page
โ โโโ layout.tsx # App layout
โโโ components/ # Game components
โ โโโ Game.tsx # Main game component
โ โโโ Player.tsx # Player character
โ โโโ Ground.tsx # Game ground
โ โโโ BlockPlacer.tsx # Block placement system
โ โโโ GameUI.tsx # User interface
โโโ hooks/ # Custom React hooks
โ โโโ useGameManager.ts # Game state management
โโโ types/ # TypeScript type definitions
โโโ game.ts # Game-related types
- Next.js 14: React framework
- TypeScript: Type-safe JavaScript
- Three.js: 3D graphics library
- React Three Fiber: React renderer for Three.js
- React Three Cannon: Physics engine
- Tailwind CSS: Styling
-
Basic Programming Concepts
- Variables and functions
- If/else statements
- Loops
- Objects and properties
-
Game Development
- How games work (game loop, rendering, input)
- 3D coordinates (X, Y, Z)
- Physics (gravity, collision)
- User interfaces
-
Problem Solving
- Breaking down big problems into smaller ones
- Debugging (finding and fixing bugs)
- Testing and iteration
- Modern React patterns (hooks, context)
- TypeScript best practices
- 3D programming with Three.js
- Game architecture and state management
-
More Block Types
// Add to BlockPlacer.tsx const blockTypes = ['normal', 'bouncy', 'slippery', 'glowing'];
-
Sound Effects
// Add sound when placing blocks const playSound = (soundName: string) => { const audio = new Audio(`/sounds/${soundName}.mp3`); audio.play(); };
-
Particle Effects
// Add sparkles when placing blocks -
Score System
// Count blocks placed, time played, structures built
- Multiplayer (local split-screen)
- Building Templates (houses, castles, etc.)
- Game Modes (creative, survival, racing)
- Inventory System
- Custom Block Shapes
- Scripting System (simple visual programming)
- World Generation
- Animation System
- Scratch - Visual programming
- Code.org - Hour of Code activities
- Khan Academy Programming
- Three.js Journey - 3D programming
- React Three Fiber Docs
- TypeScript Handbook
Edit src/components/GameUI.tsx to add new colors:
const colors = [
{ name: 'Blue', value: '#3b82f6' },
{ name: 'Pink', value: '#ec4899' }, // Add this
{ name: 'Cyan', value: '#06b6d4' }, // Add this
// ... more colors
];Edit src/components/Game.tsx:
<Physics gravity={[0, -30, 0]}> // Make gravity stronger/weakerEdit src/components/Player.tsx:
const speed = 5; // Make player faster/slower
const jumpForce = 15; // Make jumping higher/lower- Make sure all dependencies are installed:
bun install - Check the browser console for errors (F12)
- Make sure you're using a modern browser (Chrome, Firefox, Safari)
- Reduce the number of blocks
- Lower the shadow quality in
Game.tsx - Disable Stats component for better performance
This is a learning project! Feel free to:
- Add new features
- Fix bugs
- Improve documentation
- Add comments to help understand the code
Keep track of what you've learned and built:
- โ Set up the basic game structure
- โ Added player movement (WASD + Space)
- โ Added block placement system
- โ Created basic UI
- Add sound effects
- Create different block types
- Add a simple scoring system
- Make the player look like a character instead of a red box
Have fun building and learning together! ๐ฎโจ