Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from os import system
- import keyboard
- from time import sleep
- from colorama import Back, Style
- level = 1
- def win():
- system("clear")
- global level
- level = level + 1
- print(f"""
- *****************************************
- 1D Car Game
- *****************************************
- You won
- Now you are level {level}
- *****************************************""")
- input("Press ENTER to continue")
- levels()
- def levels():
- system("clear")
- px = " "
- x = 0
- char = "o--o"
- while True:
- system("clear")
- print(Back.BLUE + " ")
- print(Back.BLUE + " ")
- print(Back.BLUE + x * px + char + px * (56 - x))
- print(Back.GREEN + " ")
- print(Style.RESET_ALL)
- print(f"""
- *****************************************
- 1D Car Game
- *****************************************
- X: {x}
- Max X: 60
- Character: {char}
- Level: {level}
- *****************************************
- Press E for exit""")
- if x<0:
- x=0
- if x>=60:
- win()
- if keyboard.is_pressed("a"):
- x=x-1
- elif keyboard.is_pressed("d"):
- x=x+1*level
- elif keyboard.is_pressed("e"):
- break
- else:
- pass
- sleep(0.009)
- def free():
- system("clear")
- px = " "
- x = 0
- char = "o--o"
- while True:
- system("clear")
- print(Back.BLUE + " ")
- print(Back.BLUE + " ")
- print(Back.BLUE + x * px + char + px * (56 - x))
- print(Back.GREEN + " ")
- print(Style.RESET_ALL)
- print(f"""
- *****************************************
- 1D Car Game
- *****************************************
- X: {x}
- Max X: 60
- Character: {char}
- *****************************************
- Press E for exit""")
- if x<0:
- x=0
- if x>=60:
- x=60
- if keyboard.is_pressed("a"):
- x=x-1
- elif keyboard.is_pressed("d"):
- x=x+1
- elif keyboard.is_pressed("e"):
- break
- else:
- pass
- sleep(0.009)
- def main():
- system("clear")
- print(f"""
- *****************************************
- 1D Car Game
- *****************************************
- Select the game mode
- *****************************************
- 1. Free mode
- 2. Levels mode
- *****************************************""")
- opt = input("Select an option: ")
- if opt=="1":
- free()
- elif opt=="2":
- levels()
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement