Getting Started
Prerequisites
- Git installed
- Java 21+ (for Java stack)
- CMake & C++ compiler (for C++ stack)
- Visual Studio or your preferred IDE
Clone & Setup
git clone https://github.com/AkiUse306/akincraft.git
cd akincraft
Java Stack
cd java
./gradlew build # Build the project
./gradlew run # Run the game
C++ Stack
cd cpp
mkdir -p build && cd build
cmake ..
cmake --build .
./akincraft_cpp
Engine Architecture
Project Structure
java/
├── src/main/java/akincraft/
│ ├── App.java # Main entry point
│ ├── World.java # World management
│ ├── Chunk.java # Chunk data structure
│ ├── Entity.java # Game entities
│ ├── Renderer.java # Rendering system
│ ├── Physics.java # Physics engine
│ └── Inventory.java # Inventory system
├── build.gradle.kts # Build configuration
└── gradlew # Gradle wrapper
cpp/
├── src/
│ ├── App.cpp/h # Main application
│ ├── World.cpp/h # World system
│ ├── Chunk.cpp/h # Chunk management
│ ├── Renderer.cpp/h # OpenGL renderer
│ ├── Entity.cpp/h # Entity system
│ └── Physics.cpp/h # Physics
├── CMakeLists.txt # Build configuration
└── build/ # Build output
Core Systems
| System |
Responsibility |
Key Classes/Files |
| World |
Chunk management and terrain generation |
World.cpp/java, Chunk.cpp/java |
| Renderer |
OpenGL rendering and mesh generation |
Renderer.cpp/java |
| Entity |
Players, mobs, and game objects |
Entity.cpp/java, EntityManager.cpp/java |
| Physics |
Collision detection and movement |
Physics.cpp/java (implicitly in movement code) |
| Inventory |
Item management and crafting |
Inventory.cpp/java, Item.cpp/java |
Game Loop
// Pseudocode - Main game loop
while (game_running) {
// Input
handle_input();
// Update
update_world();
update_entities();
update_physics();
update_inventory();
// Render
generate_chunk_meshes();
render_scene();
// Frame timing
sleep_to_target_fps();
}
Customizing Your Game
Adding Block Types
Location: Look for BlockType.h (C++) or block type definitions in Java
// Example: Adding a new block type
enum BlockType {
AIR = 0,
STONE = 1,
DIRT = 2,
GRASS = 3,
// ADD YOUR BLOCKS HERE
CUSTOM_ORE = 50,
CUSTOM_WOOD = 51,
// ...
}
Modifying Block Colors
Each block type needs a color for rendering. Find the texture/color mapping in:
- Java: Look for color arrays in rendering code
- C++: Check Renderer.cpp for block color definitions
Tweaking World Generation
The procedural generation uses noise functions. You can customize:
- Biome parameters - Temperature, humidity thresholds
- Noise scales - Height variation, cave frequency
- Ore distribution - Depth ranges, spawn rates
Adding Custom Entities
// Extend Entity class with your custom entity
class MyCreature : public Entity {
virtual void update(float deltaTime) override {
// Your custom logic here
move_towards_player();
attack_if_close();
take_damage_if_hit();
}
};
Creating New Biomes
To add a new biome:
- Define biome properties (temperature, humidity, height)
- Add block palette for the biome
- Modify terrain generation to use biome data
- Add unique entities/features to the biome
Adding Major Features
1. Multiplayer Support
Note: Java version has networking foundation
- Set up TCP/WebSocket server
- Implement player state synchronization
- Handle chunk streaming to multiple clients
- Add player identification and authentication
2. Advanced Crafting System
// Define recipes
Recipe iron_pickaxe = {
input: [iron_ingot, iron_ingot, iron_ingot,
stick, stick],
output: pickaxe,
pattern: [
[I, I, I],
[_, S, _],
[_, S, _]
]
};
3. Mob AI System
- Implement state machine (Idle, Wander, Chase, Attack, Flee)
- Add pathfinding (A* or simple steering)
- Create loot drops on death
- Add breeding/spawning mechanics
4. Enhanced Lighting
- Implement light propagation
- Add light sources (torches, lava, etc.)
- Shadow calculation for realistic lighting
- Dynamic lighting for moving objects
5. Weather System
// Weather states
enum WeatherType {
CLEAR,
RAIN,
THUNDERSTORM,
SNOW
};
// Update weather
void update_weather(float deltaTime) {
weather_timer += deltaTime;
if (weather_timer > weather_duration) {
change_to_random_weather();
weather_timer = 0;
}
}
6. Persistent Data Storage
- Serialize chunks to disk (JSON, binary, or custom format)
- Implement save/load system
- Store player position and inventory
- Track modified chunks since last save
Development Tips
Performance Optimization
- Use frustum culling to skip off-screen chunks
- Implement LOD (Level of Detail) for distant chunks
- Cache mesh generation results
- Use object pooling for frequently created objects
Testing Your Changes
- Build frequently to catch compile errors early
- Test in small chunks - don't change too much at once
- Use debug visualization for terrain/physics debugging
- Profile FPS and memory usage regularly
Resources
- OpenGL: learnopengl.com - Graphics programming
- Procedural Generation: Perlin noise, Voronoi diagrams
- Physics: AABB collision, ray casting techniques
- Engine Design: Game loop patterns, ECS architecture