Add music and delay before end
This commit is contained in:
20
main.py
20
main.py
@@ -2,6 +2,7 @@ import tkinter as tk
|
||||
import datetime as dt
|
||||
import color
|
||||
import sys
|
||||
import pygame
|
||||
from game import fall, osu, pong, space
|
||||
from PIL import Image, ImageTk
|
||||
from time import sleep
|
||||
@@ -16,6 +17,7 @@ canvas_fall = None
|
||||
|
||||
# Res
|
||||
image_center = None
|
||||
AUDIO_THEME_001 = 'res/Audio/theme_001.ogg'
|
||||
|
||||
# Time
|
||||
time = None
|
||||
@@ -50,6 +52,9 @@ def ini(master):
|
||||
# Res
|
||||
image_center = ImageTk.PhotoImage(Image.open('res/logo/main.png'))
|
||||
|
||||
# Pygame
|
||||
pygame.init()
|
||||
|
||||
# Time
|
||||
score = tk.IntVar(win, 0)
|
||||
|
||||
@@ -109,6 +114,12 @@ def main(master = None, end = None):
|
||||
lobbyEnd = end
|
||||
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
|
||||
if sys.platform.startswith('win'):
|
||||
win.iconbitmap('res/logo/icon.ico')
|
||||
@@ -159,6 +170,15 @@ def end():
|
||||
global _end
|
||||
|
||||
_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())}')
|
||||
|
||||
# Terminate
|
||||
|
||||
Reference in New Issue
Block a user