-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgame.py
More file actions
161 lines (115 loc) · 4.08 KB
/
game.py
File metadata and controls
161 lines (115 loc) · 4.08 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
'''
E Y E B L I N K
A text adventure written by Miguel Reinoso (miguelreinoso7@gmail.com)
August 2019
'''
# ============================== THINGS THAT I'M TESTING ====================================
# This will print the output in a more cinematic way
'''
import sys
BAUD = 1200
def baudout(s):
for c in s:
sleep(9. / BAUD) # 8 bits + 1 stop bit @ the given baud rate
sys.stdout.write(c)
sys.stdout.flush()
baudout()
'''
from time import sleep
from player import Player
import world, pygame
# ========================================== Functions ========================================
def three_blank_lines(): # Spaces between paragraphs
print()
print()
print()
def shpause(): # short pause in the narrative
sleep(1)
def lpause(): # long pause in the narrative
sleep(2)
def get_player_command(): # Player prompt
print()
return input("What now? ")
def play(): # Game loop
player = Player()
while True:
room = world.tile_at(player.x, player.y)
print(room.intro_text())
room.modify_player(player)
action_input = get_player_command()
if action_input == 'n':
player.move_north()
elif action_input == 's':
player.move_south()
elif action_input == 'e':
player.move_east()
elif action_input == 'w':
player.move_west()
elif action_input == 'i':
player.print_inventory()
elif action_input == 'a':
player.attack()
elif action_input == 'h':
player.heal()
elif action_input == 'music off':
pygame.mixer.music.stop()
elif action_input == 'music on':
pygame.mixer.music.play(-1, 0.2)
else:
print("Invalid action")
# ==================================== NARRATIVE ================================================
pygame.init() # music
pygame.mixer.music.load('Kai_Engel-Interception.mp3')
pygame.mixer.music.play(-1, 0.2)
three_blank_lines()
print(" ####### # # ####### ###### # ### # # # # ")
print(" # # # # # # # # ## # # # ")
print(" # # # # # # # # # # # # # ")
print(" ##### # ##### ###### # # # # # ### ")
print(" # # # # # # # # # # # # ")
print(" # # # # # # # # ## # # ")
print(" ####### # ####### ###### ####### ### # # # # ")
three_blank_lines()
shpause()
print("""
Synopsis:
It's the year 2050. After the climate breakdown, life on the surface of the planet
became impossible ... Humans and cyborgs started to live in subterranean megacities where
everyone struggles to survive.
""")
lpause()
print("""
In this wicked world, you're a little girl called Valeria. You survive collecting and selling
junk, hacking machines and stealing Qtrits, the cryptocurrency that wealthy people uses in
the underground.
""")
lpause()
print("""
One night you're coming back to your cabin to get some rest and you find a strange woman
waiting at the door of your block. She asks you for an adress. You try to run without
answering nothing but it's too late. A protocol droid appears from the shadows and grabs
you while the woman forces you to inhale some kind of substance ...
""")
lpause()
print("""
You fall asleep ...
""")
three_blank_lines()
lpause()
print('''
Instructions:
- Play with your keyboard. Enter commands in lower case.
- Available commands are:
'n' North 'i' Inventory 'music on'
's' South 'a' Attack 'music off'
'e' East 'h' Heal
'w' West
Music:'Interception' by Kai Engel.
''')
three_blank_lines()
shpause()
print("""
You awake ...
After opening your eyes you find yourself in an empty room.
""")
play()