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

Added sounds

parent aeade6c1
No related branches found
No related tags found
No related merge requests found
import pygame as pg
pg.mixer.init()
coin_sound = pg.mixer.Sound('assets/sounds/coins.wav')
bullet_sound = pg.mixer.Sound('assets/sounds/bullet.mp3')
# Set the volume of the sounds
coin_sound.set_volume(0.6)
bullet_sound.set_volume(0.2)
......@@ -16,7 +16,7 @@ class Turret(pg.sprite.Sprite):
# Turret stats
self.range = 200 # Range in pixels
self.attack_damage = 10
self.attack_cooldown = 0.25
self.attack_cooldown = 1
self.time_since_last_attack = self.attack_cooldown
def find_nearest_enemy(self, enemies: list[Enemy]) -> Enemy:
......
......@@ -2,6 +2,7 @@
import pygame as pg
from turret import Turret
from enemy import Zombie
import sound
class World:
......@@ -91,9 +92,11 @@ class World:
turret.time_since_last_attack += dt
if turret.time_since_last_attack >= turret.attack_cooldown:
target.hp -= turret.attack_damage
sound.bullet_sound.play()
if target.hp <= 0:
self.enemies.remove(target)
self.money += target.reward_on_death
sound.coin_sound.play()
turret.time_since_last_attack = 0
def draw(self):
......
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