-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPyDash.py
More file actions
205 lines (192 loc) · 5.87 KB
/
PyDash.py
File metadata and controls
205 lines (192 loc) · 5.87 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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
# ╘(̾●̮̮̃̾•̃̾)╛
import os
import queue as q
import threading as th
import random as r
import time as t
#clears the screen
def clear():
os.system("clear")
scores_txt = open("scores.txt", "w")
scores_txt = open("scores.txt", "r")
if scores_txt.readline() == "":
scores_txt = open("scores.txt", "w")
scores_txt.write("0")
scores_txt = open("scores.txt", "r")
score = scores_txt.readline()
display = []
playerPos = 4
gridView = False
spikeHit = False
jump = False
emptyChunk = [" "," "," "," "," ","▮"]
#creates UI
def interface(queue):
clear()
print("PPP Y Y DDD AAA SSS H H")
print("P P Y Y D D A A S H H")
print("PPP Y D D AAAAA SSS HHHHH")
print("P Y D D A A S H H")
print("P Y DDD A A SSS H H")
print("▮▮▮▮▮▮▮▮▮▮▮▮▮▮▮▮▮▮▮▮▮▮▮▮▮▮▮▮▮▮▮▮▮▮▮▮▮▮▮▮▮▮▮")
print(" High score: "+score)
#generates the bg randomly idk it's cool don't question it
#this generates the starry background stuff
for i in range(4):
output = []
for i in range(43):
num = r.randint(1,14)
output.append(num)
actually_outputs = ""
for i in output:
if i == 7:
actually_outputs += "."
else:
actually_outputs += " "
print(actually_outputs)
output = []
#this generates the random spikes
for i in range(43):
num = r.randint(1,14)
output.append(num)
actually_outputs = ""
for i in output:
if i == 7:
actually_outputs += "∆"
else:
actually_outputs += " "
print(actually_outputs)
output = ""
#this generates the ground
for i in range(43):
output += "▮"
print(output)
#this is the actual menu choice
print(" START EXIT")
choice = input("")
#start : 9-14 spaces
#exit : 30-33 spaces
if len(choice) >= 9 and len(choice) <= 14:
# Starts the game VVVVVVV
startGame(queue)
elif len(choice) >= 30 and len(choice) <= 33:
exit
else:
interface(queue)
# ╘(̾●̮̮̃̾•̃̾)╛
#generates chunks of the map
def genChunk():
global gridView
val = r.randint(1,10)
if gridView == True:
if val == 1:
chunk = ["-","-","-","-","∆","▮"]
else:
chunk = ["-","-","-","-","-","▮"]
if gridView == False:
if val == 1:
chunk = [" "," "," "," ","∆","▮"]
else:
chunk = [" "," "," "," "," ","▮"]
return chunk
# ╘(̾●̮̮̃̾•̃̾)╛
#generates chunks of blocks
#⬜
def printChunks():
global display
global playerPos
global score
print("▮▮▮▮▮▮▮▮▮▮▮▮▮▮▮▮▮▮ Score: "+str(score)+" ▮▮▮▮▮▮▮▮▮▮▮▮▮▮▮▮▮▮▮")
for a in range(len(display[0])):
for b in range(len(display)):
if b == 3 and a == playerPos:
print("P"+f"", end="")
else:
print(display[b][a]+f"", end="")
print("")
def gameEnd(queue):
global score
runThread.join()
clear()
print("▮▮▮▮▮▮▮▮▮▮▮▮▮▮▮▮▮▮ Score: "+str(score)+" ▮▮▮▮▮▮▮▮▮▮▮▮▮▮▮▮▮▮▮")
for i in range(4):
output = []
for i in range(43):
num = r.randint(1,14)
output.append(num)
actually_outputs = ""
for i in output:
if i == 7:
actually_outputs += "."
else:
actually_outputs += " "
print(actually_outputs)
output = []
if score < 100:
something_idk_funni = "You suck!"
else:
something_idk_funni = "Try again!"
print("▮▮▮▮▮▮▮▮▮▮▮▮▮▮▮▮▮▮ " + something_idk_funni + " ▮▮▮▮▮▮▮▮▮▮▮▮▮▮▮▮▮▮▮")
#lets the player jump
def jumpp(queue):
while True:
temp = input("")
if temp == "":
action = "jump"
queue.put(action)
def runn(queue):
global spikeHit
global score
global display
global playerPos
start = inputThread.start()
jacksoniscool = 0
while spikeHit == False:
score = int(score)
score += 1
clear()
display.append(genChunk())
display.pop(0)
printChunks()
t.sleep(0.2)
action = queue.empty()
if action == False and jacksoniscool == 0:
playerPos = 3
jacksoniscool += 1
elif action == False and (jacksoniscool == 1 or jacksoniscool == 2 or jacksoniscool == 3):
playerPos = 2
jacksoniscool += 1
elif action == False and jacksoniscool == 4:
playerPos = 3
jacksoniscool += 1
elif action == False and jacksoniscool == 5:
playerPos = 4
jacksoniscool = 0
action = queue.get()
elif action == True:
jacksoniscool = 0
else:
jacksoniscool = 0
action = queue.get()
if display[2][4] == "∆" and playerPos == 4:
spikeHit = True
# ╘(̾●̮̮̃̾•̃̾)╛
#starts the game
def startGame(queue):
global emptyChunk
for x in range(50):
display.append(emptyChunk)
printChunks()
runn(queue)
calvin_bunker = open("scores.txt", "w")
calvin_bunker.write(str(score))
# ╘(̾●̮̮̃̾•̃̾)╛
#- - - - - -end of PyDash Class - - - - - -
queue = q.Queue()
inputThread = th.Thread(target=jumpp, args = (queue, ))
runThread = th.Thread(target=interface, args = (queue, ))
endThread = th.Thread(target=gameEnd, args=(queue, ))
run = runThread.start()
while spikeHit == False:
pass
end = endThread.start()