From 7535a6be755316b3e196b1b31577dbed6cf7063e Mon Sep 17 00:00:00 2001 From: valdoucet Date: Mon, 7 Dec 2020 19:56:07 +0100 Subject: [PATCH] code fini sauf tubes --- code.py | 48 ++++++++++++++++++++++++++++++++++-------------- 1 file changed, 34 insertions(+), 14 deletions(-) diff --git a/code.py b/code.py index b4f815a..0e999f6 100644 --- a/code.py +++ b/code.py @@ -3,27 +3,47 @@ import pgzrun TITLE = "vava bird" WIDTH = 490 HEIGHT = 490 - +tb = Actor("bottom", (500, 600)) +th = Actor("top", (500, -100)) +oiseau = Actor("bird1", (245, 15)) +end = 0 d = 2 -g = 1 +g = 2 +c = -35 +gm = -2 +def draw(): + screen.blit("back", (0, 0)) + oiseau.draw() + th.draw() + tb.draw() def update(): - global d - if oiseau.y < 470: - oiseau.x += d - if oiseau.y < 470: - oiseau.y += d - if oiseau.y >= 470: - print("Game Over") + global end + + if oiseau.y == 475 and end == 0: + print("--Game over--") + end = 1 + + if oiseau.y < 475 and end == 0: + th.x += gm + tb.x += gm + + if oiseau.y <= 15: + oiseau.y == 15 + if end == 0 and (oiseau.colliderect(tb) or oiseau.colliderect(th)): + print("--Game over--") + end = 1 + + if oiseau.y < 475 and end == 0 : + oiseau.y += g + + def on_mouse_down(): - print ('') + if oiseau.y > 15: + oiseau.y += c -def draw(): - screen.blit("back", (0, 0)) - oiseau.draw() -oiseau = Actor("bird1", (20, 15)) pgzrun.go()