Mini Game
unknown
plain_text
2 years ago
2.3 kB
26
Indexable
from turtle import Turtle
from colorama import Fore, init
import os
turtle = Turtle()
turtle.speed(1)
def menu():
print(Fore.YELLOW,' MINI GAME '.center(30, '='), Fore.RESET)
print(
'''[ 1 ] Rotacionar para esquerda
[ 2 ] Rotacionar para direita
[ 3 ] Caminhar para trás
[ 4 ] Sair do jogo'''
)
return
def to_walk():
walk = ''
while type(walk) != int:
try:
walk = (input('Gostaria de andar quantos pixeis? '))
walk = int(walk)
except ValueError:
os.system('cls')
print('Digite apenas valores numéricos.')
turtle.forward(walk)
def rotate_to_the_right():
rrotate = ''
while type(rrotate) != int:
try:
rrotate = (input('Gostaria de rotacionar quantos graus para direita? '))
rrotate = int(rrotate)
except ValueError:
os.system('cls')
print('Digite apenas valores numéricos.')
turtle.right(rrotate)
def rotate_to_the_left():
lrotate = ''
while type(lrotate) != int:
try:
lrotate = (input('Gostaria de rotacionar quantos graus para esquerda? '))
lrotate = int(lrotate)
except ValueError:
os.system('cls')
print('Digite apenas valores numéricos.')
turtle.left(lrotate)
def walk_backwards():
wback = ''
while type(wback) != int:
try:
wback = (input('Gostaria de andar para trásquantos pixeis? '))
wback = int(wback)
except ValueError:
os.system('cls')
print('Digite apenas valores numéricos.')
turtle.backward(wback)
while True:
menu()
option = ''
while option not in (1, 2, 3, 4):
option =(input('Escolha sua opção: '))
os.system('cls')
try:
option = int(option)
except ValueError:
print('Escolha uma opção válida...')
menu()
if option == 1:
rotate_to_the_left()
to_walk()
os.system('cls')
elif option == 2:
rotate_to_the_right()
to_walk()
os.system('cls')
elif option == 3:
walk_backwards()
os.system('cls')
else:
break
print('Programa finalizado...')Editor is loading...
Leave a Comment