# Jumping Ball
import time, os, sys, threading
print("Please Enter the Ball's form")
game_over_text = "GAME OVER"
wall = '#'*32
guide = '#' + ' '*30 + '#'
rock = 'A'
ball = sys.stdin.readline(1)
ball_x = 5
ball_y = 9
rock1_x = 30
rock2_x = 42
score = 0
jump = False
jump_count = 0
end = False
def clear():
os.system('cls' if os.name == 'ct' else 'clear')
def set():
print(wall)
print('#'+' score: ',end='')
str_score = str(score)
score_len = len(str_score)
print( str_score + ' ' * ( 30 - ( 8 + score_len ) ) + '#' )
for yy in range(2,10):
for xx in range(0, len(guide)): #
if yy == ball_y and xx == ball_x :
print(ball, end='')
elif ( xx == rock1_x or xx == rock2_x ) and yy == 9 :
print(rock, end='')
else :
print(guide[xx],end='')
print()
print(wall)
class SYSTEM(threading.Thread):
def __init__(self, var):
threading.Thread.__init__(self)
self.put = var
def run(self):
global score, rock1_x, rock2_x, ball_x, ball_y, jump, jump_count, end
if self.put :
while 1:
input('>>>')
jump = True
else :
while 1:
set()
if jump :
if jump_count <= 5:
jump_count += 1
ball_y = 4
else :
jump_count = 0
jump = False
ball_y = 9
elif rock1_x == ball_x or rock1_x == ball_x:
end = True
print(game_over_text)
print('\nYou scored %d points' % score)
break
if rock1_x == 1:
rock1_x = 30
score += 1
if rock2_x == 1:
rock2_x = 30
score += 1
rock1_x -= 1
rock2_x -= 1
time.sleep(0.1)
clear()
a = SYSTEM(True)
b = SYSTEM(False)
b.start()
a.start()