Beispiel #1
0
    def test_system(self):
        Engine.reset_indices()
        s = TestIteratingSystem()
        e1 = Entity()
        vel = VelocityComponent(1, 0, 0)
        pos = PositionComponent()
        e1.add(vel)
        e1.add(pos)
        engine = Engine()
        engine.add_entity(e1)
        engine.add_system(s)

        for i in range(10):
            engine.update(0.5)

        self.assertEqual(pos.x, 5.0)
Beispiel #2
0
	def test_system(self):
		Engine.reset_indices()
		s = TestIteratingSystem()
		e1 = Entity()
		vel = VelocityComponent(1,0,0)
		pos = PositionComponent()
		e1.add(vel)
		e1.add(pos)
		engine = Engine()
		engine.add_entity(e1)
		engine.add_system(s)

		for i in range(10):
			engine.update(0.5)

		self.assertEqual(pos.x, 5.0)
Beispiel #3
0
	def test_component(self):
		global COMPONENT_REMOVED
		global COMPONENT_ADDED

		Engine.reset_indices()
		engine = Engine()
		e1 = Entity()
		c = VelocityComponent()
		e1.component_added.append(TestComponentAddedListener())
		e1.component_removed.append(TestComponentRemovedListener())
		engine.add_entity(e1)
		e1.add(c)
		self.assertEqual(COMPONENT_ADDED, e1)
		reset_component_listener_test()

		family = Family.get_for_bits(ComponentType.get_bits_for(VelocityComponent))
		entities = engine.get_entities_for(family)
		self.assertEqual(entities[0], e1)

		e1.remove(VelocityComponent)
		self.assertEqual(COMPONENT_REMOVED, e1)
		reset_component_listener_test()
Beispiel #4
0
    def test_component(self):
        global COMPONENT_REMOVED
        global COMPONENT_ADDED

        Engine.reset_indices()
        engine = Engine()
        e1 = Entity()
        c = VelocityComponent()
        e1.component_added.append(TestComponentAddedListener())
        e1.component_removed.append(TestComponentRemovedListener())
        engine.add_entity(e1)
        e1.add(c)
        self.assertEqual(COMPONENT_ADDED, e1)
        reset_component_listener_test()

        family = Family.get_for_bits(
            ComponentType.get_bits_for(VelocityComponent))
        entities = engine.get_entities_for(family)
        self.assertEqual(entities[0], e1)

        e1.remove(VelocityComponent)
        self.assertEqual(COMPONENT_REMOVED, e1)
        reset_component_listener_test()
Beispiel #5
0
		self.graphics_list = graphics_list

class ParentTransformComponent(Component):
	def __init__(self, parent_entity):
		self.parent_entity = parent_entity

class SailSystem(IteratingSystem):
	family = Family.get_for_classes(SailComponent)


class RenderingSystem(IteratingSystem):
	family = Family.get_for_classes(GraphicsComponent)
	def __init__(self):
		super(RenderingSystem, self).__init__(self.family)

	def process_entity(self, entity, deltatime):
		print(entity, deltatime)



if __name__ == '__main__':
	engine = Engine()
	e1 = Entity()
	engine.add_entity(e1)
	e1.add(GraphicsComponent())

	rs = RenderingSystem()
	engine.add_system(rs)

	engine.update(1.0)