-
Notifications
You must be signed in to change notification settings - Fork 32
/
Copy pathgame.py
executable file
·39 lines (33 loc) · 1.4 KB
/
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
#!/usr/bin/env python
import pygame as pg
from data.main import main
import data.tools
import argparse
import sys
parser = argparse.ArgumentParser(description='Pong Arguments')
parser.add_argument('-c','--clean', action='store_true',
help='Remove all .pyc files and __pycache__ directories')
parser.add_argument('-f' , '--fullscreen', action='store_true',
help='start program with fullscreen')
parser.add_argument('-d' , '--difficulty', default='medium',
help='where DIFFICULTY is one of the strings [hard, medium, easy], set AI difficulty, default is medium, ')
parser.add_argument('-s' , '--size', nargs=2, default=[800,600], metavar=('WIDTH', 'HEIGHT'),
help='set window size to WIDTH HEIGHT, defualt is 800 600')
args = vars(parser.parse_args())
if __name__ == '__main__':
accepted_difficulty = ['hard', 'medium', 'easy']
if args['difficulty']:
if args['difficulty'].lower() in accepted_difficulty:
difficulty = args['difficulty'].lower()
print('difficulty: {}'.format(difficulty))
else:
print('{} is not a valid difficulty option, {}'.format(args['difficulty'], accepted_difficulty))
sys.exit()
if args['size']:
size = args['size']
print('window size: {}'.format(size))
if args['clean']:
data.tools.clean_files()
else:
main(args['fullscreen'], difficulty, size)
pg.quit()