Skip to content
Snippets Groups Projects
Commit f67e3f1d authored by Jantz's avatar Jantz
Browse files

sounds added

parent 61d8bde0
No related branches found
No related tags found
No related merge requests found
File added
File added
......@@ -109,6 +109,8 @@ def main():
gui.draw_text(world.window, f"ROUND: {world.current_round}", (world.window_resolution[0] - gui.margin, gui.margin), 'topright')
# Draw money balance
gui.draw_text(world.window, f"MONEY: {world.money}", (world.window_resolution[0] - gui.margin, gui.margin * 2 + gui.font_size), 'topright')
# Draw the player health to bottom right corner
gui.draw_text(world.window, f"HEALTH: {world.player_health}", (world.window_resolution[0] - gui.margin, world.window_resolution[1] - gui.margin), 'bottomright')
# Debug drawing, comment out if not needed.
#world.draw_debug()
......
import pygame as pg
from random import choice
pg.mixer.init()
coin_sound = pg.mixer.Sound('assets/sounds/coins.wav')
bullet_sound = pg.mixer.Sound('assets/sounds/bullet.mp3')
zombie_groan_1 = pg.mixer.Sound('assets/sounds/zombie_groan_1.mp3')
zombie_groan_2 = pg.mixer.Sound('assets/sounds/zombie_groan_2.mp3')
# Set the volume of the sounds
coin_sound.set_volume(0.6)
bullet_sound.set_volume(0.2)
zombie_groan_1.set_volume(0.2)
zombie_groan_2.set_volume(0.2)
def play_zombie_groan():
"""Plays a random zombie groan sound."""
choice([zombie_groan_1, zombie_groan_2]).play()
\ No newline at end of file
......@@ -49,6 +49,7 @@ class World:
# Player stats
self.money = 1000
self.player_health = 100
def generate_enemy_spawn_times(self, round_index: int) -> list[tuple[any, int]]:
"""
......@@ -90,12 +91,16 @@ class World:
# Rotate the turret to face the target
turret.face_at_the_current_target(target)
turret.time_since_last_attack += dt
# Attack the target if the cooldown has passed
if turret.time_since_last_attack >= turret.attack_cooldown:
target.hp -= turret.attack_damage
sound.bullet_sound.play()
# Detect if the target is dead
if target.hp <= 0:
self.enemies.remove(target)
self.money += target.reward_on_death
sound.play_zombie_groan()
sound.coin_sound.play()
turret.time_since_last_attack = 0
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment