Skip to main content

A pythonic and fast Entity-Component-System written in pure Python

Project description

TOYBLOCK

Toyblock is yet another entity component system written in pure Python being fast as possible.

License

LGPL-3.0

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

toyblock-1.1.0-py2.py3-none-any.whl (7.4 kB view hashes)

Uploaded Python 2 Python 3

Supported by

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