A pythonic and fast Entity-Component-System written in pure Python
Project description
Toyblock is yet another entity component system written in pure Python being fast as possible.
License
Installation
pip install toyblock
Example usage
from time import time import toyblock #Our components for the entity class A: def __init__(self): self.x = 1 class B: def __init__(self): self.b = 0 entity = toyblock.Entity(A(), B()) #The order does not matter here def multiply_with_time(system, entity, time): """This will be the callable for our system.""" b = entity.get_component(B) a = entity.get_component(A) b.b = a.x*2*time() if b.b > 3: system.remove_entity(entity) main_system = toyblock.System(multiply_with_time, time) main_system.add_entity(entity) main_system.run() #Run the system
Pool
Toyblock provides you a Pool. A Pool helps you to manage large groups of entities (such bullets or enemies) and caches them for speed.
a_pool = toyblock.Pool(1000, (B, A)) # A pool of 1000 entities with A and B component a_entity = a_pool.get() # Get an avaliable entity a_pool.free(a_entity)
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
Built Distribution
Close
Hashes for toyblock-1.2.0-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2895c317ea6b0c398afa8706fc96cd7e19b7632458e0e8d312e9316c06037185 |
|
MD5 | 7a47f4e38759edf6d0aabbba8562bb84 |
|
BLAKE2b-256 | 615619eba29b478c4ba928ee7a5bf7224222d13dad2e317c12f79525d29db4fa |