def __init__(self, base, mapNo): self.isListening = False # Holds rigid bodies, joints, controls global params self.world = OdeWorld() self.world.setGravity(0, 0, -9.8) st = SurfaceType() st.load(self.world) del st self.contactgroup = OdeJointGroup() self.space = OdeHashSpace() self.space.setAutoCollideWorld(self.world) self.space.setAutoCollideJointGroup(self.contactgroup) self.space.setCollisionEvent(EventType.ODE_COLLISION) base.accept(EventType.ODE_COLLISION, self.onCollision) self.ball = Ball(self.world, self.space, "Johanneksen pallo") self.level = Level(self, mapNo) self.player = Player("Johannes") self.camera = Camera(base, self.ball)
def __init__(self, game): self.game = game self.world = OdeWorld() self.world.setGravity(0, 0, -9.81 * 3) self.group = OdeJointGroup() self.space = OdeHashSpace() self.space.setAutoCollideWorld(self.world) self.space.setAutoCollideJointGroup(self.group) self.setSurfaceTables() self.objects = [] self.objectsToRemove = [] self.postStepTasks = [] self.engineRunning = True self.dtAccumulator = 0.0 self.physicsFps = 90 self.physicsMinFps = 10 base.taskMgr.doMethodLater(0.1, self.processPhysics, "Physics") base.accept("escape", self.togglePhysics) self.space.setCollisionEvent("odeCollision") base.accept("odeCollision", self.onCollision)
def __init__(self): # Disable Panda's base camera mover base.disableMouse() base.setBackgroundColor(0, 0, 0, 0) self.state = Game.STATE_INITIALIZING # contains a list of the ships in game self.ships = None self.players = None self.bullets = None self.stars = None self.planet = None self.time = 0.0 self.isListening = False getModelPath().prependDirectory(Filename('./media/')) self.physWorld = OdeWorld() self.physWorld.setGravity(0, 0, 0) self.physWorld.initSurfaceTable(1) self.physWorld.setSurfaceEntry( 0, 0, 1.0, # u .35, # elasticity .01, # minimum threshold for physical movement .01, # .00000001, # softening .01, # .01) # dampening self.physSpace = OdeHashSpace() self.winnerText = None self.gameFrames = 0 self.lastWarp = 0 self.cameraMode = Game.CAMERA_MODE_GAME self.lastCameraPos = None self.pause = False