Commit 10be050b authored by 12903783's avatar 12903783
Browse files

Scoring system implemented but still buggy.

parent 979c6597
......@@ -4,7 +4,7 @@ wn = turtle.Screen()
wn.setup(width=800, height=600)
wn.bgcolor ("#0fb300")
wn.title ("Turtle Tennis")
#Court
court = turtle.Turtle()
court.shape("turtle")
......@@ -43,16 +43,29 @@ ball.penup()
ball.dx = 4
ball.dy = 4
#Scoreboard
scoreboard = turtle.Turtle()
scoreboard.shape("square")
scoreboard.color("white")
scoreboard.hideturtle()
scoreboard.penup()
scoreboard.setx(-110)
scoreboard.sety(200)
scoreboard.pendown()
scoreboard.write("0 0", font=("Arial Black", "60"))
#Scoreboard 1
scoreboard1 = turtle.Turtle()
scoreboard1.shape("square")
scoreboard1.color("white")
scoreboard1.hideturtle()
scoreboard1.penup()
scoreboard1.setx(-140)
scoreboard1.sety(200)
scoreboard1.pendown()
score_1 = 0
scoreboard1.write("{}".format(score_1), font=("Arial Black", "60"))
#Scoreboard 2
scoreboard2 = turtle.Turtle()
scoreboard2.shape("square")
scoreboard2.color("white")
scoreboard2.hideturtle()
scoreboard2.penup()
scoreboard2.setx(80)
scoreboard2.sety(200)
scoreboard2.pendown()
score_2 = 0
scoreboard2.write("{}".format(score_2), font=("Arial Black", "60"))
#Movement
......@@ -96,6 +109,12 @@ while True:
ball.sety(0)
ball.showturtle()
ball.dx *= -1
score_1 += 15
scoreboard1.clear()
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"))
if ball.ycor() < -290:
ball.sety(-290)
ball.dy *= -1
......@@ -105,7 +124,13 @@ while True:
ball.sety(0)
ball.showturtle()
ball.dx *= -1
score_2 += 15
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"))
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
\ No newline at end of file
ball.dx *= -1
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