Commit d5f65eb6 authored by 12903783's avatar 12903783
Browse files

Fixed score and added 2nd turtle obstacle.

parent 302ed548
......@@ -67,7 +67,7 @@ scoreboard2.pendown()
score_2 = 0
scoreboard2.write("{}".format(score_2), font=("Arial Black", "60"))
#Obstacle
#Obstacles
obstacle = turtle.Turtle()
obstacle.shape("turtle")
obstacle.color("brown")
......@@ -75,6 +75,13 @@ obstacle.penup()
obstacle.goto(100,-150)
obstacle.shapesize(3,3)
obstacle2 = turtle.Turtle()
obstacle2.shape("turtle")
obstacle2.color("purple")
obstacle2.penup()
obstacle2.goto(-50,110)
obstacle2.shapesize(4,4)
#Movement
def racquet1up():
......@@ -117,12 +124,27 @@ while True:
ball.sety(0)
ball.showturtle()
ball.dx *= -1
score_1 += 15
score_1 += 1
if score_1 == 1:
scoreboard1.clear()
scoreboard1.write("{}".format(15), font=("Arial Black", "60"))
score_1 += 0.1
if score_1 == 2.1:
scoreboard1.clear()
scoreboard1.write("{}".format(30), font=("Arial Black", "60"))
score_1 += 0.1
if score_1 == 3.2:
scoreboard1.clear()
scoreboard1.write("{}".format(score_1), font=("Arial Black", "60"))
if score_1 > 41:
scoreboard1.write("{}".format(40), font=("Arial Black", "60"))
score_1 += 0.1
if (score_1 > 4.3 and score_2 < 4.3):
scoreboard1.clear()
scoreboard1.write("{}".format(score_1 -5), font=("Arial Black", "60"))
scoreboard1.penup()
scoreboard1.setx(-230)
scoreboard1.write("Winner", font=("Arial Black", "40"))
scoreboard2.clear()
scoreboard2.write("Loser", font=("Arial Black", "40"))
break
if ball.ycor() < -290:
ball.sety(-290)
ball.dy *= -1
......@@ -132,17 +154,41 @@ while True:
ball.sety(0)
ball.showturtle()
ball.dx *= -1
score_2 += 15
score_2 += 1
if score_2 == 1:
scoreboard2.clear()
scoreboard2.write("{}".format(15), font=("Arial Black", "60"))
score_2 += 0.1
if score_2 == 2.1:
scoreboard2.clear()
scoreboard2.write("{}".format(30), font=("Arial Black", "60"))
score_2 += 0.1
if score_2 == 3.2:
scoreboard2.clear()
scoreboard2.write("{}".format(score_2), font=("Arial Black", "60"))
if score_2 > 41:
scoreboard2.clear
scoreboard2.write("{}".format(score_1 -5), font=("Arial Black", "60"))
scoreboard2.write("{}".format(40), font=("Arial Black", "60"))
score_2 += 0.1
if (score_2 > 4.3 and score_1 < 4.3):
scoreboard2.clear()
scoreboard2.write("Winner", font=("Arial Black", "40"))
scoreboard1.clear()
scoreboard1.penup()
scoreboard1.setx(-210)
scoreboard1.write("Loser", font=("Arial Black", "40"))
break
if (ball.xcor() > 275 and ball.xcor() < 285) and (ball.ycor() < racquet2.ycor() +100 and ball.ycor() > racquet2.ycor() -100):
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.color("red")
obstacle.left(475)
obstacle.forward(200)
ball.showturtle()
ball.dx *= -1
obstacle.color("brown")
if (ball.xcor() > obstacle2.xcor() -30 and ball.xcor() < obstacle2.xcor() + 30) and (ball.ycor() > obstacle2.ycor() -30 and ball.ycor() < obstacle2.ycor() + 30):
obstacle2.color("red")
ball.dx *= -1
obstacle2.right(510)
obstacle2.forward(100)
obstacle2.color("purple")
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment