Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def main():
init(autoreset=True)
os.system('cls' if os.name == 'nt' else 'clear')
print("\t \t Snake")
print("==============")
print("W - to move up")
print("S - to move down")
print("A - to move left")
print("D - to move right")
print("==============")
while True:
print('press Y to Start the game and N to exit: ',end="")
x = getch.getche()
print("")
if x== 'Y' or x=='N' or x=='y' or x=='n':
break
else:
print("wrong input try again")
if x=='n' or x=='N':
sys.exit()
game_over = multiprocessing.Value('i')
game_over.value = 0
direction = multiprocessing.Value('i')
direction.value=ord('D')
moved = multiprocessing.Value('i')
moved.Value=0
lock = multiprocessing.Lock()
process1=multiprocessing.Process(target=dir_input,args=(direction,game_over,lock,moved))
process2=multiprocessing.Process(target=game_start,args=(direction,game_over,lock,moved))
def race(distance):
inp = getch.getche()
correct = MOVES["x"]
distance_ran = 0
if inp == correct:
distance_ran += 1
start = time.time()
while distance_ran < distance:
correct = MOVES[correct]
while inp != correct:
inp = getch.getche()
else:
distance_ran += 1
end = time.time()
return "\nFinished in: {:.3f}s".format(end-start)
return "\nYou burned the lead!\n"
def race(distance):
inp = getch.getche()
correct = MOVES["x"]
distance_ran = 0
if inp == correct:
distance_ran += 1
start = time.time()
while distance_ran < distance:
correct = MOVES[correct]
while inp != correct:
inp = getch.getche()
else:
distance_ran += 1
end = time.time()
return "\nFinished in: {:.3f}s".format(end-start)
return "\nYou burned the lead!\n"