Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
12903783
Turtle Tennis
Commits
302ed548
Commit
302ed548
authored
Oct 21, 2019
by
12903783
Browse files
Added turtle obstacle.
parent
10be050b
Changes
1
Hide whitespace changes
Inline
Side-by-side
turtle-tennis
View file @
302ed548
...
...
@@ -40,8 +40,8 @@ ball = turtle.Turtle()
ball.shape("turtle")
ball.color("#d2fc03")
ball.penup()
ball.dx =
4
ball.dy =
4
ball.dx =
6.1
ball.dy =
6.1
#Scoreboard 1
scoreboard1 = turtle.Turtle()
...
...
@@ -67,6 +67,14 @@ scoreboard2.pendown()
score_2 = 0
scoreboard2.write("{}".format(score_2), font=("Arial Black", "60"))
#Obstacle
obstacle = turtle.Turtle()
obstacle.shape("turtle")
obstacle.color("brown")
obstacle.penup()
obstacle.goto(100,-150)
obstacle.shapesize(3,3)
#Movement
def racquet1up():
...
...
@@ -114,7 +122,7 @@ while True:
scoreboard1.write("{}".format(score_1), font=("Arial Black", "60"))
if score_1 > 41:
scoreboard1.clear()
scoreboard1.write("
tits
".format(score_1), font=("Arial Black", "60"))
scoreboard1.write("
{}
".format(score_1
-5
), font=("Arial Black", "60"))
if ball.ycor() < -290:
ball.sety(-290)
ball.dy *= -1
...
...
@@ -134,3 +142,7 @@ while True:
ball.dx *= -1
if (ball.xcor() < -275 and ball.xcor() > -285) and (ball.ycor() < racquet1.ycor() +100 and ball.ycor() > racquet1.ycor() -100):
ball.dx *= -1
if (ball.xcor() > obstacle.xcor() -20 and ball.xcor() < obstacle.xcor() + 20) and (ball.ycor() > obstacle.ycor() -20 and ball.ycor() < obstacle.ycor() + 20):
ball.dx *= -1
obstacle.left(475)
obstacle.forward(200)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment