More content added, weapons, coin collecting, basic combat.
This commit is contained in:
		| @@ -27,34 +27,36 @@ class WickedQuest: | ||||
|     def handle_input(self): | ||||
|         keys = pygame.key.get_pressed() | ||||
|         player = self.currentLevel.player | ||||
|         currentTime = pygame.time.get_ticks() | ||||
|      | ||||
|         # Calculate current speed based on jumping state | ||||
|         currentSpeed = player.moveSpeed * 1.5 if player.isJumping else player.moveSpeed | ||||
|      | ||||
|         # Track movement distance for this frame | ||||
|         movement = 0 | ||||
|         movementDistance = 0 | ||||
|      | ||||
|         # Horizontal movement | ||||
|         if keys[pygame.K_a]:  # Left | ||||
|             movement = currentSpeed | ||||
|             movementDistance = currentSpeed | ||||
|             player.xPos -= currentSpeed | ||||
|             player.facingRight = False | ||||
|         elif keys[pygame.K_d]:  # Right | ||||
|             movement = currentSpeed | ||||
|             movementDistance = currentSpeed | ||||
|             player.xPos += currentSpeed | ||||
|             player.facingRight = True | ||||
|          | ||||
|         # Handle attack with either CTRL key | ||||
|         if (keys[pygame.K_LCTRL] or keys[pygame.K_RCTRL]) and player.start_attack(currentTime): | ||||
|             self.sounds[player.currentWeapon.attackSound].play() | ||||
|              | ||||
|         # Play footstep sounds if moving and not jumping | ||||
|         if movement > 0 and not player.isJumping: | ||||
|             player.distanceSinceLastStep += movement | ||||
|         if movementDistance > 0 and not player.isJumping: | ||||
|             player.distanceSinceLastStep += movementDistance | ||||
|             if player.distanceSinceLastStep >= player.stepDistance: | ||||
|                 self.sounds['footstep'].play() | ||||
|                 player.distanceSinceLastStep = 0 | ||||
|  | ||||
|         # Handle jumping | ||||
|         currentTime = pygame.time.get_ticks() | ||||
|      | ||||
|         # Start jump | ||||
|         if keys[pygame.K_w] and not player.isJumping: | ||||
|             player.isJumping = True | ||||
|             player.jumpStartTime = currentTime | ||||
| @@ -69,7 +71,9 @@ class WickedQuest: | ||||
|     def game_loop(self): | ||||
|         clock = pygame.time.Clock() | ||||
|          | ||||
|         while True: | ||||
|         while self.currentLevel.player.get_health() > 0 and self.currentLevel.player.get_lives() > 0: | ||||
|             currentTime = pygame.time.get_ticks() | ||||
|              | ||||
|             if check_for_exit(): | ||||
|                 return | ||||
|                  | ||||
| @@ -79,13 +83,21 @@ class WickedQuest: | ||||
|             self.currentLevel.update_audio() | ||||
|             self.currentLevel.handle_collisions() | ||||
|              | ||||
|             # Handle combat interactions | ||||
|             self.currentLevel.handle_combat(currentTime) | ||||
|              | ||||
|             clock.tick(60)  # 60 FPS | ||||
|              | ||||
|         # Player died or ran out of lives | ||||
|         speak("Game Over") | ||||
|  | ||||
|     def run(self): | ||||
|         while True: | ||||
|             choice = game_menu(self.sounds, "play", "instructions", "learn_sounds", "credits", "donate") | ||||
|             choice = game_menu(self.sounds, "play", "instructions", "learn_sounds", "credits", "donate", "exit") | ||||
|              | ||||
|             if choice == "play": | ||||
|             if choice == "exit": | ||||
|                 exit_game() | ||||
|             elif choice == "play": | ||||
|                 if self.load_level(1): | ||||
|                     self.game_loop() | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user