(self)
| 78 | return False |
| 79 | |
| 80 | def draw(self): |
| 81 | self.curx += self.x |
| 82 | self.cury += self.y |
| 83 | self.graph.relocate_figure(self.id, self.curx, self.cury) |
| 84 | if self.cury <= 0: # see if hit top or bottom of play area. If so, reverse y direction |
| 85 | self.y = 4 |
| 86 | self.cury = 0 |
| 87 | if self.cury >= GAMEPLAY_SIZE[1]-BALL_RADIUS/2: |
| 88 | self.y = -4 |
| 89 | self.cury = GAMEPLAY_SIZE[1]-BALL_RADIUS/2 |
| 90 | if self.curx <= 0: # see if beyond player |
| 91 | self.player_1_Score += 1 |
| 92 | self.graph.relocate_figure( |
| 93 | self.id, STARTING_BALL_POSITION[0], STARTING_BALL_POSITION[1]) |
| 94 | self.x = 4 |
| 95 | self.update_player2_score(self.player_1_Score) |
| 96 | self.curx, self.cury = STARTING_BALL_POSITION |
| 97 | if self.curx >= GAMEPLAY_SIZE[0]: |
| 98 | self.player_2_Score += 1 |
| 99 | self.graph.relocate_figure( |
| 100 | self.id, STARTING_BALL_POSITION[0], STARTING_BALL_POSITION[1]) |
| 101 | self.x = -4 |
| 102 | self.update_player1_score(self.player_2_Score) |
| 103 | self.curx, self.cury = STARTING_BALL_POSITION |
| 104 | if self.hit_bat((self.curx, self.cury)): |
| 105 | self.x = 4 |
| 106 | if self.hit_bat2((self.curx, self.cury)): |
| 107 | self.x = -4 |
| 108 | |
| 109 | |
| 110 | class PongBall(): |
no test coverage detected