This server is intended for use for Academic Classwork related Git repositories only. Projects/repositories will generally be removed after 6 months following close of the semester. Inactive repositories from previous semester are now being archived when no activity for 365 days. They are renamed and marked as 'archived'. After 90 days in that state they will be removed from the system completely.

Add new file

parent f307c035
def shapes(art):
car =''' _.-="_- _
_.-=" _- | ||"""""""---._______ __..
___.===""""-.______-,,,,,,,,,,,,`-''----" """"" """"" __'
__.--"" __ ,' o \ __ [__|
__-""=======.--"" ""--.=================================.--"" ""--.=======:
] [w] : / \ : |========================| : / \ : [w] :
V___________:| |: |========================| :| |: _-"
V__________: \ / :_|=======================/_____: \ / :__-"
-----------' "-____-" `-------------------------------' "-____-"
'''
lightBulb = '''
_------_
-~ ~-
- _ -
- |> -
- |< -
- |> -
- || -
- || -
-__||__-
|______|
<______>
<______>
\/'''
skeleton = '''
_.--"""""--._
.' '.
/ \\
; ;
| |
| |
; ;
\ (`'--, ,--'`) /
\ \ _ ) ( _ / /
) )(')/ \(')( (
(_ `""` /\ `""` _)
\`"-, / \ ,-"`/
`\ / `""` \ /`
|/\/\/\/\/\|
|\ /|
; |/\/\/\| ;
\`-`--`-`/
\ /
',__,'
q__p
q__p
q__p
q__p
'''
city = ''' .''.
.''. . *''* :_\/_: .
:_\/_: _\(/_ .:.*_\/_* : /\ : .'.:.'.
.''.: /\ : /)\ ':'* /\ * : '..'. -=:o:=-
:_\/_:'.:::. | ' *''* * '.\'/.'_\(/_ '.':'.'
: /\ : ::::: = *_\/_* -= o =- /)\ '
'..' ':::' === * /\ * .'/.\'. ' ._____
* | *..* : |. |' .---"|
* | _ .--'| || | _| |
* | .-'| __ | | | || |
.-----. | |' | || | | | | | || |
___' ' /"\ | '-."". '-' '-.' '` |____
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~-~-~-~-~-~-~-~-~-~ /|
~-~-~-~-~-~-~-~ /|~ /_|\
~-~-~- -~-~-~-~-~-~ /_|\ -~======-~
~-~~~~~~~~~~~~~ ~-~-~-~ /__|_\ ~-~-~-~
~-~-~-~-~-~ ~-~~-~-~-~-~ ======== ~-~-~-~
~-~~-~-~-~-~-~-~-~-~-~-~-~ ~-~~-~-~-~-~
~-~~-~-~-~-~'''
if art == 'racecar':
return car
elif art == 'bulb':
return lightBulb
elif art == 'bones':
return skeleton
elif art == 'town':
return city
def menu():
print(shapes('racecar'))
print("Welcome to ASCII-racer.\nNavigate through to the light at the end of the tunnel to win!\nPress 'a' for left, 'd' for right', enter for nothing.\nIf you hit the walls, you lose.\nTo win, you have to complete 2 laps around the tunnel array.\nPress any key to start!")
def dead():
print(shapes('bones'))
print('You hit the wall, and lose!')
def win():
print(shapes('town'))
print('You win!')
def ascii_racer():
map = ['|* *|',
' |* *|',
' |* *|',
' |* *|',
' |* *|',
' |* *|',
' |* *|',
' |* *|',
' |* *|',
' |* *|',
' |* *|',
' |* *|',
' |* *|',
' |* *|',
' |* *|',
' |* *|',
' |* *|',
' |* *|',
' |* *|',
' |* *|',
' |* *|',
' |* *|',
' |* *|',
'|* *|', # 1 of 2nd lap
' |* *|',#start of 2nd 19
' |* *|',#end of 1st lap 19
' |* *|',
' |* *|',
' |* *|',
' |* *|',
' |* *|',
' |* *|',
' |* *|',
' |* *|',
' |* *|',
' |* *|',
' |* *|',
' |* *|',
' |* *|',
' |* *|',
' |* *|',
' |* *|',
' |* *|',
' |* *|']
returnVal = 'w'
laps = 1
position = 0
wallShift = 0
q = 0
while laps <= 2:
i = len(map) - 1
path = 0
while i >= 0:
print('ASCII Racer 1.0, level: ' +str(path)+ ' of 23 rows in lap number ',laps)
print(shapes('bulb'))
print(' ')
listVer = list(map[i])
y = 0
while y < len(listVer):
if listVer[y] == '*' and listVer[y+1] != '|' :
if listVer[y+2+position+wallShift] =='|'or (y+2+position+wallShift) > len(listVer) or listVer[y+2+position+wallShift] == '*':
returnVal = 'l'
break
else:
listVer[y+2+position+wallShift] = '^'
z = y
y += 1
if q == 0:
position += 1
q = 12
if returnVal == 'l':
break
joinedVer = "".join(listVer)
print(map[i-2])
print(map[i-1])
print(joinedVer)
movement = input()
if movement == 'a':
position -= 1
elif movement == 'd':
position += 1
else:
movement == movement
listVer2 = list(map[i-1])
if len(listVer) > len(listVer2):
wallShift += 1
elif len(listVer) < len(listVer2):
wallShift -= 1
else:
wallShift ==wallShift
if (z+2+position+wallShift) >= len(listVer2):
returnVal ='1'
break
elif listVer2[z+2+position+wallShift] == '|':
returnVal = 'l'
print("\033[H\033[J")
break
print("\033[H\033[J")
i -= 1
path += 1
if path == 19 and laps == 1:
path = 0
laps = 2
if returnVal == 'l':
break
laps += 1
return returnVal
menu()
print()
x = 1
while x != 0 :
startGame = ' '
while startGame == ' ' or startGame != ' ':
print("\033[H\033[J")
LorW = ascii_racer()
print("\033[H\033[J")
if LorW == 'l':
dead()
elif LorW == 'w':
win()
replay = ' '
while replay != 'y' or replay == 'n':
print('Do you want to play again (y | n)?:')
replay = input()
if replay == 'n':
break
break
if replay == 'n':
break
elif replay == 'y':
print("\033[H\033[J")
menu()
print()
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment