From 790faa8395fa1a09f19aa529886afd4aa1274754 Mon Sep 17 00:00:00 2001 From: WildTrack Date: Thu, 9 May 2019 19:02:43 +0200 Subject: [PATCH] Add progressive load --- main.py | 49 +++++++++++++++++++++++++++++++------------------ 1 file changed, 31 insertions(+), 18 deletions(-) diff --git a/main.py b/main.py index 7e81e5e..790fcae 100644 --- a/main.py +++ b/main.py @@ -9,6 +9,10 @@ from tkinter import messagebox # Var win = None +canvas_pong = None +canvas_osu = None +canvas_space = None +canvas_fall = None # Res image_center = None @@ -52,6 +56,17 @@ def ini(master): def loop(deltaTime): global time, delta, tick, score, difficulty + # Create Canvas + # Ini + if tick == 2: + pong.main(canvas_pong) + if tick == 200: + osu.main(canvas_osu) + if tick == 400: + fall.main(canvas_fall) + if tick == 600: + space.main(canvas_space) + # Check end if (_end): return @@ -63,9 +78,12 @@ def loop(deltaTime): # Loop try: if tick > 2: - fall.loop(deltatime, difficulty, end) - osu.loop(deltatime, difficulty, end) pong.loop(deltatime, difficulty, end) + if tick > 200: + osu.loop(deltatime, difficulty, end) + if tick > 400: + fall.loop(deltatime, difficulty, end) + if tick > 600: space.loop(deltatime, difficulty, end) except: return @@ -85,13 +103,20 @@ def loop(deltaTime): win.after(int(1000 / 60), lambda: loop(deltaTime)) def main(master = None, end = None): - global time, delta, lobbyEnd + global time, delta, lobbyEnd, canvas_pong, canvas_osu, canvas_fall, canvas_space # Ini lobbyEnd = end ini(master) - # Create Canvas + # Logo + if sys.platform.startswith('win'): + win.iconbitmap('res/logo/icon.ico') + else: + logo = tk.PhotoImage('res/logo/icon.png') + win.tk.call('wm', 'iconphoto', win._w, logo) + + # Canvas canvas_pong = tk.Canvas(win, width = 400, height = 300, bd = 0, highlightthickness = 0, relief = 'ridge', bg = color.LEVEL_1) canvas_pong.place(x = 2, y = 2) canvas_osu = tk.Canvas(win, width = 400, height = 300, bd = 0, highlightthickness = 0, relief = 'ridge', bg = color.LEVEL_1) @@ -101,24 +126,12 @@ def main(master = None, end = None): canvas_space = tk.Canvas(win, width = 400, height = 300, bd = 0, highlightthickness = 0, relief = 'ridge', bg = color.LEVEL_1) canvas_space.place(x = 404, y = 304) - # Logo - if sys.platform.startswith('win'): - win.iconbitmap('res/logo/icon.ico') - else: - logo = tk.PhotoImage('res/logo/icon.png') - win.tk.call('wm', 'iconphoto', win._w, logo) - - # tk.Label(win, image = image_center, bg = color.LEVEL_1).place(x = 401 - 32, y = 301 - 32) + # Center image + tk.Label(win, image = image_center, bg = color.LEVEL_1).place(x = 401 - 32, y = 301 - 32) # Score tk.Label(win, textvariable = score, bg = color.LEVEL_1, fg = color.BROWN, font = (None, 12)).place(x = 2, y = 2) - # 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()