Skip to main content

A package which can implement and draw the diamond-square in pgzero.

Project description

Diamond Square

Implementation of the Diamond Square Algorithm. This package can draw terrain on pgzero and pygame, also can set up interactive mode.

Interactive mode is only supported by pgzero. If you are using this package in pygame, you cannot use the interactive mode, but you can use the terrain generation.

Sample Generations:

Sample Default Terrain Sample Desert Terrain Sample Tundra Terrain Sample Tropical Terrain Sample Volcanic Terrain Sample Swamp Terrain Sample Ocean Terrain Sample Mars Terrain Sample Extreme Mars Terrain

Usage:

Drawing Terrain:

Use terrain = generate_terrain(roughness=..., biome=..., scale=..., size=...) to generate terrain. Once you generate terrain and store it in a variable, the terrain won't draw unless you call terrain.draw(screen).

When you pass in the screen parameter for terrain.draw(screen), this is expecting the pgzero screen or the pygame display surface. For pgzero, just enter screen for the screen parameter. This will have a yellow underline under it, but do not worry because this is what is supposed to happen.

Drawing interactive Terrain:

Use terrain = generate_interactive_mode(size=..., start_biome=..., max_roughness=..., scale=..., start_roughness=...) to generate an interactive scence which the user can interact and change the biome and roughness. Once you generate the interactive terrain and store it in a variable, the terrain won't draw unless you call terrain.for_draw(screen) in the draw function, terrain.for_on_mouse_down(pos) in the on_mouse_down function, terrain.for_on_mouse_up() in the on_mouse_up function, and terrain.for_on_mouse_move(pos) in the on_mouse_move function.

If you leave out any one of these, then it will create unexpected results or fail. As of latest version, drawing interactive terrains is not suppored by pygame. You can only use this in pgzero.

For the draw function, when you pass in the screen parameter for terrain.draw(screen), this is expecting the pgzero screen or the pygame display surface. For pgzero, just enter screen for the screen parameter. This will have a yellow underline under it, but do not worry because this is what is supposed to happen.

Versions:

Version 0.0.1: Main code for diamond-square added.

Version 0.0.2: Updated REAMDE file and added documentation.

Version 0.0.3: Fixed bugs and errors

Version 0.0.4: Added sample terrain.

(Latest) Version 0.0.5: Added sample terrains.

Coming Soon:

Version 0.0.6: Added a function to add/remove biomes and added parameter pos to determine where to place the terrain.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

diamond_square-0.0.5.tar.gz (5.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

diamond_square-0.0.5-py3-none-any.whl (6.2 kB view details)

Uploaded Python 3

File details

Details for the file diamond_square-0.0.5.tar.gz.

File metadata

  • Download URL: diamond_square-0.0.5.tar.gz
  • Upload date:
  • Size: 5.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for diamond_square-0.0.5.tar.gz
Algorithm Hash digest
SHA256 deabed8f3e07371e6d6c9153d39864bb4712efac49720840f04f60d970915ac3
MD5 8371a97f2e29735c32be3a237f386745
BLAKE2b-256 65249543ed61f8df0174eb6e658aa619872d8f6ded1807bed9fd9d92bdb66107

See more details on using hashes here.

File details

Details for the file diamond_square-0.0.5-py3-none-any.whl.

File metadata

  • Download URL: diamond_square-0.0.5-py3-none-any.whl
  • Upload date:
  • Size: 6.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for diamond_square-0.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 0802fcccf113a4229dc2b2f5d28b233b70eaea0b7d53e03ac110ddc7b569a523
MD5 ca3a3a4de47913f768b4840375a5536c
BLAKE2b-256 23b1f18f34c7723c22340bcc133f8c0f9a47482b778d409051d627c37019f754

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page