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

Method _move_computer

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

Source from the content-addressed store, hash-verified

303
304 # Move computer to follow the ball after half of the game field
305 def _move_computer(self):
306 if self._ball.get_borders()['right'] < self._game_field.disp_w / 2:
307 if self._computer.get_borders()['center_y'] < self._ball.get_borders()['center_y']:
308 self._computer.set_speed(self._cpu_speed)
309 else:
310 self._computer.set_speed(-self._cpu_speed)
311 else:
312 self._computer.set_speed(0)
313
314 # Based on incoming keyboard event, move the player
315 def _move_player(self, event: pygame.event):

Callers 1

run_gameMethod · 0.95

Calls 2

get_bordersMethod · 0.45
set_speedMethod · 0.45

Tested by

no test coverage detected