def update(): "Updates global components. Basically the clock. Should be called once every frame, regardless of the game state." if not paused: clock.update() else: clock.timeStep = 0 particles.ParticleGroup.begin() particles.update(not paused)
def run(self): #self.runMenu() #self.initNet() while 1: timer.tick() self.doNet() for event in pygame.event.get(): self.handleEvent(event, self.mywalker) if not simplenet.isClient: self.mainloop() particles.update() if simplenet.isServer: self.drawstuff() simplenet.sendall("gamestate", self.gamestate) else: #particles.update() self.drawstuff()
def run(params): """ Run the experiment """ samples = params.samples for params.ntimestep in range(0, params.ntimesteps): params.currentTime = params.ntimestep * params.timedelta particles.update(params) # get potential energy if samples.sampleCountdown == 0: measure.update(params) # measure system properties sample.update(params) # record samples views.update(params) # update views samples.nsample += 1 samples.sampleCountdown = samples.sampleInterval integrate.update( params) # integrate equations of motion, handle collisions samples.sampleCountdown -= 1
def run(self): while not self.done: if not self.pause: # update all game entities self.camera.update(self.player) self.groundSpeed = \ self.player.update( self.platforms, self.iceCoords, self.rocks) clouds.update(self.bgTime, self.totalGameTime, self.raining) for bird in self.birds: if pixelPerfectCollision(self.player, bird) != None: birds.update(bird) self.flyingBirds.append(bird) if self.flyingBirds != []: # bird animation for bird in self.flyingBirds: if bird.rect.top >= 0: birds.update(bird) else: self.flyingBirds.remove(bird) self.birds.remove(bird) for c in self.coins: if pixelPerfectCollision(self.player, c) != None: self.bgTime -= 1 coin.update(c) self.collectedCoins.append([c, 0]) if self.collectedCoins != []: # coin animation existCoins = False for i in range(len(self.collectedCoins)): c, num = self.collectedCoins[i] if c != None and num != None: existCoins = True if num <= 20: coin.update(c) num += 1 self.collectedCoins[i] = [c, num] else: self.collectedCoins[i] = [None, None] self.coins.remove(c) if not existCoins: self.collectedCoins = [] # no coins to update if self.raining: self.rain.update() if self.snowing: self.snow.update() particles.update(self.player.rect.centerx, self.player.rect.centery, self.player.angle, self.groundSpeed) if self.player.crashed and not self.noCrashes: self.exit = False self.setGameOver("You crashed! Press ENTER to exit.") elif self.player.crashed and self.noCrashes: self.player.crashed = False elif self.player.tooSteep and self.custom: self.exit = False self.setGameOver( "The slopes are too steep! Press ENTER to exit.") self.score.add(self.player.getScore()) self.draw() self.handleEvents() return self.score.getScore()