This is a very simple code for a basic racing game I haven’t tested it out on my computer so I’m not sure it will work properly but if anything this will be a good starting point. I used two different modules time and msvcrt which I believe detects key presses for simple text based games.
import msvcrt
import time
high_score = 0
name = “Car Driver”
while True: distance = int(0)
print(“/nCar—————————————“)
print(‘Welcome to the race track. tap b to move.’)
print(‘n/Press enter to begin.)
input()
print(‘Go!’)
k1 = msvcrt.getch().decode (ASCII’)
k1 = ‘z’:
distance += 1
if distance == 100
print (” You finished the race.”)
Advertisements