Skip to content

Commit cd01756

Browse files
committed
inti minecraft ai
0 parents  commit cd01756

19 files changed

+4004
-0
lines changed

.gitignore

+182
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,182 @@
1+
# Based on https://raw.githubusercontent.com/github/gitignore/main/Node.gitignore
2+
3+
# Logs
4+
5+
logs
6+
_.log
7+
npm-debug.log_
8+
yarn-debug.log*
9+
yarn-error.log*
10+
lerna-debug.log*
11+
.pnpm-debug.log*
12+
13+
# Caches
14+
15+
.cache
16+
17+
# Diagnostic reports (https://nodejs.org/api/report.html)
18+
19+
report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json
20+
21+
# Runtime data
22+
23+
pids
24+
_.pid
25+
_.seed
26+
*.pid.lock
27+
28+
# Directory for instrumented libs generated by jscoverage/JSCover
29+
30+
lib-cov
31+
32+
# Coverage directory used by tools like istanbul
33+
34+
coverage
35+
*.lcov
36+
37+
# nyc test coverage
38+
39+
.nyc_output
40+
41+
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
42+
43+
.grunt
44+
45+
# Bower dependency directory (https://bower.io/)
46+
47+
bower_components
48+
49+
# node-waf configuration
50+
51+
.lock-wscript
52+
53+
# Compiled binary addons (https://nodejs.org/api/addons.html)
54+
55+
build/Release
56+
57+
# Dependency directories
58+
node_modules/
59+
jspm_packages/
60+
61+
# Snowpack dependency directory (https://snowpack.dev/)
62+
63+
web_modules/
64+
65+
# TypeScript cache
66+
67+
*.tsbuildinfo
68+
69+
# Optional npm cache directory
70+
71+
.npm
72+
73+
# Optional eslint cache
74+
75+
.eslintcache
76+
77+
# Optional stylelint cache
78+
79+
.stylelintcache
80+
81+
# Microbundle cache
82+
83+
.rpt2_cache/
84+
.rts2_cache_cjs/
85+
.rts2_cache_es/
86+
.rts2_cache_umd/
87+
88+
# Optional REPL history
89+
90+
.node_repl_history
91+
92+
# Output of 'npm pack'
93+
94+
*.tgz
95+
96+
# Yarn Integrity file
97+
98+
.yarn-integrity
99+
100+
# dotenv environment variable files
101+
102+
.env
103+
.env.development.local
104+
.env.test.local
105+
.env.production.local
106+
.env.local
107+
108+
# parcel-bundler cache (https://parceljs.org/)
109+
110+
.parcel-cache
111+
112+
# Next.js build output
113+
114+
.next
115+
out
116+
117+
# Nuxt.js build / generate output
118+
119+
.nuxt
120+
dist
121+
122+
# Gatsby files
123+
124+
# Comment in the public line in if your project uses Gatsby and not Next.js
125+
126+
# https://nextjs.org/blog/next-9-1#public-directory-support
127+
128+
# public
129+
130+
# vuepress build output
131+
132+
.vuepress/dist
133+
134+
# vuepress v2.x temp and cache directory
135+
136+
.temp
137+
138+
# Docusaurus cache and generated files
139+
140+
.docusaurus
141+
142+
# Serverless directories
143+
144+
.serverless/
145+
146+
# FuseBox cache
147+
148+
.fusebox/
149+
150+
# DynamoDB Local files
151+
152+
.dynamodb/
153+
154+
# TernJS port file
155+
156+
.tern-port
157+
158+
# Stores VSCode versions used for testing VSCode extensions
159+
160+
.vscode-test
161+
162+
# yarn v2
163+
164+
.yarn/cache
165+
.yarn/unplugged
166+
.yarn/build-state.yml
167+
.yarn/install-state.gz
168+
.pnp.*
169+
170+
# IntelliJ based IDEs
171+
.idea
172+
173+
# Finder (MacOS) folder config
174+
.DS_Store
175+
176+
# Windows
177+
Thumbs.db
178+
ehthumbs.db
179+
Desktop.ini
180+
181+
# Linux
182+
*~

README.md

