Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #IMPORTOWANIE BIBLIOTEKI
- import turtle
- import random
- #KONFIGURUJE ZOLWIA
- stas = turtle.Turtle()
- stas.speed(0)
- stas.width(5)
- stas.shape("turtle")
- stas.color("indian red")
- stas.screen.setup(1280, 880)
- turtle.bgcolor("snow")
- colors = ['red', 'blue', 'green', 'wheat']
- def gora():
- if ( stas.ycor() < 400) :
- stas.setheading(90)
- stas.forward(100)
- def dol():
- if ( stas.ycor() > -400 ) :
- stas.setheading(270)
- stas.forward(100)
- def lewo():
- if (stas.xcor() > -600) :
- stas.setheading(180)
- stas.forward(100)
- def prawo():
- if (stas.xcor() < 600) :
- stas.setheading(0)
- stas.forward(100)
- def zmienKolor():
- stas.color(random.choice(colors))
- def mazakWGore():
- stas.penup()
- def mazakWDol():
- stas.pendown()
- #czyszczenie planszy
- def wyczyscWszystko():
- stas.clear()
- #komenda powodujaca "nasluch" klawiatury
- turtle.listen()
- turtle.onkey(gora, 'Up')
- turtle.onkey(dol, 'Down')
- turtle.onkey(prawo, 'Right')
- turtle.onkey(lewo, 'Left')
- turtle.onkey(zmienKolor, 'space')
- turtle.onkey(mazakWGore, 'g')
- turtle.onkey(mazakWDol, 'd')
- turtle.onkey(wyczyscWszystko, 'c')
- #petla glowna programu
- turtle.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement