-
Notifications
You must be signed in to change notification settings - Fork 0
/
Scene.py
41 lines (34 loc) · 1.36 KB
/
Scene.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import importlib
class Scene:
setScene = False
staticObjects = {}
physicsObjects = {}
staticObjList = []
physicsObjList = []
def __init__(self, dir):
#defining all objects
for objName in self.staticObjList:
gameMod = importlib.import_module("gameObjects." + objName,dir)
gameClass = getattr(gameMod,objName)
gameObj = gameClass()
self.staticObjects.update({objName: gameObj})
for objName in self.physicsObjList:
gameMod = importlib.import_module("gameObjects." + objName,dir)
gameClass = getattr(gameMod,objName)
gameObj = gameClass()
self.physicsObjects.update({objName, gameObj})
def getPhysicsObjects(self):
return self.physicsObjects
def getStaticObjects(self):
return self.staticObjects
def process(self, screen):
for obj in self.physicsObjects:
currentObj = self.physicsObjects[obj]
currentObj.process()
screen.blit(currentObj.spriteImg, (currentObj.posx,currentObj.posy))
for obj in self.staticObjects:
currentObj = self.staticObjects[obj]
if currentObj.change == True:
currentObj.process()
currentObj.change == False
screen.blit(currentObj.spriteImg, (currentObj.posx,currentObj.posy))