MCPcopy Create free account
hub / github.com/Mrinank-Bhowmick/python-beginner-projects / reset_ball

Method reset_ball

projects/PONG/main.py:96–108  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

94 self.speed_y *= -1
95
96 def reset_ball(self):
97 for paddle in self.paddles:
98 if paddle.x == 20:
99 paddle.rect.center = (20, HEIGHT / 2)
100 else:
101 paddle.rect.center = (WIDTH - 20, HEIGHT / 2)
102 self.active = False
103 self.speed_x *= random.choice((-1, 1))
104 self.speed_y *= random.choice((-1, 1))
105 self.score_time = pygame.time.get_ticks()
106 self.rect.center = (WIDTH / 2, HEIGHT / 2)
107 if started > 1:
108 pygame.mixer.Sound.play(score_sound)
109
110 def restart_counter(self):
111 current_time = pygame.time.get_ticks()

Callers 4

reset_ballMethod · 0.45
easy_gameMethod · 0.45
med_gameMethod · 0.45
hard_gameMethod · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected