Skip to content

Instantly share code, notes, and snippets.

@feliperazeek
Created May 24, 2022 20:04
Show Gist options
  • Save feliperazeek/4d12c4ff2c20992905484c5ccffa50d3 to your computer and use it in GitHub Desktop.
Save feliperazeek/4d12c4ff2c20992905484c5ccffa50d3 to your computer and use it in GitHub Desktop.
Ty's Python Turtle Game
import turtle
import random
t = turtle.Turtle()
scorey = turtle.Turtle()
score = 0
t.goto(0,0)
scorey.penup()
scorey.goto(200,200)
t.setheading(90)
c = turtle.Turtle()
scorey.write('Use up arrow to jump!')
t.penup()
t.shape('square')
c.shape('circle')
s = turtle.Screen()
def jump():
t.forward(50)
t.penup()
t.goto(0,0)
s.onkey(jump,'up')
s.listen()
c.penup()
while True:
c.forward(400)
c.right(180)
c.forward(400)
score = score + 100
scorey.pendown()
scorey.clear()
scorey.write('Score: ' + str(score))
if abs(t.xcor() - c.xcor()) < 3 and abs(t.ycor() - c.ycor()) < 3:
t.write('GAME OVER')
break
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment