-
Notifications
You must be signed in to change notification settings - Fork 0
/
tankstar.py
47 lines (34 loc) · 1.05 KB
/
tankstar.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
import argparse
from model import Model
parser = argparse.ArgumentParser(
description="Simplified Battle City clone")
parser.add_argument(
'-m', '--mode',
choices=('gui', 'console'),
default='gui',
dest='mode',
help='game mode')
args = parser.parse_args()
model = Model()
if args.mode == 'console':
import time
import keyboard
while True:
if keyboard.is_pressed('up'):
model.add_move_action(model.player, backward=False)
elif keyboard.is_pressed('down'):
model.add_move_action(model.player, backward=True)
elif keyboard.is_pressed('right'):
model.add_turn_action(model.player, ACW=False)
elif keyboard.is_pressed('left'):
model.add_turn_action(model.player, ACW=True)
elif keyboard.is_pressed('space'):
model.add_shoot_action(model.player)
elif keyboard.is_pressed('q'):
break
model.update()
model.dump()
time.sleep(1/5)
else:
from view import View
View(model).start()