Add music and delay before end

This commit is contained in:
2019-05-09 19:31:17 +02:00
parent 2c2575aad4
commit 25e217270b

20
main.py
View File

@@ -2,6 +2,7 @@ import tkinter as tk
import datetime as dt import datetime as dt
import color import color
import sys import sys
import pygame
from game import fall, osu, pong, space from game import fall, osu, pong, space
from PIL import Image, ImageTk from PIL import Image, ImageTk
from time import sleep from time import sleep
@@ -16,6 +17,7 @@ canvas_fall = None
# Res # Res
image_center = None image_center = None
AUDIO_THEME_001 = 'res/Audio/theme_001.ogg'
# Time # Time
time = None time = None
@@ -50,6 +52,9 @@ def ini(master):
# Res # Res
image_center = ImageTk.PhotoImage(Image.open('res/logo/main.png')) image_center = ImageTk.PhotoImage(Image.open('res/logo/main.png'))
# Pygame
pygame.init()
# Time # Time
score = tk.IntVar(win, 0) score = tk.IntVar(win, 0)
@@ -109,6 +114,12 @@ def main(master = None, end = None):
lobbyEnd = end lobbyEnd = end
ini(master) ini(master)
# Music
pygame.mixer.init()
pygame.mixer.music.load(AUDIO_THEME_001)
pygame.mixer.music.set_volume(0.2)
pygame.mixer.music.play()
# Logo # Logo
if sys.platform.startswith('win'): if sys.platform.startswith('win'):
win.iconbitmap('res/logo/icon.ico') win.iconbitmap('res/logo/icon.ico')
@@ -159,6 +170,15 @@ def end():
global _end global _end
_end = True _end = True
tk.Label(
win,
text = 'PERDU!',
bg = color.LEVEL_1,
fg = color.LEVEL_9,
font = (None, 48)
).place(relx = 0.5, rely = 0.5, anchor = tk.CENTER)
win.update()
sleep(1)
messagebox.showinfo('Perdu', f'Votre score est de {score.get()} points\n{getMessage(score.get())}') messagebox.showinfo('Perdu', f'Votre score est de {score.get()} points\n{getMessage(score.get())}')
# Terminate # Terminate