Skip to content

Instantly share code, notes, and snippets.

@Larseda
Last active December 17, 2015 17:03
Show Gist options
  • Save Larseda/c5dca0d4c7114905e065 to your computer and use it in GitHub Desktop.
Save Larseda/c5dca0d4c7114905e065 to your computer and use it in GitHub Desktop.
Python Spiel #1
from turtle import *
from random import *
shape("turtle")
def spielfeld():
pass
#Spielfeld gestalte
#Figur gestalten
def teste_ziel():
print(round(xcor()),round(ycor()))
if round(xcor())==x and round(ycor())==y:
write("Juhu")
clear()
spielfeld()
block()
def teste_spielfeld():
if round(xcor())<0 or round(xcor())>100:
backward(10)
write("AUA!")
undo()
if round(ycor())<0 or round(ycor())>100:
backward(10)
write("AUA!")
undo()
def f():
fd(10)
teste_spielfeld()
teste_ziel()
def l():
left(90)
def r():
right(90)
def block ():
global x,y
x=randint(0,10)*10
y=randint(0,10)*10
up()
goto(x,y)
dot(10)
goto(0,0)
spielfeld()
block()
onkey(f,"Up")
onkey(l,"Left")
onkey(r,"Right")
listen()
print(x,y)
mainloop()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment