diff --git a/assets/RETROTECH.ttf b/assets/RETROTECH.ttf new file mode 100644 index 0000000..edfbb7c Binary files /dev/null and b/assets/RETROTECH.ttf differ diff --git a/assets/blood-splatter.mp3 b/assets/blood-splatter.mp3 new file mode 100644 index 0000000..1f5d23d Binary files /dev/null and b/assets/blood-splatter.mp3 differ diff --git a/assets/music.mp3 b/assets/music.mp3 new file mode 100644 index 0000000..05184a3 Binary files /dev/null and b/assets/music.mp3 differ diff --git a/assets/upheavtt.ttf b/assets/upheavtt.ttf new file mode 100644 index 0000000..e374c97 Binary files /dev/null and b/assets/upheavtt.ttf differ diff --git a/game.py b/game.py index b7ddee7..9827214 100644 --- a/game.py +++ b/game.py @@ -3,6 +3,7 @@ import pygame import math import csv import random +import datetime # pygame setup pygame.init() @@ -139,6 +140,9 @@ class Pnj: village.final_boss() elif player.killcounter >= game.pnj_number+8: game.game_over() + # play sound effect + blood = pygame.mixer.Sound("assets/blood-splatter.mp3") + pygame.mixer.Sound.play(blood) class Village: def __init__(self, nb_pnj: int) -> None: @@ -173,7 +177,6 @@ class Village: objective_waypoint = start_waypoint.get_new_connected() self.liste_pnj.append(Pnj(start_waypoint.x, start_waypoint.y, "assets/pnj/knight.png", start_waypoint.get_direction(start_waypoint, objective_waypoint), objective_waypoint, 10)) - class Player: def __init__(self)-> None: self.x = 800 @@ -201,9 +204,9 @@ class Player: class Game: def __init__(self): self.is_paused = False - self.pnj_number = 5 + self.pnj_number = 20 pygame.font.init() - self.font = pygame.font.SysFont('Comic Sans MS', 30) + self.font = pygame.font.Font('assets/upheavtt.ttf', 60) self.load_sprites() self.load_collisions() @@ -235,6 +238,22 @@ class Game: screen.blit(kill_surface, (0,90)) #pygame.draw.rect(screen, "blue",pygame.Rect(player.x-50, player.y-50, 100, 100)) + def display_ui(self): + color = "black" + if player.killcounter < game.pnj_number: + kill_surface = self.font.render("Kills: "+str(player.killcounter)+"\\"+str(game.pnj_number), False, color) + else: + kill_surface = self.font.render("Kills: "+str(player.killcounter)+"\\"+str(game.pnj_number+8), False, color) + screen.blit(kill_surface, (10,0)) + + seconds = pygame.time.get_ticks()/1000 + seconds = seconds % (24 * 3600) + seconds %= 3600 + minutes = seconds // 60 + seconds %= 60 + time_surface = self.font.render("Time: "+str(int(minutes)).zfill(2)+":"+str(int(seconds)).zfill(2), False, color) + screen.blit(time_surface, (740,0)) + def check_input(self): keys = pygame.key.get_pressed() if keys[pygame.K_z]: @@ -264,15 +283,26 @@ class Game: self.draw_player() # We display it at the end so it's on top of all - self.display_debug_text() + # self.display_debug_text() + + self.display_ui() # flip() the display to put your work on screen pygame.display.flip() def game_over(self)->None: screen.blit(pygame.image.load("assets/gameover.png"), (0,0)) + seconds = pygame.time.get_ticks()/1000 + seconds = seconds % (24 * 3600) + seconds %= 3600 + minutes = seconds // 60 + seconds %= 60 + time_surface = self.font.render(str(int(minutes)).zfill(2)+":"+str(int(seconds)).zfill(2), False, "white") + screen.blit(time_surface, (500,500)) + # flip() the display to put your work on screen pygame.display.flip() + while True: for event in pygame.event.get(): if event.type == pygame.QUIT: @@ -283,6 +313,11 @@ game = Game() #pnj = Pnj(800, 900, "assets/MiniPeasant.png", "south", Waypoint("H"), 3) village = Village(game.pnj_number) +# start music +pygame.mixer.music.load("assets/music.mp3") +pygame.mixer.music.play(-1) + + while running: # poll for events # pygame.QUIT event means the user clicked X to close your window