You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
2 months ago | |
|---|---|---|
| .github | 2 months ago | |
| config | 2 months ago | |
| docs | 2 months ago | |
| src | 2 months ago | |
| .gitignore | 2 months ago | |
| README.md | 2 months ago | |
| main.py | 2 months ago | |
| requirements.txt | 2 months ago | |
| test_texture.py | 2 months ago | |
README.md
Isometric Terrain Generator
A RollerCoaster Tycoon-style isometric terrain generator using Python, Pygame, and OpenGL.
Project Structure
shader/
├── config/
│ ├── __init__.py
│ └── settings.py # Configuration settings for the entire application
├── src/
│ ├── __init__.py
│ ├── app.py # Main application class
│ ├── camera/
│ │ ├── __init__.py
│ │ └── camera.py # Camera control and positioning
│ ├── terrain/
│ │ ├── __init__.py
│ │ └── generator.py # Terrain generation using Perlin noise
│ └── rendering/
│ ├── __init__.py
│ └── terrain_renderer.py # OpenGL rendering logic
├── main.py # Application entry point
├── isometric_terrain.py # Original monolithic version (legacy)
├── requirements.txt
└── README.md
Features
- 20×20 grid of 30px×30px isometric tiles
- Procedural terrain generation using Perlin noise with random seeds
- Procedural texture decorations - Each tile has unique pixelated patterns (RCT-style)
- Multiple biomes based on elevation (water, sand, grass, rock, snow)
- Real-time camera controls
- Dynamic regeneration - Press R for new terrain and textures
- Configurable settings via
config/settings.py
Installation
- Activate the virtual environment:
source venv/bin/activate
- Install dependencies (if not already installed):
pip install -r requirements.txt
Usage
Run the new organized version:
source venv/bin/activate && python main.py
Or run the legacy version:
source venv/bin/activate && python isometric_terrain.py
Controls
- UP/DOWN Arrow: Zoom in/out
- LEFT/RIGHT Arrow: Adjust camera height
- R Key: Regenerate terrain (new version only)
- ESC: Exit application
Configuration
All settings can be modified in config/settings.py:
Terrain Settings
grid_size: Number of tiles (default: 20×20)tile_width/tile_depth: Size of each tile in pixels (default: 30px)noise_scale: Controls terrain variation frequencyheight_multiplier: Controls terrain elevation rangeenable_smoothing: Enable/disable terrain smoothing
Camera Settings
initial_distance: Starting zoom levelinitial_height: Starting camera heightzoom_speed: How fast zoom in/out worksmin_distance/max_distance: Zoom limits
Rendering Settings
background_color: Sky colorgrid_line_width: Thickness of tile borderslight_position: Light source positionlight_ambient/light_diffuse: Lighting propertiesside_face_color: Uniform color for lateral tile facestexture_enabled: Enable/disable procedural textures (default: true)texture_detail_scale: Controls texture pattern sizetexture_variation: Amount of color variation (0.0-1.0)texture_spots_threshold: Controls dark spot frequency
Biome Configuration
BIOME_COLORS: RGB colors for each biome typeBIOME_THRESHOLDS: Height thresholds for biome transitions
Architecture
Separation of Concerns
The code is organized into logical modules:
-
Configuration (
config/settings.py)- Centralized settings management
- Easy to modify without touching code
-
Camera (
src/camera/camera.py)- Handles view projection and positioning
- Processes user input for camera movement
- Manages camera constraints
-
Terrain Generation (
src/terrain/generator.py)- Procedural heightmap generation using Perlin noise
- Optional terrain smoothing
- Configurable noise parameters
-
Rendering (
src/rendering/terrain_renderer.py)- OpenGL rendering of terrain mesh
- Procedural texture generation - 16×16 pixelated textures per tile
- Biome coloring based on elevation
- Wireframe grid overlay
- Shaded side faces for depth
- Texture caching for performance
-
Application (
src/app.py)- Main application loop
- Event handling
- Coordinates all components
Extending the Project
Adding New Biomes
- Add color to
BIOME_COLORSinconfig/settings.py - Add threshold to
BIOME_THRESHOLDS - Update
get_color_for_height()interrain_renderer.py
Modifying Terrain Generation
Edit parameters in config/settings.py:
- Adjust
noise_scalefor more/less variation - Change
noise_octavesfor detail level - Modify
height_multiplierfor elevation range - Each generation uses a random seed for unique terrains
Customizing Textures
Edit texture parameters in RENDERING section:
texture_variation: Increase for more dramatic color changestexture_detail_scale: Lower values = larger patternstexture_spots_threshold: Lower values = more dark spots- Textures are 16×16 pixels with GL_NEAREST filtering for retro look
Adding Camera Features
Extend the Camera class in src/camera/camera.py:
- Add rotation controls
- Implement smooth camera transitions
- Add camera presets
License
This project is provided as-is for educational purposes.