Initial Commit
This commit is contained in:
73
main.py
Normal file
73
main.py
Normal file
@@ -0,0 +1,73 @@
|
||||
import tkinter as tk
|
||||
import datetime as dt
|
||||
import color
|
||||
from time import sleep
|
||||
from game import fall, osu, pong, space
|
||||
from PIL import Image, ImageTk
|
||||
|
||||
win = tk.Tk()
|
||||
win['bg'] = color.LEVEL_9
|
||||
win.title('QuadraLudi')
|
||||
win.geometry('806x606')
|
||||
win.resizable(False, False)
|
||||
win.wm_attributes('-transparentcolor', color.TRANSPARENT)
|
||||
|
||||
# Res
|
||||
image_center = ImageTk.PhotoImage(Image.open('res/logo/main.png'))
|
||||
|
||||
# Time
|
||||
time = None
|
||||
delta = None
|
||||
iter = 0
|
||||
|
||||
def loop(deltaTime):
|
||||
global time, delta, iter
|
||||
|
||||
# Start
|
||||
delta = dt.datetime.now()
|
||||
deltatime = (delta - time).microseconds * 1e-6
|
||||
|
||||
# Loop
|
||||
if iter > 2:
|
||||
fall.loop(deltatime)
|
||||
osu.loop(deltatime)
|
||||
pong.loop(deltatime)
|
||||
space.loop(deltatime)
|
||||
else:
|
||||
iter += 1
|
||||
|
||||
# End
|
||||
time = delta
|
||||
win.after(int(1000 / 60), lambda: loop(deltaTime))
|
||||
|
||||
def main():
|
||||
global time, delta
|
||||
|
||||
# Create Canvas
|
||||
canvas_osu = tk.Canvas(win, width = 400, height = 300, bd = 0, highlightthickness = 0, relief = 'ridge', bg = color.LEVEL_1)
|
||||
canvas_osu.place(x = 2, y = 2)
|
||||
canvas_pong = tk.Canvas(win, width = 400, height = 300, bd = 0, highlightthickness = 0, relief = 'ridge', bg = color.LEVEL_1)
|
||||
canvas_pong.place(x = 404, y = 2)
|
||||
canvas_space = tk.Canvas(win, width = 400, height = 300, bd = 0, highlightthickness = 0, relief = 'ridge', bg = color.LEVEL_1)
|
||||
canvas_space.place(x = 2, y = 304)
|
||||
canvas_fall = tk.Canvas(win, width = 400, height = 300, bd = 0, highlightthickness = 0, relief = 'ridge', bg = color.LEVEL_1)
|
||||
canvas_fall.place(x = 404, y = 304)
|
||||
|
||||
# Logo
|
||||
win.iconbitmap('res/logo/main.ico')
|
||||
tk.Label(win, image = image_center, bg = color.LEVEL_1).place(x = 401 - 32, y = 301 - 32)
|
||||
|
||||
# Ini
|
||||
fall.main(canvas_fall)
|
||||
osu.main(canvas_osu)
|
||||
pong.main(canvas_pong)
|
||||
space.main(canvas_space)
|
||||
|
||||
# Loop
|
||||
delta = dt.datetime.now()
|
||||
time = dt.datetime.now()
|
||||
loop(1000 / 60)
|
||||
|
||||
print('Bienvenue dans le jeu QuadraLudi')
|
||||
main()
|
||||
win.mainloop()
|
||||
Reference in New Issue
Block a user