+148
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
# Minecraft Clone with Three.js
2+
3+
A voxel-based Minecraft clone built using Three.js and TypeScript.
4+
5+
![Minecraft Clone Screenshot](screenshot.png)
6+
7+
## Features
8+
9+
- Procedurally generated terrain with different biomes
10+
- Block breaking and placement
11+
- Player movement with collision detection
12+
- Different block types (grass, dirt, stone, wood, leaves, etc.)
13+
- Basic physics (gravity, jumping)
14+
- First-person camera controls
15+
- Hotbar for block selection
16+
- Debug information display
17+
- Lighting system with shadows
18+
19+
## Prerequisites
20+
21+
- Node.js (v14 or higher)
22+
- Bun or npm
23+
24+
## Installation
25+
26+
1. Clone the repository:
27+
```bash
28+
git clone <repository-url>
29+
cd minecraft-clone
30+
```
31+
32+
2. Install dependencies:
33+
```bash
34+
bun install
35+
# or
36+
npm install
37+
```
38+
39+
## Running the Game
40+
41+
1. Start the development server:
42+
```bash
43+
bun start
44+
# or
45+
npm start
46+
```
47+
48+
2. Open your browser and navigate to `http://localhost:3000`
49+
50+
## Development
51+
52+
For development with hot reloading:
53+
54+
```bash
55+
bun dev
56+
# or
57+
npm run dev
58+
```
59+
60+
To generate the texture atlas:
61+
62+
```bash
63+
bun generate-textures
64+
# or
65+
npm run generate-textures
66+
```
67+
68+
## Project Structure
69+
70+
```
71+
minecraft-clone/
72+
├── dist/ # Compiled output
73+
├── public/ # Static assets
74+
│ └── textures/ # Game textures
75+
│ └── atlas.png # Texture atlas
76+
├── src/
77+
│ ├── core/ # Core game engine
78+
│ │ └── Engine.ts # Main game engine
79+
│ ├── player/ # Player-related code
80+
│ │ └── Player.ts # Player controller
81+
│ ├── ui/ # User interface
82+
│ │ └── DebugUI.ts # Debug information display
83+
│ ├── utils/ # Utility functions
84+
│ │ ├── TextureManager.ts # Texture management
85+
│ │ └── TextureAtlasGenerator.ts # Texture atlas generator
86+
│ └── world/ # World generation and management
87+
│ ├── Block.ts # Block definitions
88+
│ ├── Chunk.ts # Chunk management
89+
│ └── World.ts # World generation
90+
├── index.html # Main HTML file
91+
├── index.ts # Entry point
92+
├── server.ts # Development server
93+
├── build.ts # Build script
94+
├── package.json # Project configuration
95+
└── README.md # Project documentation
96+
```
97+
98+
## Controls
99+
100+
- **WASD**: Move
101+
- **Space**: Jump
102+
- **Mouse**: Look around
103+
- **Left Click**: Break block
104+
- **Right Click**: Place block
105+
- **1-6 Keys**: Select block type
106+
- **Mouse Wheel**: Cycle through block types
107+
- **ESC**: Release mouse pointer
108+
109+
## How It Works
110+
111+
The game is built using the following components:
112+
113+
- **Engine**: Main game engine that manages the scene, camera, and game loop
114+
- **World**: Manages chunks and terrain generation
115+
- **Chunk**: Represents a 16x16x16 section of blocks
116+
- **Block**: Defines different block types and their properties
117+
- **Player**: Handles player movement and interaction
118+
- **TextureManager**: Manages block textures and UV mapping
119+
- **DebugUI**: Displays debug information
120+
121+
## Technical Notes
122+
123+
- The project uses Three.js as a dependency installed via npm
124+
- Custom PointerLockControls implementation for better compatibility
125+
- Fallback texture generation if atlas.png is not available
126+
- Debug logging added to help diagnose rendering issues
127+
- Enhanced lighting with ambient and directional lights
128+
129+
## Performance Considerations
130+
131+
- Chunks are only rendered when visible
132+
- Only visible faces of blocks are rendered
133+
- Chunks are loaded/unloaded based on player position
134+
- Frustum culling is used to avoid rendering off-screen objects
135+
136+
## Future Improvements
137+
138+
- Multiplayer support
139+
- Inventory system
140+
- Crafting
141+
- More block types
142+
- Day/night cycle
143+
- Mobs and creatures
144+
- Saving/loading worlds
145+
146+
## License
147+
148+
MIT

0 commit comments

Comments
 (0)