Add difficulty

This commit is contained in:
2019-03-18 19:30:03 +01:00
parent fbfbb93444
commit 952832745d
5 changed files with 25 additions and 13 deletions

29
main.py
View File

@@ -18,25 +18,35 @@ image_center = ImageTk.PhotoImage(Image.open('res/logo/main.png'))
# Time
time = None
delta = None
iter = 0
tick = 0
score = tk.IntVar(win, 0)
difficulty = 1.0
MAX_DIFFICULTY = 3.0
DIFFICULTY_STEP = (MAX_DIFFICULTY - difficulty) / 5000
def loop(deltaTime):
global time, delta, iter, score
global time, delta, tick, score, difficulty
# 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)
if tick > 2:
fall.loop(deltatime, difficulty)
osu.loop(deltatime, difficulty)
pong.loop(deltatime, difficulty)
space.loop(deltatime, difficulty)
score.set(int(iter / 5))
iter += 1
# Step tick
tick += 1
score.set(int(tick / 5))
# Step difficulty
if difficulty < MAX_DIFFICULTY:
difficulty += DIFFICULTY_STEP
elif difficulty > MAX_DIFFICULTY:
difficulty = MAX_DIFFICULTY
# End
time = delta
@@ -73,6 +83,7 @@ def main():
time = dt.datetime.now()
loop(1000 / 60)
print('Bienvenue dans le jeu QuadraLudi')
main()
win.mainloop()