-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgame.py
More file actions
46 lines (40 loc) · 893 Bytes
/
Copy pathgame.py
File metadata and controls
46 lines (40 loc) · 893 Bytes
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
"""
module game. main exec file :)
"""
from exceptions import EnemyDown
from exceptions import GameOver
from models import Enemy
from models import Player
def play():
"""
method play. :)
"""
pl_name = input("Enter your name : ")
player = Player(pl_name)
level = 1
enemy = Enemy(1)
while True:
try:
player.attack(enemy)
player.defence(enemy)
except EnemyDown:
level += 1
player.score += 5
enemy = Enemy(level)
def main():
"""
method main. :)
"""
try:
play()
except GameOver as g_o:
print("GameOver")
ffile = open('scores.txt', 'a')
ffile.write(g_o.pl_name + ' - ' + g_o.pl_score + '\n')
ffile.close
except KeyboardInterrupt:
pass
finally:
print("Good Bye!")
if __name__ == "__main__":
main()