|
|
|
@ -183,6 +183,8 @@ class Playground(object):
@@ -183,6 +183,8 @@ class Playground(object):
|
|
|
|
|
paddleRight = Paddle(self, width - 1, (height - paddlesize)//2, paddlesize) |
|
|
|
|
self.__paddles = [paddleLeft, paddleRight] |
|
|
|
|
|
|
|
|
|
self.cancelled = False |
|
|
|
|
|
|
|
|
|
self.__ball = Ball(self, 0, 0, 1, 1) |
|
|
|
|
self.__gameTickCallbacks = [] |
|
|
|
|
self.__newRoundCallbacks = [] |
|
|
|
@ -227,6 +229,9 @@ class Playground(object):
@@ -227,6 +229,9 @@ class Playground(object):
|
|
|
|
|
if paddle.containsPoint(x, y): |
|
|
|
|
return paddle |
|
|
|
|
|
|
|
|
|
def cancel(self): |
|
|
|
|
self.cancelled = True |
|
|
|
|
|
|
|
|
|
def play(self, serve=None): |
|
|
|
|
leftPaddle = self.__paddles[0] |
|
|
|
|
rightPaddle = self.__paddles[1] |
|
|
|
@ -250,7 +255,7 @@ class Playground(object):
@@ -250,7 +255,7 @@ class Playground(object):
|
|
|
|
|
callback() |
|
|
|
|
|
|
|
|
|
ticks = 0 |
|
|
|
|
while True: |
|
|
|
|
while not self.cancelled: |
|
|
|
|
ticks += 1 |
|
|
|
|
time.sleep(0.08) |
|
|
|
|
if ticks %2 == 0: |
|
|
|
|