def update(self, dt): self._play_text.update (dt); self._credits_text.update(dt); if(input.is_click(pygame.locals.K_UP)): self._update_selection(-1); elif(input.is_click(pygame.locals.K_DOWN)): self._update_selection(+1); elif(input.is_click(pygame.locals.K_SPACE)): if(self._curr_selection == 0): director.go_to_game(); else: director.go_to_credits();
def update(self, dt): self._play_text.update (dt); self._credits_text.update(dt); if(input.is_click(pygame.locals.K_UP)): self._update_selection(-1); elif(input.is_click(pygame.locals.K_DOWN)): self._update_selection(+1); elif(input.is_click(pygame.locals.K_SPACE)): sound.play_shot_sound(); if(self._curr_selection == 0): director.go_to_game(); else: director.go_to_credits();
def _update_playing(self, dt): ## Check if player wants to pause. if(input.is_click(K_p)): self._change_state_playing_to_paused(); return; ## Update the Enemies. self.enemy_mgr.update(dt); if(not self.enemy_mgr.did_finished_init()): return; ## Update the Player self.player.update(dt); ## Update the Projectile ## Restart the Projectile if needed. if(self.projectile.is_alive() == False and self.player.wants_to_shoot()): cannon_pos = self.player.get_cannon_position (); cannon_dir = self.player.get_cannon_direction(); self.projectile.restart(cannon_pos[0], cannon_pos[1], cannon_dir); self.projectile.update(dt); ## Check collisions hit = self.enemy_mgr.check_collision(self.projectile); ## If player hit an enemy, increment the score... if(hit): self.score += 1; self.hud.set_score(self.score); ## Check Game Status self._check_status();
def _update_playing(self, dt): ## Check if player wants to pause. if (input.is_click(K_p)): self._change_state_playing_to_paused() return ## Update the Enemies. self.enemy_mgr.update(dt) if (not self.enemy_mgr.did_finished_init()): return ## Update the Player self.player.update(dt) ## Update the Projectile ## Restart the Projectile if needed. if (self.projectile.is_alive() == False and self.player.wants_to_shoot()): cannon_pos = self.player.get_cannon_position() cannon_dir = self.player.get_cannon_direction() self.projectile.restart(cannon_pos[0], cannon_pos[1], cannon_dir) self.projectile.update(dt) ## Check collisions hit = self.enemy_mgr.check_collision(self.projectile) ## If player hit an enemy, increment the score... if (hit): self.score += 1 self.hud.set_score(self.score) ## Check Game Status self._check_status()
def _update_playing(self, dt): ## Input if input.is_click(pygame.locals.K_p): self._game_state = GameScene._STATE_PAUSED return ## Updates self._hud.update(dt) self._taz.update(dt) ## Taz is Dying or dead - We don't need ## update the Enemies anymore, them will be reseted ## when taz animation is done. if self._taz.get_state() != Taz.STATE_ALIVE: return taz_hit_box = self._taz.get_hit_box() ## Need to be calc'ed 1 time... for enemy in self._enemies: enemy.update(dt) ## Doesn't collided... if not enemy.check_collision(taz_hit_box): continue ## Collided if not enemy.is_fatal(): sound.play_eat() self._taz.make_eat() eat_count = self._taz.get_eat_count() self._hud.set_score(eat_count * GameScene._SCORE_MULTIPLIER) ## Ate enough enmies to accelerate them... if eat_count % GameScene._SPEED_UPDATE_COUNT == 0 and eat_count != 0: Enemy.Accelerate(GameScene._SPEED_ACCELERATION) else: sound.play_bomb() self._taz.kill()
def update(self, dt): if(input.is_click(pygame.locals.K_SPACE)): director.go_to_menu();
def _update_game_over(self, dt): ## Input if input.is_click(pygame.locals.K_SPACE): director.go_to_menu()
def _update_paused(self, dt): ## Input if input.is_click(pygame.locals.K_p): self._game_state = GameScene._STATE_PLAYING
def _update_game_over(self, dt): if(input.is_click(K_SPACE)): self._change_state_gameover_to_menu_screen();
def _update_defeat(self, dt): if(input.is_click(K_SPACE)): self._change_state_defeat_to_playing();
def _update_victory(self, dt): if(input.is_click(K_SPACE)): self._change_state_victory_to_playing();
def _update_paused(self, dt): if(input.is_click(K_p)): self._change_state_paused_to_playing();
def _update_game_over(self, dt): if (input.is_click(K_SPACE)): self._change_state_gameover_to_menu_screen()
def _update_defeat(self, dt): if (input.is_click(K_SPACE)): self._change_state_defeat_to_playing()
def _update_victory(self, dt): if (input.is_click(K_SPACE)): self._change_state_victory_to_playing()
def _update_paused(self, dt): if (input.is_click(K_p)): self._change_state_paused_to_playing()