Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random, time, os, msvcrt, sys
- def clear():
- os.system("cls")
- inp = 0
- y = 2
- x = 2
- foody = random.randint(0, 9)
- foodx = random.randint(0, 9)
- lengh = 3
- mapa = [[[0] * 10] * 10]
- print(mapa)
- while True:
- time.sleep(1)
- clear()
- for i in range(10):
- for j in range(10):
- if mapa[i][j] > 0:
- mapa[i][j] -= 1
- if i == y and j == x:
- mapa[i][j] = lengh
- if i == foody and j == foodx:
- mapa[i][j] = -1
- if i == foody and x == foodx:
- mapa[i][j] = lengh
- foody = random.randint(0, 9)
- foodx = random.randint(0, 9)
- lengh += 1
- print("{:^2}".format(mapa[i][j]), end = "")
- print()
- try:
- inp = msvcrt.getch()
- except:
- pass
- if inp == b'd':
- x += 1
- if inp == b'a':
- x -= 1
- if inp == b's':
- y += 1
- if inp == b'w':
- y -= 1
- if inp == b'q':
- clear()
- print('your score: ', lengh)
- sys.exit()
Advertisement
Add Comment
Please, Sign In to add comment