コード例 #1
0
ファイル: controller.py プロジェクト: Barcol/bomberman
 def set_character_movement(character: Character, positive: bool,
                            negative: bool, direction: str):
     if direction == "vertical":
         character.moving_down = positive
         character.moving_up = negative
     if direction == "horizontal":
         character.moving_right = positive
         character.moving_left = negative
コード例 #2
0
ファイル: controller.py プロジェクト: Barcol/bomberman
 def check_keyup_events(event: EventType, character: Character):
     if event.key == pygame.K_RIGHT:
         character.moving_right = False
     if event.key == pygame.K_LEFT:
         character.moving_left = False
     if event.key == pygame.K_UP:
         character.moving_up = False
     if event.key == pygame.K_DOWN:
         character.moving_down = False
コード例 #3
0
ファイル: controller.py プロジェクト: Barcol/bomberman
 def check_keydown_events(self, event: EventType, game_settings: Settings,
                          screen: Surface, character: Character,
                          bombs: Group):
     if event.key == pygame.K_RIGHT:
         character.moving_right = True
     if event.key == pygame.K_LEFT:
         character.moving_left = True
     if event.key == pygame.K_UP:
         character.moving_up = True
     if event.key == pygame.K_DOWN:
         character.moving_down = True
     if event.key == pygame.K_SPACE:
         self.place_bomb(game_settings, screen, character, bombs)
     elif event.key == pygame.K_q:
         sys.exit()