MCPcopy Create free account
hub / github.com/ndleah/python-mini-project / _update_game_speed

Method _update_game_speed

Lazy_Pong/pong.py:292–302  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

290
291 # Update game speed after a reset due to cpu error
292 def _update_game_speed(self):
293 score_diff = self._stat['player_score'] - self._stat['cpu_score']
294 if score_diff > 0 and score_diff > self._stat['last_diff']:
295 self._ball.set_speed(abs(self._ball.get_speed()[
296 0]) + self._cpu_speed_increment, abs(self._ball.get_speed()[1]) + self._cpu_speed_increment)
297 self._computer.set_speed(
298 self._cpu_speed + self._cpu_speed_increment)
299 self._stat['last_diff'] = score_diff
300 self._stat['level'] += 1
301 pong_log.debug(
302 f"Update speed, score diff = {score_diff}, last diff {self._stat['last_diff']}, level: {self._stat['level']}")
303
304 # Move computer to follow the ball after half of the game field
305 def _move_computer(self):

Callers 1

_reset_gameMethod · 0.95

Calls 2

set_speedMethod · 0.45
get_speedMethod · 0.45

Tested by

no test coverage detected