MCPcopy Index your code
hub / github.com/ndleah/python-mini-project / main

Function main

Lazy_Pong/pong.py:399–433  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

397
398
399def main():
400 os.remove(os.path.abspath(log_file))
401 parser = argparse.ArgumentParser(description='Pong Game')
402 parser.add_argument('-dw','--width', type=int, default=320, help='Width of the display (dflt 320)')
403 parser.add_argument('-dh','--height', type=int, default=240, help='Height of the display (dflt 240)')
404 parser.add_argument('-n','--name', type=str, default="player 1", help='Player name')
405 parser.add_argument('-c', '--color', type=str, default="lightgrey", help='Game color (dflt light grey)')
406 parser.add_argument('--fps', type=int, default=120, help='Framerate (dflt 120)')
407 parser.add_argument('--max_score', type=int, default=10, help='Max score to win (dflt 10)')
408 args = parser.parse_args()
409
410 screen_width = args.width
411 screen_height = args.height
412 fps = args.fps
413 max_score = args.max_score
414 color = args.color
415 player_name = args.name
416
417 if color not in rgb_colors.keys():
418 pong_log.error(f"Color {color} not found, setting light grey")
419 color = "lightgrey"
420 # Il resto del tuo codice rimane invariato
421
422 game_field = GameField(screen_width, screen_height,
423 "black", rgb_colors[color], "Pong")
424 ball = Ball(screen_width / 2, screen_height / 2, 5,
425 rgb_colors[color], screen_width, screen_height)
426 player = Gamer(screen_width - 30, (screen_height / 2) - 40,
427 10, 40, rgb_colors[color], player_name, screen_width, screen_height)
428 computer = Gamer(20, (screen_height / 2) - 40, 10, 40,
429 rgb_colors[color], "CPU",screen_width, screen_height)
430
431 pong = PongGame(game_field, ball, player, computer, fps=fps, max_score=max_score)
432
433 pong.run_game()
434
435if __name__ == '__main__':
436 main()

Callers 1

pong.pyFile · 0.70

Calls 7

run_gameMethod · 0.95
GameFieldClass · 0.85
BallClass · 0.85
GamerClass · 0.85
PongGameClass · 0.85
removeMethod · 0.80
errorMethod · 0.80

Tested by

no test coverage detected