Skip to content

Commit

Permalink
add minimal example
Browse files Browse the repository at this point in the history
  • Loading branch information
chromy committed Oct 23, 2015
1 parent e424d22 commit 2d86502
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions examples/minimal.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import essence

class Position(essence.Component):
def __init__(self, x, y):
self.x = x
self.y = y

class PhysicsSystem(essence.System):
def __init__(self, gravity):
self.gravity = gravity

def update(self, world):
for e in world.entites:
e.get(Position).y -= self.gravity

class RenderSystem(essence.System):
def update(self, world):
for e in world.entites:
# Render entity...

if __name__ == '__main__':
world = essence.World()
world.systems.append(PhysicsSystem(2))
world.systems.append(RenderSystem(2))

player = world.create_entity()
player.add(Position(10, 10))

while True:
world.update()

0 comments on commit 2d86502

Please sign in to comment.