From ad3602ba8b2ecc88a58f591dad20f0f3488914f5 Mon Sep 17 00:00:00 2001 From: Kaio Henrique Lopes Teixeira Date: Mon, 3 Feb 2025 20:52:20 +0000 Subject: [PATCH] Atualizar CatMaus/CatMaus.py --- CatMaus/CatMaus.py | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/CatMaus/CatMaus.py b/CatMaus/CatMaus.py index 88ae4b0..63275e4 100644 --- a/CatMaus/CatMaus.py +++ b/CatMaus/CatMaus.py @@ -6,16 +6,16 @@ tl.hideturtle() tl.colormode(255) t = tl.Turtle() t.color("Blue") -t.goto(100,0) +t.goto(-100,0) t2 = tl.Turtle() t2.color("Red") -t2.goto(-100,0) +t2.goto(100,0) tl.tracer(1) -che = tl.Turtle() -che.color("Yellow") -che.shape("square") -che.up() -che.goto(-600,600) +cheese = tl.Turtle() +cheese.color("Yellow") +cheese.shape("square") +cheese.up() +cheese.goto(-600,600) #CENÁRIO @@ -71,10 +71,13 @@ tl.tracer(1) #funções +global tem_queijo tem_queijo = False + #pass def colide(): + global tem_queijo rng = rd.randint(0,5) chance_tocheese = rd.randint(0,100) if t.distance(t2) < 10 and tem_queijo == False: @@ -85,26 +88,23 @@ def colide(): elif t2.pos()[1] > 250 or t2.pos()[1] < -300 or t2.pos()[0] > 300 or t2.pos()[0] < -300: t2.goto(0,0) + + elif t.distance(t2) < 10 and tem_queijo == True: + print("Vitoria do Rato") + tl.bye() + if chance_tocheese <= 5: tl.tracer(0) - che.goto(possible_pos[rng]) + cheese.goto(possible_pos[rng]) tl.update() tl.tracer(1) - if t.distance(che) < 10: + if t.distance(cheese) < 10: print("queijo coletado!") tem_queijo = True - che.hideturtle() - if t.distance(t2) < 10: - print("Vitoria do Rato!") + cheese.hideturtle() + - - - - - - - def godir(): tl.tracer(0) t.seth(0)