Minecraft like block world in Python
Project description
PyBlockWorld
Eine an Minecraft angelehnte Welt aus Blöcken.
Installation
Die Installation erfolgt über pip install pyblockworld
.
API
from pyblockworld import World
#
# BEISPIEL 1
#
# Eine Funktion, die beim Drücken der B-Taste aufgerufen werden soll
def b_key_pressed(world:World):
print("B pressed. Player at", world.player_position())
# Erstellen einer neuen Welt
world = World()
# Die Funktion für die build-Taste (b) wird zugewiesen
world.build_key_pressed = b_key_pressed
# Die Welt wird gestartet
world.run()
#
# BEISPIEL 2
#
# Nun werden beim Drücken der Taste ein paar Blöcke platziert.
def b_key_pressed(world:World):
# Neue Blöcke können mit setBlock gesetzt werden.
# Verfügbare Materialien stehen in World.MATERIALS und umfassen
# air, default:brick, default:stone, default:sand, default:grass
print("Block types", World.MATERIALS)
x,y,z = world.player_position()
# Einen Block platzieren
world.setBlock(x,y,z, "default:brick")
# Mehrere Blöcke auf einmal abseits des Spielers platzieren
x,y,z = x,y,z+3
world.setBlocks(x,y,z, x+3,y+3,z+3, "default:grass")
world = World()
world.build_key_pressed = b_key_pressed
world.run()
Quellen
Der Quellcode basiert auf dem Code von SensorCraft, der wiederum auf dem Code von Craft basiert.
Changelog
-
0.3.8
- Methoden der Klasse World dokumentiert.
-
0.3.5
- Changelog eingeührt
- Support für Python 3.8
-
0.3.7
- PeristentWorld als speicherbare Welt hinzugefügt.
- Doku aktualisiert: Abschnitt Start entfernt.
- World.player_position hat das Attribut as_int, um ein Int-Tuple zu erzeugen
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pyblockworld-0.3.8.2.tar.gz
(17.4 kB
view hashes)
Built Distribution
Close
Hashes for pyblockworld-0.3.8.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4aa4cd1e62efdeb1c819bcff4c7bef6671a1e114ef31ac4f7d91d39e7c0ac056 |
|
MD5 | 8386aa5436aa971e6fcf621ca150b654 |
|
BLAKE2b-256 | 9f00ea9795818028092b436d1d7f7b6641c0aa0e8d89e4dd66685c23236a4a51 |