Atualizar CatMaus/CatMaus.py

This commit is contained in:
Kaio Henrique Lopes Teixeira 2025-02-03 20:52:20 +00:00
parent 1720f77f00
commit ad3602ba8b
1 changed files with 19 additions and 19 deletions

View File

@ -6,16 +6,16 @@ tl.hideturtle()
tl.colormode(255) tl.colormode(255)
t = tl.Turtle() t = tl.Turtle()
t.color("Blue") t.color("Blue")
t.goto(100,0) t.goto(-100,0)
t2 = tl.Turtle() t2 = tl.Turtle()
t2.color("Red") t2.color("Red")
t2.goto(-100,0) t2.goto(100,0)
tl.tracer(1) tl.tracer(1)
che = tl.Turtle() cheese = tl.Turtle()
che.color("Yellow") cheese.color("Yellow")
che.shape("square") cheese.shape("square")
che.up() cheese.up()
che.goto(-600,600) cheese.goto(-600,600)
#CENÁRIO #CENÁRIO
@ -71,10 +71,13 @@ tl.tracer(1)
#funções #funções
global tem_queijo
tem_queijo = False tem_queijo = False
#pass #pass
def colide(): def colide():
global tem_queijo
rng = rd.randint(0,5) rng = rd.randint(0,5)
chance_tocheese = rd.randint(0,100) chance_tocheese = rd.randint(0,100)
if t.distance(t2) < 10 and tem_queijo == False: if t.distance(t2) < 10 and tem_queijo == False:
@ -85,23 +88,20 @@ def colide():
elif t2.pos()[1] > 250 or t2.pos()[1] < -300 or t2.pos()[0] > 300 or t2.pos()[0] < -300: elif t2.pos()[1] > 250 or t2.pos()[1] < -300 or t2.pos()[0] > 300 or t2.pos()[0] < -300:
t2.goto(0,0) t2.goto(0,0)
elif t.distance(t2) < 10 and tem_queijo == True:
print("Vitoria do Rato")
tl.bye()
if chance_tocheese <= 5: if chance_tocheese <= 5:
tl.tracer(0) tl.tracer(0)
che.goto(possible_pos[rng]) cheese.goto(possible_pos[rng])
tl.update() tl.update()
tl.tracer(1) tl.tracer(1)
if t.distance(che) < 10: if t.distance(cheese) < 10:
print("queijo coletado!") print("queijo coletado!")
tem_queijo = True tem_queijo = True
che.hideturtle() cheese.hideturtle()
if t.distance(t2) < 10:
print("Vitoria do Rato!")