def play(): """ creating players :return: """ print("Please, enter your name: ", end='') name = input() level = settings.START_ENEMY_LEVEL player = models.Player(name) enemy = models.Enemy(level) command = '' while command != 'start': print("To start the game enter 'start' here: ", end='') command = input() player.verify_commands(command) while True: try: print(player.attack(enemy)) print(player.defence(enemy)) except exceptions.EnemyDown: player.scores_up(5) level += 1 enemy = models.Enemy(level) print( f'Enemy down. \n' f'Going to LEVEL {level}. Player has {player.lives} lives from {settings.START_LIVES} and' f' {player.score} scores.') return None
def play(): global player_name player_name = input("Please enter your name\n") player = models.Player(player_name) level = 1 opponent = models.Enemy(level) start_game = input("Write 'start' to start the game\n") if start_game == 'start': while True: try: player.attack(opponent) player.defence(opponent) except exceptions.EnemyDown: level += 1 opponent = models.Enemy(level) settings.score = (level - 1) * 5 + player.allowed_attacks
def play(): name = print(input('Welcome to the game! Please enter your name here: ')) player_one = models.Player(name) enemy_one = models.Enemy() while True: try: player_one.attack(enemy_one) player_one.defence(enemy_one) except exceptions.EnemyDown: if enemy_one.lives == 0: player_one.lives += 5 enemy_two = models.Enemy() except exceptions.GameOver: with open('scores.txt', 'a+') as file: file.write(player_one.name + ' ' + player_one.score + '\n') raise
def __load_level(self, x_offset, y_offset, level, layout, images): for y in range(len(layout)): for x in range(len(layout[y])): '''Get the center point for the rects''' center_point = [(x * config.block_size) + x_offset, (y * config.block_size + y_offset)] if layout[y][x] == level.BLOCK: self.block_sprites.add( models.BasicSprite(center_point, images[level.BLOCK])) elif layout[y][x] == level.GWALL: self.gwall_sprites.add( models.BasicSprite(center_point, images[level.GWALL])) elif layout[y][x] == level.PACMAN: self.pacman = models.Pacman(center_point, images[level.PACMAN]) elif layout[y][x] == level.PELLET: self.pellet_sprites.add( models.BasicSprite(center_point, images[level.PELLET], colorkey=-1)) elif layout[y][x] == level.BLINKY: self.enemies.append( models.Enemy(center_point, images[level.BLINKY], colorkey=-1)) elif layout[y][x] == level.INKY: self.enemies.append( models.Enemy(center_point, images[level.INKY], colorkey=-1)) elif layout[y][x] == level.PINKY: self.enemies.append( models.Enemy(center_point, images[level.PINKY], colorkey=-1)) elif layout[y][x] == level.CLYDE: self.enemies.append( models.Enemy(center_point, images[level.CLYDE], colorkey=-1))
def play(): print("Enter your name") name = input() print("Enter start") start = input() player = models.Player(name) level = 1 enemy = models.Enemy(level) global score score = 0 score = models.Player(score) while True: try: player.attack(enemy) player.defense(enemy) except exceptions.EnemyDown: level += 1 print("Enemy down, meet new enemy with level ", level) enemy = models.Enemy(level)
def play(): """Beginning of the game""" start = input("To start the game enter 'start': ") if start != 'start': print('You entered incorrect data!') play() else: print("Enter your name, please: ") name = input() player = models.Player(name) level = 1 enemy = models.Enemy(level) while True: try: player.attack(enemy) player.defense(enemy) except exceptions.EnemyDown: level += 1 player.score += 5 print("The enemy is defeated, increase the level to: ", level) enemy = models.Enemy(level)
def play(): name = input('Welcome to the game! Please enter your name to start: ') player_one = models.Player(name) enemy_one = models.Enemy() while True: try: player_one.attack(enemy_one) player_one.defence(enemy_one) except exceptions.GameOver: with open('scores.txt', 'a+') as file: file.write( str(player_one.name) + ' ' + str(player_one.score) + '\n') break except exceptions.EnemyDown: print('Your enemy has been slain \n New enemy is ready to fight. ') player_one.score += 5 enemy_two = models.Enemy() while True: player_one.attack(enemy_two) player_one.defence(enemy_two) if player_one.lives == 0 or enemy_two.lives == 0: break
def play(): global player_name player_name = input('Enter your name\n') player = models.Player(player_name, settings.PLAYER_LIVES).score level = 1 enemy = models.Enemy(level) while True: user_input = input( 'Введите "start" для начала игры или "help" - для просмотра доступных команд\n' ) if user_input == 'help': settings.show_command() elif user_input == 'start': while True: try: player.attack(enemy) player.defence(enemy) except exceptions.EnemyDown: enemy = models.Enemy(level + 1)\ elif user_input == 'exit': raise exceptions.Exit
def play(): """ start game """ while True: name = input("input your name:\n") if len(name) <= 10: break else: print("max count char is 10\n") player = models.Player(name) level = 1 enemy = models.Enemy(level) print(f"LEVEL {level}") while True: try: if player.attack(enemy) == "done": if player.defence(enemy) == "done": settings.pause() settings.clear_area() except exceptions.EnemyDown: print("Enemy down") player.score += 5 level += 1 enemy = models.Enemy(level) break