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