-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathbomber_server.py
More file actions
executable file
·51 lines (43 loc) · 1.29 KB
/
bomber_server.py
File metadata and controls
executable file
·51 lines (43 loc) · 1.29 KB
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
#!/usr/bin/env python3
# -*- coding: Utf-8 -*
# Author: aurelien.esnard@u-bordeaux.fr
from model import *
from view import *
from network import *
import sys
import pygame
### python version ###
print("python version: {}.{}.{}".format(sys.version_info[0], sys.version_info[1], sys.version_info[2]))
print("pygame version: ", pygame.version.ver)
################################################################################
# MAIN #
################################################################################
# parse arguments
if len(sys.argv) == 2:
port = int(sys.argv[1])
map_file = DEFAULT_MAP
elif len(sys.argv) == 3:
port = int(sys.argv[1])
map_file = sys.argv[2]
else:
print("Usage: {} port [map_file]".format(sys.argv[0]))
sys.exit()
# initialization
pygame.display.init()
pygame.font.init()
clock = pygame.time.Clock()
model = Model()
model.load_map(map_file)
for _ in range(10): model.add_fruit()
server = NetworkServerController(model, port)
# view = GraphicView(model, "server")
# main loop
while True:
# make sure game doesn't run at more than FPS frames per second
dt = clock.tick(FPS)
server.tick(dt)
model.tick(dt)
# view.tick(dt)
# quit
print("Game Over!")
pygame.quit()