Diamond Square
Implementation of the Diamond–Square Algorithm. This package can draw terrain on pgzero and pygame, and can also set up interactive mode.
Sample Generations
⚠️ You MUST include all four interactive functions for pgzero interactive
Missing even one will cause failures or unpredictable behavior.
Table of Contents
- Why Use Diamond Square?
- Usage
- Pgzero Terrain Example
- Pgzero Interactive Terrain Example
- Pygame Terrain Example
- Pygame Interactive Terrain Example
- Image Saving Examples
- Custom Biome Examples
- Requirements for Pgzero Interactive
- Versions
- Coming Soon
Why Use diamond-square?
This package provides a complete implementation of the Diamond–Square algorithm with:
-
Fast rendering of the Diamond-Square algorithm written in C.
-
Multiple built‑in biomes.
-
Adjustable roughness and scale.
-
Support for pgzero and pygame.
-
Optional interactive mode.
-
The ability to save generated terrain as an image.
-
Functions to add or remove biomes dynamically.
It is designed for both experimentation and game development, making terrain generation simple and customizable.
Usage
Pgzero Terrain Example
Go to /sample_codes/pgzero_terrain.py
Pgzero Interactive Terrain Example
Go to /sample_codes/pgzero_interactive_terrain.py
Pygame Terrain Example
Go to /sample_codes/pygame_terrain.py
Pygame Interactive Terrain Example
Go to /sample_codes/pygame_interactive_terrain.py
Image Saving Examples
Go to /sample_codes/save_terrain.py
Custom Biome Examples
Go to /sample_code/custom_biome.py
Requirements for Pgzero Interactive
For Pgzero Interative Mode, it requires all four of the following functions to be placed in their corresponding pgzero event handlers:
terrain.draw_func(screen)
terrain.on_mouse_down_func(pos)
terrain.on_mouse_up_func()
terrain.on_mouse_move_func(pos)
If any one of these is missing, the interactive mode will:
-
fail to update correctly
-
behave unpredictably
-
or stop working entirely
These must be placed in these functions in pgzero:
-
def draw():→terrain.draw_func(screen) -
on_mouse_down(pos):→terrain.on_mouse_down_func(pos) -
on_mouse_up():→terrain.on_mouse_up_func() -
on_mouse_move(pos):→terrain.on_mouse_move_func(pos)
Versions
(Latest) Version 0.2.0: Add re-generate button for interactive mode in pygame.
Version 0.1.9: Improve speed in C file and fix bugs.
Version 0.1.8: Add remake terrain button for interactive mode in pgzero.
To view previous versions, go to versions.txt
Coming Soon
Version 1.0.0: Added 3D Terrain Generation in Pgzero and Pygame.
Metadata
Release files for diamond-square 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| diamond_square-0.2.0.tar.gz | 15.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| diamond_square-0.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 30.9 kB
Release files / diamond_square-0.2.0.tar.gz
| Download URL | diamond_square-0.2.0.tar.gz |
|---|---|
| Size | 15.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f335f9125f389297404d0ca6baf15463a52bfbe8dd77a230cfca3882c152a4cc
|
|
BLAKE2b-256 checksum How to use checksums |
20abeebf8188b533c6430fda8209a0d081e26d26ef550a664e10914301d5600b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.7
|
Release files / diamond_square-0.2.0-py3-none-any.whl
| Download URL | diamond_square-0.2.0-py3-none-any.whl |
|---|---|
| Size | 15.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
53edb17c717f579bbb44adb49ab2b716e88b90cd634768965777a58e705ed4fb
|
|
BLAKE2b-256 checksum How to use checksums |
07453a2f55f097471f30cadddc7c187df8e49e10d05c74ae9e000670c3f9107b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.7
|