-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpong.py
37 lines (30 loc) · 1020 Bytes
/
pong.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import sys
import pygame
from settings import Settings
from objects import *
import functions as f
def run_game():
pygame.init()
settings = Settings()
screen = pygame.display.set_mode((settings.width, settings.length))
pygame.display.set_caption(settings.title)
# Init Game stats
stats = GameStats(settings)
# Init Scoreboard
scoreboard = Scoreboard(settings, screen, stats)
scoreboard.prep_score()
# Init paddle for each player
paddle1 = Paddle(settings, screen, stats, player = 1)
paddle2 = Paddle(settings, screen, stats, player = 2)
paddles = [paddle1, paddle2]
# Init ball
ball = Ball(settings, screen)
while True:
f.check_events(settings, stats, screen, paddles, ball)
for paddle in paddles:
paddle.update()
f.update_ball(settings, stats, screen, scoreboard, paddles, ball)
f.update_screen(settings,stats, screen, scoreboard,
paddles, ball)
if __name__ == "__main__":
run_game()