7
7
from rich .console import Console
8
8
9
9
console = Console ()
10
+ def clear ():
11
+ global console
12
+ for x in range (50 ):
13
+ console .clear ()
10
14
try :
11
15
db = json .load (open ("save.json" , "r" ))
12
16
except FileNotFoundError :
@@ -77,8 +81,8 @@ def climb(self):
77
81
self .position += 1
78
82
if self .position > self .max_height :
79
83
self .position = self .max_height
80
- console . clear ()
81
- console . clear ()
84
+ clear ()
85
+ clear ()
82
86
if self .position == 1 :
83
87
console .print (f"Climbed 1 up. You are now at { self .position } metre." )
84
88
else :
@@ -88,15 +92,15 @@ def climb(self):
88
92
else :
89
93
fall_distance = 1
90
94
if self .position > 5 :
91
- console . clear ()
92
- console . clear ()
95
+ clear ()
96
+ clear ()
93
97
console .print (f"Fell from height { self .position } . You died!" )
94
98
self .alive = False
95
99
return False
96
100
else :
97
101
self .position = max (0 , self .position - fall_distance )
98
- console . clear ()
99
- console . clear ()
102
+ clear ()
103
+ clear ()
100
104
console .print (f"Waited and fell to position: { self .position } " )
101
105
102
106
self .current_key = random .choice (self .keys )
@@ -123,8 +127,8 @@ def climb():
123
127
return False
124
128
125
129
126
- console . clear ()
127
- console . clear ()
130
+ clear ()
131
+ clear ()
128
132
console .print ("[NOTE]: Successfully launched game." )
129
133
130
134
# CODE STARTS HERE
@@ -137,8 +141,8 @@ def climb():
137
141
with open ('save.json' , 'w' ) as f :
138
142
json .dump (db , f )
139
143
exit ()
140
- console . clear ()
141
- console . clear ()
144
+ clear ()
145
+ clear ()
142
146
143
147
144
148
def sequence1 ():
@@ -185,8 +189,8 @@ def sequence2():
185
189
)
186
190
console .print ("You decide to climb." )
187
191
input ("Press enter to continue..." )
188
- console . clear ()
189
- console . clear ()
192
+ clear ()
193
+ clear ()
190
194
climb_result = climb () # Climbing system initation
191
195
if climb_result :
192
196
pass
@@ -196,8 +200,8 @@ def sequence2():
196
200
json .dump (db , f )
197
201
exit ()
198
202
console .print ("You have reached the top of the cliff." )
199
- console . clear ()
200
- console . clear ()
203
+ clear ()
204
+ clear ()
201
205
with open ('save.json' , 'w' ) as f :
202
206
json .dump (db , f )
203
207
db ['stage' ] = 3
0 commit comments