def engine_start(self): del self.greenlets['engine'] print('engine started') while True: if (len(self.players) == 1 and self.started): self.finished = True self.winning_logic() self.restart_game(11) break elif (len(self.players) == 0): self.finished = True self.restart_game() break t = uwsgi.micros() / 1000.0 for p in self.players.keys(): player = self.players[p] if player.cmd: draw = self.cmd_handler(player, player.cmd) if draw: player.update_gfx() player.cmd = None if player.attack_cmd: draw = self.attack_cmd_handler(player, player.attack_cmd) # print player.attack_cmd if draw: player.update_gfx() player.attack_cmd = None for animation in self.animations: animation.animate() t1 = uwsgi.micros() / 1000.0 delta = t1 - t if delta < 33.33: gevent.sleep((33.33 - delta) / 1000.0) self.greenlets['engine'] = self.engine_start print("engine ended")
def engine_start(self): del self.greenlets['engine'] print('engine started') while True: t = uwsgi.micros() / 1000.0 if len(self.players) == 1 and self.started: self.finished = True self.winning_logic() self.restart_game(11) break elif len(self.players) == 0: self.finished = True self.restart_game() break self.world.stepSimulation(1, 30) for p in self.players.keys(): player = self.players[p] # if player.cmd: # draw = self.cmd_handler(player, player.cmd) # draw = True # if draw: # player.update_gfx() # player.cmd = None if player.cmd: self.cmd_handler(player, player.cmd) player.cmd = None player.update_gfx() t1 = uwsgi.micros() / 1000.0 delta = t1 - t if delta < 33.33: gevent.sleep((33.33 - delta) / 1000.0) self.greenlets['engine'] = self.engine_start print("engine ended")
def physic_engine(world): while True: t = uwsgi.micros() / 1000.0 world.space.collide((world.world, world.contactgroup), near_callback) for name,box in world.boxes.items(): box.draw() world.world.step(1) world.contactgroup.empty() t1 = uwsgi.micros() / 1000.0 delta = t1 - t if delta < 33.33: gevent.sleep((33.33 - delta) / 1000.0)
def physic_engine(world): while True: t = uwsgi.micros() / 1000.0 world.world.stepSimulation(1, 30) for name,box in world.boxes.items(): box.draw() for name,ramp in world.ramps.items(): ramp.draw() t1 = uwsgi.micros() / 1000.0 delta = t1 - t if delta < 33.33: gevent.sleep((33.33 - delta) / 1000.0)
def physic_engine(world): while True: t = uwsgi.micros() / 1000.0 world.world.stepSimulation(1, 30) for name, box in world.boxes.items(): box.draw() for name, ramp in world.ramps.items(): ramp.draw() t1 = uwsgi.micros() / 1000.0 delta = t1 - t if delta < 33.33: gevent.sleep((33.33 - delta) / 1000.0)
def engine_start(self): del self.greenlets['engine'] print('engine started') self.world.setInternalTickCallback(self.cb, 17) self.sphere.trans.setOrigin(Vector3(0, 50, 0)) self.sphere.body.setLinearVelocity(Vector3(0, 0, 0)) self.sphere.body.setAngularVelocity(Vector3(0, 0, 0)) self.sphere.body.setWorldTransform (self.sphere.trans) while True: t = uwsgi.micros() / 1000.0 if not self.debug: if len(self.players) == 1 and self.started: self.finished.set() self.winning_logic() self.restart_game(10) break elif len(self.players) == 0: self.finished.set() self.restart_game() break self.world.stepSimulation(1, 30) self.sphere.update_gfx() for p in self.players.keys(): try: player = self.players[p] except KeyError: continue position = player.trans.getOrigin() if position.getY() < -420: player.end('loser') continue if not player.is_accelerating and not player.is_braking: player.vehicle.applyEngineForce(0, 0) player.vehicle.applyEngineForce(0, 1) player.vehicle.applyEngineForce(0, 2) player.vehicle.applyEngineForce(0, 3) player.is_braking = True else: velocity = player.chassis.getLinearVelocity() speed = velocity.length() if speed > (player.max_speed/2): new_speed = (player.max_speed/2) / speed velocity = Vector3( new_speed * velocity.getX(), new_speed * velocity.getY(), new_speed * velocity.getZ()) player.chassis.setLinearVelocity(velocity) elif speed < 0.001: quaternion = player.trans.getRotation() if not -0.5 < quaternion.getX() < 0.5 or not -0.5 < quaternion.getZ() < 0.5: player.end('loser') continue player.is_accelerating = False if player.cmd: self.cmd_handler(player, player.cmd) player.cmd = None if player.attack_cmd: self.attack_cmd_handler(player, player.attack_cmd) player.attack_cmd = None player.update_gfx() for bullet in self.bullets: bullet.animate() t1 = uwsgi.micros() / 1000.0 delta = t1 - t if delta < 33.33: gevent.sleep((33.33 - delta) / 1000.0) self.greenlets['engine'] = self.engine_start print("engine ended")