-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
48 lines (42 loc) · 1.26 KB
/
main.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
38
39
40
41
42
43
44
45
46
47
48
import pygame
from time import sleep, time
from pygame.locals import *
from paddle import *
from ball import *
from background import *
from scoreboard import *
from menu import *
from game import *
from constants import *
# Main function that loops through the menus and game
def main():
running = True
# Pygame initialization
pygame.init()
pygame.display.set_caption("2.5D Pong")
screen = pygame.display.set_mode((WIDTH, HEIGHT))
# Initializing objects
ball = Ball()
scoreboard = Scoreboard(11)
# Main loop, will run until you close the window or force stop the program
while running:
# Calls the main menu and gets paddles
paddles = mainMenu(screen, ball)
if paddles[0] != 0:
# Creates Game object with paddles and runs it
winner = game(screen, ball, scoreboard, paddles)
if winner[2] == 0:
running = False
else:
sleep(1)
# Runs win menu when the game is over, loops back to main menu
running = winMenu(screen, winner)
else:
running = False
#end
#end
#end
# Runs main code when file is run. Allows main to be accessed elsewhere
if __name__ == "__main__":
main()
#end