Skip to content

Commit c149e49

Browse files
authored
fix: lots of clears
1 parent f55caba commit c149e49

File tree

1 file changed

+18
-14
lines changed

1 file changed

+18
-14
lines changed

main.py

+18-14
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77
from rich.console import Console
88

99
console = Console()
10+
def clear():
11+
global console
12+
for x in range(50):
13+
console.clear()
1014
try:
1115
db = json.load(open("save.json", "r"))
1216
except FileNotFoundError:
@@ -77,8 +81,8 @@ def climb(self):
7781
self.position += 1
7882
if self.position > self.max_height:
7983
self.position = self.max_height
80-
console.clear()
81-
console.clear()
84+
clear()
85+
clear()
8286
if self.position == 1:
8387
console.print(f"Climbed 1 up. You are now at {self.position} metre.")
8488
else:
@@ -88,15 +92,15 @@ def climb(self):
8892
else:
8993
fall_distance = 1
9094
if self.position > 5:
91-
console.clear()
92-
console.clear()
95+
clear()
96+
clear()
9397
console.print(f"Fell from height {self.position}. You died!")
9498
self.alive = False
9599
return False
96100
else:
97101
self.position = max(0, self.position - fall_distance)
98-
console.clear()
99-
console.clear()
102+
clear()
103+
clear()
100104
console.print(f"Waited and fell to position: {self.position}")
101105

102106
self.current_key = random.choice(self.keys)
@@ -123,8 +127,8 @@ def climb():
123127
return False
124128

125129

126-
console.clear()
127-
console.clear()
130+
clear()
131+
clear()
128132
console.print("[NOTE]: Successfully launched game.")
129133

130134
# CODE STARTS HERE
@@ -137,8 +141,8 @@ def climb():
137141
with open('save.json', 'w') as f:
138142
json.dump(db, f)
139143
exit()
140-
console.clear()
141-
console.clear()
144+
clear()
145+
clear()
142146

143147

144148
def sequence1():
@@ -185,8 +189,8 @@ def sequence2():
185189
)
186190
console.print("You decide to climb.")
187191
input("Press enter to continue...")
188-
console.clear()
189-
console.clear()
192+
clear()
193+
clear()
190194
climb_result = climb() # Climbing system initation
191195
if climb_result:
192196
pass
@@ -196,8 +200,8 @@ def sequence2():
196200
json.dump(db, f)
197201
exit()
198202
console.print("You have reached the top of the cliff.")
199-
console.clear()
200-
console.clear()
203+
clear()
204+
clear()
201205
with open('save.json', 'w') as f:
202206
json.dump(db, f)
203207
db['stage'] = 3

0 commit comments

Comments
 (0)