-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMain.py
81 lines (54 loc) · 1.83 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
import pygame
from logic.GameLogic import *
from scenes.Menu import *
from scenes.SingleplayerGame import *
from scenes.MultiplayerGame import *
from network.Client import Client
SCREEN_WIDTH = 800
SCREEN_HEIGHT = 640
class Process:
def __init__(self):
pygame.init()
self.screen = pygame.display.set_mode((SCREEN_WIDTH, SCREEN_HEIGHT))
self.running = True
self.logic = False
self.client = False
#self.logic = GameLogic() # or GameLogicClient(self) and GameLogicServer(self)
self.menu = Menu(self)
self.game = False #SingleGame(self)
self.soundVolume = 100
self.currentScene = self.menu
def handle_events(self):
for event in pygame.event.get():
if event.type == pygame.QUIT:
self.running = False
else:
self.currentScene.on_event(event)
def loop(self):
while self.running:
self.handle_events()
self.currentScene.update()
if self.logic:
self.logic.update()
if self.client:
self.client.update()
def quit(self):
self.running = False
def change_scene(self, scene):
self.currentScene = scene
def init_logic(self, multiplayerMode="singleplayer"):
self.logic = GameLogic(multiplayerMode)
def init_game(self, gameType):
if gameType == "singleplayer":
self.game = SingleplayerGame(self)
elif gameType == "multiplayer":
self.game = MultiplayerGame(self)
def init_client(self):
self.client = Client(("localhost", 666))
if __name__ == '__main__':
# nickname = input('Enter your nickname: ')
# client = Client(nickname)
# client.connect((HOST, PORT))
main = Process()
main.loop()
pygame.quit()