-
Notifications
You must be signed in to change notification settings - Fork 7
/
run_game.py
executable file
·57 lines (42 loc) · 1.12 KB
/
run_game.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
#! /usr/bin/python
import argparse
import sys
import pygame
import time
import os.path
# my imports
from tile import *
from game import *
from editor import *
def main():
pygame.init()
screen = pygame.display.set_mode((800,600))
pygame.display.set_caption("Vanessa's Mahjong, v0.0")
editor = False
sound_on = True
player_name = 'Player'
if len(sys.argv) > 2 and '--editor' in sys.argv:
editor = True
pygame.mouse.set_visible(False)
i = sys.argv.index('--editor')
if len(sys.argv) > 2 and '--player_name' in sys.argv:
pi = sys.argv.index('--player_name')+1
player_name = sys.argv[pi]
if '--nosound' in sys.argv:
sound_on = False
if editor:
level_arg = sys.argv[i+1]
game = Editor(sound=sound_on, filename = level_arg)
else:
game = Game(sound=sound_on, player_name=player_name)
while True:
for event in pygame.event.get():
if event.type == pygame.QUIT:
return
game.handle_input(event)
game.render(screen)
pygame.display.flip()
time.sleep(.001)
return
if __name__ == "__main__":
main()