__author__ = '29173' import turtle,random,time def die(t): screen.tracer(8,0) t.color("black") for i in range(10): t.dot(2*i+10,"orange") t.dot(2*i+9,"white") t.clear() t.color("blue") screen.tracer(1,0) steps = 0 screen = turtle.Screen() screen.colormode(255) turs = turtle.Turtle() turs.pu() turs.ht() turs.color("red") turd = turtle.Turtle() turd.pu() turd.shape("turtle") turt = turtle.Turtle() turt.pu() turt.ht() turn = turtle.Turtle() turn.pu() turn.ht() turn.color("orange") screen.tracer(10,0) turk = turtle.Turtle() turk.ht() turk.pu() turk.color("purple") turp = turtle.Turtle() turp.ht() turp.pu() turp.color("pink") aa = 0 a = 0 death = 6 dif = 4 wi = 0 while aa >= 0 and aa <= 4: turd.clear() turk.clear() turp.clear() turn.clear() turt.clear() x = [[7 for h in range(20)] for h in range(20)] y = [[0 for h in range(20)] for h in range(20)] for i in range(20): for j in range(20): r = random.randrange(1,dif + 6) if r == 1: y[i][j] = 1 else: y[i][j] = 0 turp.goto(-230,-230) turp.setheading(90) for i in range(4): turp.begin_fill() for j in range(2): turp.forward(440) turp.right(90) turp.forward(20) turp.right(90) turp.end_fill() turp.forward(440) turp.right(90) turd.goto(0,-200) turd.color("blue") wi += 1 a = 0 dif -= 1 death -= 1 charge = 2 deaths = 0 spawnx = 0 spawny = -200 winx = 10 winy = 15 wins = 0 while a == 0: screen.tracer(10,0) turs.clear() turk.clear() turs.goto(0,210) pen = "Checkpoints:" + str(wins) + "/" + str(wi) turs.write(pen,align = "center",font=("Arial",16,"normal")) turs.goto(0,-250) pen = "Deaths:" + str(deaths) + "/" + str(death) turs.write(pen,align="center",font=("Arial",16,"normal")) turk.goto(0,10) turk.color("red") pen = "Level " + str(aa + 1) turk.write(pen,align="center",font=("Arial",32,"normal")) turk.goto( winx * 20 - 210, winy * 20 - 210) turk.setheading(90) turk.color("purple") turk.begin_fill() for i in range(4): turk.forward(20) turk.right(90) turk.end_fill() if charge > 0: turk.color("plum") turk.goto(-10,-10) turk.setheading(90) turk.begin_fill() for i in range(4): turk.forward(20) turk.right(90) turk.end_fill() turk.color("purple") screen.tracer(1,0) for i in range(5): for j in range(5): y[i + 8][j + 8] = 0 for i in range(5): for j in range(3): y[i + 8][j] = 0 y[winx][winy] = 0 b = str(raw_input()) if b == 'w': turd.setheading(90) turd.goto(turd.xcor(),turd.ycor()+20) if b == 'a': turd.setheading(180) turd.goto(turd.xcor()-20,turd.ycor()) if b == 's': turd.setheading(270) turd.goto(turd.xcor(),turd.ycor()-20) if b == 'd': turd.setheading(0) turd.goto(turd.xcor()+20,turd.ycor()) corex = int((turd.xcor() + 200)/ 20) corey = int((turd.ycor() + 200)/ 20) if corex == winx and corey == winy: wins += 1 turd.left(720) spawnx = turd.xcor() spawny = turd.ycor() winx = random.randrange(0,20) winy = random.randrange(0,20) if wins == wi: print("You win!") a = 1 aa += 1 else: turd.goto(spawnx,spawny) elif corey < 0 or corey > 20: print("Out of bounds") turd.forward(-20) elif corex < 0 or corey > 20: print("Out of bounds") turd.forward(-20) elif corex == 10 and corey == 10: if charge > 0: winx = random.randrange(0,20) winy = random.randrange(0,20) charge -= 1 elif y[corex][corey] == 1: print("Died") die(turd) deaths += 1 if deaths == death+1: a = 1 print("Died too many times") aa = -1 turd.goto(spawnx,spawny) corex = int(turd.xcor() + 200)// 20 corey = int(turd.ycor() + 200)//20 else: x[corex][corey] += 1 steps += 1 turt.goto(turd.xcor() - 10, turd.ycor() - 10) color = x[corex][corey] if color <= 15: turt.color(255-(color**2),255,255-(color**2)) elif color <= 16: turt.color("yellow") else: y[corex][corey] = 1 turt.color("orange") turt.setheading(90) turt.begin_fill() for i in range(4): turt.forward(20) turt.right(90) turt.end_fill() turd.st() turn.clear() screen.tracer(100,0) if corey + 3 >= 0 and corey + 3 < 20: for var in [-3,-2,-1,0,1,2,3]: if corex + var >= 0 and corex + var < 20: if y[corex + var][corey + 3] == 1: turn.color("orange") turn.goto((corex + var)* 20 - 210,(corey + 3) * 20 -210) turn.setheading(90) turn.begin_fill() for i in range(4): turn.forward(20) turn.right(90) turn.end_fill() else: turn.color("bisque") turn.goto((corex + var)* 20 - 210,(corey + 3) * 20 -210) turn.setheading(90) turn.begin_fill() for i in range(4): turn.forward(20) turn.right(90) turn.end_fill() if corey - 3 >= 0 and corey - 3 < 20: for var in [-3,-2,-1,0,1,2,3]: if corex + var >= 0 and corex + var < 20: if y[corex + var][corey - 3] == 1: turn.color("orange") turn.goto((corex + var)* 20 - 210,(corey - 3) * 20 -210) turn.setheading(90) turn.begin_fill() for i in range(4): turn.forward(20) turn.right(90) turn.end_fill() else: turn.color("bisque") turn.goto((corex + var)* 20 - 210,(corey - 3) * 20 -210) turn.setheading(90) turn.begin_fill() for i in range(4): turn.forward(20) turn.right(90) turn.end_fill() if corex + 3 >= 0 and corex + 3 < 20: for var in [-3,-2,-1,0,1,2,3]: if corey + var >= 0 and corey + var < 20: if y[corex + 3][corey + var] == 1: turn.color("orange") turn.goto((corex + 3)* 20 - 210,(corey + var) * 20 -210) turn.setheading(90) turn.begin_fill() for i in range(4): turn.forward(20) turn.right(90) turn.end_fill() else: turn.color("bisque") turn.goto((corex + 3)* 20 - 210,(corey + var) * 20 -210) turn.setheading(90) turn.begin_fill() for i in range(4): turn.forward(20) turn.right(90) turn.end_fill() if corex - 3 >= 0 and corex - 3 < 20: for var in [-3,-2,-1,0,1,2,3]: if corey + var >= 0 and corey + var < 20: if y[corex - 3][corey + var] == 1: turn.color("orange") turn.goto((corex - 3)* 20 - 210,(corey + var) * 20 -210) turn.setheading(90) turn.begin_fill() for i in range(4): turn.forward(20) turn.right(90) turn.end_fill() else: turn.color("bisque") turn.goto((corex - 3)* 20 - 210,(corey + var) * 20 -210) turn.setheading(90) turn.begin_fill() for i in range(4): turn.forward(20) turn.right(90) turn.end_fill() turs.clear() turk.clear() if aa == -1: turs.goto(0,10) pen = "Turtle Toast" turs.write(pen,align="center",font=("Arial",32,"normal")) print(steps) screen.exitonclick() if aa == 5: turs.goto(0,10) pen = "Success!" turs.write(pen,align="center",font=("Arial",32,"normal")) aa = 0 turd.clear() turk.clear() turp.clear() turn.clear() turt.clear() while aa >= 0 and aa <= 4: turns = 0 turd.clear() turk.clear() turp.clear() turn.clear() turt.clear() x = [[7 for h in range(20)] for h in range(20)] y = [[0 for h in range(20)] for h in range(20)] for i in range(20): for j in range(20): r = random.randrange(1,dif + 6) if r == 1: y[i][j] = 1 else: y[i][j] = 0 turp.goto(-230,-230) turp.setheading(90) for i in range(4): turp.begin_fill() for j in range(2): turp.forward(440) turp.right(90) turp.forward(20) turp.right(90) turp.end_fill() turp.forward(440) turp.right(90) turd.goto(0,-200) turd.color("blue") wi += 1 a = 0 dif -= 1 death -= 1 charge = 2 deaths = 0 spawnx = 0 spawny = -200 winx = 10 winy = 15 wins = 0 while a == 0: screen.tracer(10,0) turs.clear() turk.clear() turs.goto(0,210) pen = "Checkpoints:" + str(wins) + "/" + str(wi) turs.write(pen,align = "center",font=("Arial",16,"normal")) turs.goto(0,-250) pen = "Deaths:" + str(deaths) + "/" + str(death) turs.write(pen,align="center",font=("Arial",16,"normal")) turk.goto(0,10) turk.color("red") pen = "Level " + str(aa + 1) turk.write(pen,align="center",font=("Arial",32,"normal")) turk.goto( winx * 20 - 210, winy * 20 - 210) turk.setheading(90) turk.color("purple") turk.begin_fill() for i in range(4): turk.forward(20) turk.right(90) turk.end_fill() if charge > 0: turk.color("plum") turk.goto(-10,-10) turk.setheading(90) turk.begin_fill() for i in range(4): turk.forward(20) turk.right(90) turk.end_fill() turk.color("purple") screen.tracer(1,0) for i in range(5): for j in range(5): y[i + 8][j + 8] = 0 for i in range(5): for j in range(3): y[i + 8][j] = 0 y[winx][winy] = 0 b = str(raw_input()) if b == 'w': turd.setheading(90) turd.goto(turd.xcor(),turd.ycor()+20) if b == 'a': turd.setheading(180) turd.goto(turd.xcor()-20,turd.ycor()) if b == 's': turd.setheading(270) turd.goto(turd.xcor(),turd.ycor()-20) if b == 'd': turd.setheading(0) turd.goto(turd.xcor()+20,turd.ycor()) corex = int((turd.xcor() + 200)/ 20) corey = int((turd.ycor() + 200)/ 20) if corex == winx and corey == winy: wins += 1 turd.left(720) spawnx = turd.xcor() spawny = turd.ycor() winx = random.randrange(0,20) winy = random.randrange(0,20) if wins == wi: print("You win!") a = 1 aa += 1 else: turd.goto(spawnx,spawny) elif corey < 0 or corey > 20: print("Out of bounds") turd.forward(-20) elif corex < 0 or corey > 20: print("Out of bounds") turd.forward(-20) elif corex == 10 and corey == 10: if charge > 0: winx = random.randrange(0,20) winy = random.randrange(0,20) charge -= 1 elif y[corex][corey] == 1: print("Died") die(turd) deaths += 1 if deaths == death+1: a = 1 print("Died too many times") aa = -1 turd.goto(spawnx,spawny) corex = int(turd.xcor() + 200)// 20 corey = int(turd.ycor() + 200)//20 else: x[corex][corey] += 1 steps += 1 turt.goto(turd.xcor() - 10, turd.ycor() - 10) color = x[corex][corey] if color <= 15: turt.color(255-(color**2),255,255-(color**2)) elif color <= 16: turt.color("yellow") else: y[corex][corey] = 1 turt.color("orange") turt.setheading(90) turt.begin_fill() for i in range(4): turt.forward(20) turt.right(90) turt.end_fill() turd.st() turn.clear() screen.tracer(100,0) turn.clear() screen.tracer(1000,0) if turns == 0: for i in range(20): for j in range(20): if y[i][j] == 1: turn.color("orange") turn.goto((i)* 20 - 210,(j) * 20 -210) turn.setheading(90) turn.begin_fill() for k in range(4): turn.forward(20) turn.right(90) turn.end_fill() else: turn.color("bisque") turn.goto((i)* 20 - 210,(j) * 20 -210) turn.setheading(90) turn.begin_fill() for k in range(4): turn.forward(20) turn.right(90) turn.end_fill() screen.tracer(1,0) time.sleep(0.2) turn.clear() if turns == 5: turns = 0 else: turns += 1 turs.clear() turk.clear() if aa == -1: turs.clear() turs.goto(0,10) pen = "Turtle Toast" turs.write(pen,align="center",font=("Arial",32,"normal")) screen.exitonclick() aa = -1 if aa == 5: turs.clear() turs.goto(0,10) pen = "Success!" turs.write(pen,align="center",font=("Arial",32,"normal")) aa = 0 while aa >= 0 and aa <= 4: turd.clear() turk.clear() turp.clear() turn.clear() turt.clear() x = [[7 for h in range(20)] for h in range(20)] y = [[0 for h in range(20)] for h in range(20)] for i in range(20): for j in range(20): r = random.randrange(1,dif + 6) if r == 1: y[i][j] = 1 else: y[i][j] = 0 turp.goto(-230,-230) turp.setheading(90) for i in range(4): turp.begin_fill() for j in range(2): turp.forward(440) turp.right(90) turp.forward(20) turp.right(90) turp.end_fill() turp.forward(440) turp.right(90) turd.goto(0,-200) turd.color("blue") wi += 1 a = 0 dif -= 1 death -= 1 charge = 2 deaths = 0 spawnx = 0 spawny = -200 winx = 10 winy = 15 wins = 0 while a == 0: screen.tracer(10,0) turs.clear() turk.clear() turs.goto(0,210) pen = "Checkpoints:" + str(wins) + "/" + str(wi) turs.write(pen,align = "center",font=("Arial",16,"normal")) turs.goto(0,-250) pen = "Deaths:" + str(deaths) + "/" + str(death) turs.write(pen,align="center",font=("Arial",16,"normal")) turk.goto(0,10) turk.color("red") pen = "Level " + str(aa + 1) turk.write(pen,align="center",font=("Arial",32,"normal")) turk.goto( winx * 20 - 210, winy * 20 - 210) turk.setheading(90) turk.color("purple") turk.begin_fill() for i in range(4): turk.forward(20) turk.right(90) turk.end_fill() if charge > 0: turk.color("plum") turk.goto(-10,-10) turk.setheading(90) turk.begin_fill() for i in range(4): turk.forward(20) turk.right(90) turk.end_fill() turk.color("purple") screen.tracer(1,0) for i in range(5): for j in range(5): y[i + 8][j + 8] = 0 for i in range(5): for j in range(3): y[i + 8][j] = 0 y[winx][winy] = 0 b = str(raw_input()) if b == 'w': turd.setheading(90) turd.goto(turd.xcor(),turd.ycor()+20) if b == 'a': turd.setheading(180) turd.goto(turd.xcor()-20,turd.ycor()) if b == 's': turd.setheading(270) turd.goto(turd.xcor(),turd.ycor()-20) if b == 'd': turd.setheading(0) turd.goto(turd.xcor()+20,turd.ycor()) corex = int((turd.xcor() + 200)/ 20) corey = int((turd.ycor() + 200)/ 20) if corex == winx and corey == winy: wins += 1 turd.left(720) spawnx = turd.xcor() spawny = turd.ycor() winx = random.randrange(0,20) winy = random.randrange(0,20) if wins == wi: print("You win!") a = 1 aa += 1 else: turd.goto(spawnx,spawny) elif corey < 0 or corey > 20: print("Out of bounds") turd.forward(-20) elif corex < 0 or corey > 20: print("Out of bounds") turd.forward(-20) elif corex == 10 and corey == 10: if charge > 0: winx = random.randrange(0,20) winy = random.randrange(0,20) charge -= 1 elif y[corex][corey] == 1: print("Died") die(turd) deaths += 1 if deaths == death+1: a = 1 print("Died too many times") aa = -1 turd.goto(spawnx,spawny) corex = int(turd.xcor() + 200)// 20 corey = int(turd.ycor() + 200)//20 else: x[corex][corey] += 1 steps += 1 turt.goto(turd.xcor() - 10, turd.ycor() - 10) color = x[corex][corey] if color <= 15: turt.color(255-(color**2),255,255-(color**2)) elif color <= 16: turt.color("yellow") else: y[corex][corey] = 1 turt.color("orange") turt.setheading(90) turt.begin_fill() for i in range(4): turt.forward(20) turt.right(90) turt.end_fill() turd.st() turn.clear() screen.tracer(100,0) turn.color("bisque") for i in [-3,-2,-1,0,1,2,3]: for j in [-3,-2,-1,0,1,2,3]: if corex + i < 20 and corex + i >= 0: if corey + j < 20 and corey + j >= 0: if y[corex+i][corey+j] == 1: turn.goto(turt.xcor()+ 10,turt.ycor()+ 10) turn.pd() turn.goto((corex + i) * 20 - 200,(corey + j ) * 20 -200) turn.dot(10,"orange") turn.goto((corex - i) * 20 -200,(corey - j ) * 20 - 200) turn.dot(10,"orange") turn.goto(turt.xcor() + 10,turt.ycor() + 10) turn.goto((corex + i) * 20 - 200,(corey-j) * 20 - 200) turn.dot(10,"orange") turn.goto((corex - i) * 20 - 200, (corey + j) * 20 -200) turn.dot(10,"orange") turn.pu() turs.clear() turk.clear() if a == -1: turs.clear() turs.goto(0,10) pen = "Turtle Toast" turs.write(pen,align="center",font=("Arial",32,"normal")) screen.exitonclick() aa = -1 if a == 5: turs.clear() turs.goto(0,10) pen = "Success!" turs.write(pen,align="center",font=("Arial",32,"normal")) aa = 0