Skip to content

Instantly share code, notes, and snippets.

@MinmoTech
Created July 18, 2019 18:14
Show Gist options
  • Save MinmoTech/5c0254f7761681ea623bd893ec48a9d3 to your computer and use it in GitHub Desktop.
Save MinmoTech/5c0254f7761681ea623bd893ec48a9d3 to your computer and use it in GitHub Desktop.
Python game test
import random
def rand_x():
return random.randint(0, 9)
def rand_y():
return random.randint(0, 39)
player_position_x = rand_x()
player_position_y = rand_y()
snake_position_x = rand_x()
snake_position_y = rand_y()
gold_position_x = rand_x()
gold_position_y = rand_y()
while abs(player_position_x - snake_position_x) < 3 or abs(player_position_y - snake_position_y) < 3:
player_position_x = rand_x()
player_position_y = rand_y()
while True:
for x in range(0, 10):
for y in range(0, 40):
if x is player_position_x and y is player_position_y:
print('@', end='')
elif x is snake_position_x and y is snake_position_y:
print('S', end='')
elif x is gold_position_x and y is gold_position_y:
print('$', end='')
else:
print('.', end='')
if y is 39:
print('')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment