示例#1
0
    def test_entity_creation(self):
        s = Scene(None)
        e = s.entity(components = None, groups = None)

        self.assertEquals(len(s._entities), 1)


        s.add_entity(TestEntity())
        self.assertEquals(len(s._entities), 2)

        e = s.entity(components = [ComponentTest])
        self.assertEquals(len(s._entities), 3)

        e = s.entity(components = [ComponentTest], groups = ['one', 'two'])
        self.assertEquals(len(s._entities), 4)
示例#2
0
    def test_entity_retrieval(self):
        s = Scene(None)
        for i in range(10):
            s.entity()

        for i in range(20):
            s.entity(components = [ComponentTest])

        for i in range(30):
            s.entity(groups=['test'])

        self.assertEquals(len(list(s.get())), 60)
        self.assertEquals(len(list(s.get(ComponentTest))), 20)
        self.assertEquals(len(list(s.get().is_member_of('test'))), 30)