def __init__(self, level, game_score, enemy_in_game=[], i=0): self.load_level = LoadLevel() self.level = level self.level_map = self.load_level.load_level(level) self.enemy_in_game = enemy_in_game self.i = i self.type_for_level = dict(settings.LEVELS_ENEM) self.count_of_artillery = 0 self.artillery_position = self.load_level.artillery_position self.current_level = list(self.type_for_level[self.level]) self.count_of_enemy = len(self.type_for_level[self.level]) + len( self.artillery_position) self.game_over = screen.Screen() self.game_score = game_score self.best_score = score.load_score() self.is_game_over = False self.respawn_position_for_enemy = self.load_level.enemy_respawn_position self.bonus_position = self.load_level.bonus_respawn_position self.using_position = [] self.bonus_for_level = list(settings.LEVEL_BONUS[self.level]) self.bonus_in_game = [] self.period_for_bonus = 0 self.artillery_in_game = [] self.all_target_for_art = []
def wave_view(stdscr, input_file, args): """View wave form.""" raw_data = read_raw_data(input_file, args) one_channel_raw_data = data.OneChannelRawData(raw_data, args.selected_channel) curses.curs_set(0) top_screen = screen.Screen(stdscr, one_channel_raw_data) top_screen.clear() top_screen.init_display() # TODO: constraint cursor in view window. # TODO: show time stamp and value at cursor. while True: input_char = stdscr.getch() logging.debug('input char = %r', input_char) direction = None time_level_direction = None value_level_direction = None reset_view = None if 0 < input_char < 256: python_char = chr(input_char) if python_char in 'Qq': break elif python_char in 'O': time_level_direction = screen.ScaleDirection.UP elif python_char in 'o': time_level_direction = screen.ScaleDirection.DOWN elif python_char in 'P': value_level_direction = screen.ScaleDirection.UP elif python_char in 'p': value_level_direction = screen.ScaleDirection.DOWN elif python_char in 'Rr': reset_view = True # Ignore incorrect keys else: pass elif input_char == curses.KEY_UP: direction = screen.Direction.UP elif input_char == curses.KEY_DOWN: direction = screen.Direction.DOWN elif input_char == curses.KEY_LEFT: direction = screen.Direction.LEFT elif input_char == curses.KEY_RIGHT: direction = screen.Direction.RIGHT else: # Ignore incorrect keys pass if direction: # Move view. top_screen.wave_view_move(direction) elif time_level_direction: top_screen.wave_view_change_time_level(time_level_direction) elif value_level_direction: top_screen.wave_view_change_value_level(value_level_direction) elif reset_view: top_screen.wave_view_reset()
def main(): try: myscreen = screen.Screen() signal.pause() except KeyboardInterrupt: # if exit with ctrl + c shut off the screen print('Interrupted') try: myscreen.stop() sys.exit(0) except SystemExit: os._exit(0)
def main_loop(self): pygame.display.set_caption("Battle city") main_player = Player(145, 375, enemies=self.enemy_in_game, count_of_enemies=self.count_of_enemy, level_map=self.level_map, bonus_on_level=self.bonus_in_game) self.all_target_for_art.append(main_player) main_screen = screen.Screen() while not self.is_game_over: settings.TIMER.tick(60) settings.GAME_DISPLAY.fill((0, 0, 0)) main_screen.draw_sidebar(main_player, main_player.count_of_enemies, self.level) main_player.collision_missile_with_enemy() main_player.draw(settings.GAME_DISPLAY, PLAYER_SPRITE, (main_player.x, main_player.y)) self.respawn(main_player) main_player.collision_with_bonus() self.game_over_func(main_player, main_player) for elements in self.level_map: elements.draw(settings.GAME_DISPLAY) for bul in main_player.missile: bul.draw(settings.GAME_DISPLAY, MISSILE) Missile.bullet_operation(main_player.missile) for bomb in main_player.bomb: main_player.del_bomb(bomb) self.check_bonus_status() self.period_for_bonus += 1 main_player.enemy_collision_with_bomb() if self.load_level.artillery_position: self.create_artillery() if not self.enemy_in_game \ and not self.current_level \ and main_player.hp != 0: if self.level < 4: main_screen.next_level_screen(main_player, self.level, self.game_score) else: main_screen.victory_screen() for event in pygame.event.get(): if event.type == pygame.QUIT: self.is_game_over = True main_player.player_control(pygame.key.get_pressed()) pygame.display.update() pygame.quit()
#!/usr/bin/env python3 import argparse from screen import screen if __name__ == "__main__": parser = argparse.ArgumentParser() parser.add_argument('--game', '-G', action='store_const', const='1', help='This will be option One') if parser.parse_args().game == '1': screen = screen.Screen() screen.start_screen()