Add progressive load
This commit is contained in:
49
main.py
49
main.py
@@ -9,6 +9,10 @@ from tkinter import messagebox
|
|||||||
|
|
||||||
# Var
|
# Var
|
||||||
win = None
|
win = None
|
||||||
|
canvas_pong = None
|
||||||
|
canvas_osu = None
|
||||||
|
canvas_space = None
|
||||||
|
canvas_fall = None
|
||||||
|
|
||||||
# Res
|
# Res
|
||||||
image_center = None
|
image_center = None
|
||||||
@@ -52,6 +56,17 @@ def ini(master):
|
|||||||
def loop(deltaTime):
|
def loop(deltaTime):
|
||||||
global time, delta, tick, score, difficulty
|
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
|
# Check end
|
||||||
if (_end):
|
if (_end):
|
||||||
return
|
return
|
||||||
@@ -63,9 +78,12 @@ def loop(deltaTime):
|
|||||||
# Loop
|
# Loop
|
||||||
try:
|
try:
|
||||||
if tick > 2:
|
if tick > 2:
|
||||||
fall.loop(deltatime, difficulty, end)
|
|
||||||
osu.loop(deltatime, difficulty, end)
|
|
||||||
pong.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)
|
space.loop(deltatime, difficulty, end)
|
||||||
except:
|
except:
|
||||||
return
|
return
|
||||||
@@ -85,13 +103,20 @@ def loop(deltaTime):
|
|||||||
win.after(int(1000 / 60), lambda: loop(deltaTime))
|
win.after(int(1000 / 60), lambda: loop(deltaTime))
|
||||||
|
|
||||||
def main(master = None, end = None):
|
def main(master = None, end = None):
|
||||||
global time, delta, lobbyEnd
|
global time, delta, lobbyEnd, canvas_pong, canvas_osu, canvas_fall, canvas_space
|
||||||
|
|
||||||
# Ini
|
# Ini
|
||||||
lobbyEnd = end
|
lobbyEnd = end
|
||||||
ini(master)
|
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 = 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_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)
|
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 = tk.Canvas(win, width = 400, height = 300, bd = 0, highlightthickness = 0, relief = 'ridge', bg = color.LEVEL_1)
|
||||||
canvas_space.place(x = 404, y = 304)
|
canvas_space.place(x = 404, y = 304)
|
||||||
|
|
||||||
# Logo
|
# Center image
|
||||||
if sys.platform.startswith('win'):
|
tk.Label(win, image = image_center, bg = color.LEVEL_1).place(x = 401 - 32, y = 301 - 32)
|
||||||
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)
|
|
||||||
|
|
||||||
# Score
|
# Score
|
||||||
tk.Label(win, textvariable = score, bg = color.LEVEL_1, fg = color.BROWN, font = (None, 12)).place(x = 2, y = 2)
|
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
|
# Loop
|
||||||
delta = dt.datetime.now()
|
delta = dt.datetime.now()
|
||||||
time = dt.datetime.now()
|
time = dt.datetime.now()
|
||||||
|
|||||||
Reference in New Issue
Block a user