Upload code
This commit is contained in:
612
TextAdventure/FightDay TA.py
Executable file
612
TextAdventure/FightDay TA.py
Executable file
@@ -0,0 +1,612 @@
|
||||
import time
|
||||
import datetime
|
||||
from random import *
|
||||
from math import *
|
||||
from threading import Thread
|
||||
from turtle import *
|
||||
|
||||
Zahl = randint(1,4)
|
||||
if Zahl == 4:
|
||||
Objekt = "Kupferleitung"
|
||||
elif Zahl == 3:
|
||||
Objekt = "Metallplatte"
|
||||
elif Zahl == 2:
|
||||
Objekt = "Schwarzpulver"
|
||||
elif Zahl == 1:
|
||||
Objekt = "rote Lampe"
|
||||
|
||||
|
||||
|
||||
def cover():
|
||||
print("\n \
|
||||
______ _ _ _ _____ \n \
|
||||
| ___|(_) | | | | | __ \ \n \
|
||||
| |__ _ __ _| |__ | |_ | | | | __ _ _ _ \n \
|
||||
| __| | |/ _` | '_ \| __| | | | |/ _` | | | |\n \
|
||||
| | | | (_| | | | | |_ | |__| | (_| | |_| |\n \
|
||||
|_| |_|\__, |_| |_|\__| |_____/ \__,_|\__, |\n \
|
||||
__/ | __/ |\n \
|
||||
|___/ |___/ ")
|
||||
time.sleep(3)
|
||||
|
||||
def einfuehrung():
|
||||
print("\n \n Es ist kurz nach Mittag.\n Du bist Teckniker beim Militär und mit deinen Kollegen in einem kompakten \
|
||||
Flugzeughangar des Militärs.\n \
|
||||
Plötzlich geht ein lauter Alarm los und du wirst von deinen Kollegen dazu aufgefordert, \n \
|
||||
ein Kampfflugzeug startklar zu machen.\n 'Geh und hole das Ersatzteil für den rechten Flügel!' \
|
||||
ruft dein Kollege.")
|
||||
time.sleep(9)
|
||||
|
||||
def grundriss():
|
||||
print ("\n Links von dir ist das Büro deines Vorgesetzten, \n rechts sind weitere Räume mit Materialien \
|
||||
für die Techniker, \n vor dir steht das Kampfflugzeug.\n Du kannst die vier Himmelsrichtungen (Norden, Osten, \
|
||||
Süden, Westen) zur Steuerung verwenden.")
|
||||
time.sleep(7)
|
||||
print("Los gehts!")
|
||||
time.sleep(1)
|
||||
showHelp()
|
||||
time.sleep(5)
|
||||
|
||||
|
||||
def Hangar():
|
||||
print("\n Du befindest dich am hinteren Ende des Hangars.")
|
||||
time.sleep(1)
|
||||
action = getUserAction()
|
||||
if action == 'o':
|
||||
return 2
|
||||
elif action == 'w':
|
||||
return 3
|
||||
elif action == 'egal':
|
||||
print("\n Mir auch egal. Lass uns eingach sagen, dass du es geschafft hast.")
|
||||
time.sleep(3)
|
||||
elif action == 'n':
|
||||
return 4
|
||||
else:
|
||||
handleStandardAction(action)
|
||||
return 1
|
||||
|
||||
|
||||
|
||||
def Objektraum():
|
||||
print("\n Willkommen im Raum der Ersatzteile.")
|
||||
time.sleep(1)
|
||||
print("\n Du kannst nun einen von acht Gegenständen mitnehmen. \
|
||||
\n \t-Metallrohr \n \t-Kupferleitung \n \t-Metallplatte \n \t-Kupferrohr \n \t-Gewehrlauf \n \t-Schwarzpulver \
|
||||
\n \t-rote Lampe \n \t-blaue Lampe")
|
||||
time.sleep(3)
|
||||
objekt = input("Welches Objekt willst du mitnehmen? ")
|
||||
|
||||
if objekt == Objekt:
|
||||
print("Gut...")
|
||||
inventory.append(Objekt)
|
||||
action = getUserAction()
|
||||
while action != 'w':
|
||||
handleStandardAction(action)
|
||||
action = getUserAction()
|
||||
return 1,1
|
||||
|
||||
elif objekt != 'Metallrohr' and objekt != 'Kupferleitung' and objekt != 'Metallplatte' and objekt != 'Kupferrohr' and objekt != 'Gewehrlauf' and objekt != 'Schwarzpulver' and objekt != 'rote Lampe' and objekt != 'blaue Lampe':
|
||||
handleStandardAction(objekt)
|
||||
|
||||
print("\n Dies ist leider nicht das korrekte Objekt, versuch es noch einmal.")
|
||||
Tipp = input("Willst du einen Tipp für das korrekte Objekt? ").lower()
|
||||
if Tipp == 'ja':
|
||||
print("\n Begebe dich in das Büro um Unterlagen zu den Ersatzteilen zu bekommen.")
|
||||
time.sleep(2)
|
||||
|
||||
|
||||
action = getUserAction()
|
||||
while action != 'w':
|
||||
handleStandardAction(action)
|
||||
action = getUserAction()
|
||||
return 1,0
|
||||
|
||||
else:
|
||||
print("Okay")
|
||||
|
||||
action = getUserAction()
|
||||
while action != 'w':
|
||||
handleStandardAction(action)
|
||||
action = getUserAction()
|
||||
return 1,0
|
||||
|
||||
|
||||
def Büro():
|
||||
print("\nWillkommen im Büro des Kommandanten.")
|
||||
time.sleep(1)
|
||||
print("Vor dir liegen 3 Dokumente: \n \t- 1.Ersatzteile F-16 Tiger\
|
||||
\n \t- 2. Ersatzteile F/A-18 Hornet \n \t- 3.Ersatzteile Saab Gripen \n Mehr Informationen über den \
|
||||
richtigen Flugzeugtypen kriegst du beim Flugzeug.")
|
||||
time.sleep(2)
|
||||
dokument = (input("\n Welches Dokument willst du anschauen?(Nr. des Dokumentes eingeben) "))
|
||||
|
||||
if (randint(1,3) > 2):
|
||||
print("\n\nDeine Basis wurde von einer feindlichen Luft-Boden Rakete getroffen!!!")
|
||||
time.sleep(2)
|
||||
print("Der Raum füllt sich schnell mit Rauch.")
|
||||
time.sleep(2)
|
||||
print("Du musst schnellstmöglich in den \
|
||||
Hangar zum Feuerlöscher kommen.")
|
||||
time.sleep(2)
|
||||
print("Du hast nur noch 3 sekunden um aus dem Raum zu kommen!")
|
||||
time.sleep(2)
|
||||
|
||||
now = datetime . datetime . now ()
|
||||
midnight = now . replace ( hour =0 , minute =0 , second =0 , microsecond =0)
|
||||
seconds1 = ( now - midnight ) . seconds
|
||||
|
||||
action = getUserAction()
|
||||
|
||||
while action != 'o':
|
||||
now = datetime . datetime . now ()
|
||||
midnight = now . replace ( hour =0 , minute =0 , second =0 , microsecond =0)
|
||||
seconds2 = ( now - midnight ) . seconds
|
||||
if ((seconds2 - seconds1)>3):
|
||||
print("\nDu kannst dich nicht mehr retten und das Feuer verschlingt dich!")
|
||||
time.sleep(1)
|
||||
verloren()
|
||||
|
||||
else:
|
||||
handleStandardAction(action)
|
||||
action = getUserAction()
|
||||
|
||||
now = datetime . datetime . now ()
|
||||
midnight = now . replace ( hour =0 , minute =0 , second =0 , microsecond =0)
|
||||
seconds2 = ( now - midnight ) . seconds
|
||||
if ((seconds2 - seconds1)>3):
|
||||
verloren()
|
||||
else:
|
||||
print("\nDu schaffst es gerade noch aus dem Raum hinauszurennen.")
|
||||
time.sleep(2)
|
||||
print("Du packst den Feuerlöscher\n\
|
||||
und kannst das Büro rechtzeitig von den Flammen befreien.")
|
||||
time.sleep(4)
|
||||
return 1
|
||||
|
||||
|
||||
while dokument != "1" and dokument != "2" and dokument != "3":
|
||||
handleStandardAction(dokument)
|
||||
print("Achte darauf, dass du nur die Zahl des Dokumentes eingibst.")
|
||||
dokument = (input("\n Welches Dokument willst du anschauen?(Nr. des Dokumentes eingeben) "))
|
||||
|
||||
|
||||
if dokument == '1':
|
||||
print("\n Ersatzteile: rechter Flügel => Kupferleitung, linker Flügel => rote Lampe")
|
||||
elif dokument == '2':
|
||||
print("Ersatzteile: rechter Flügel => ",end="")
|
||||
print(Objekt,end=", ")
|
||||
print("linker Flügel => blaue Lampe")
|
||||
elif dokument == '3':
|
||||
print("\n Ersatzteile: rechter Flügel => rote Lampe, linker Flügel => Metallröhre")
|
||||
|
||||
action = getUserAction()
|
||||
|
||||
while action != 'o':
|
||||
handleStandardAction(action)
|
||||
action = getUserAction()
|
||||
return 1
|
||||
|
||||
def Kampfflugzeug(o):
|
||||
print("\n Du befindest dich nun beim Kampfflugzeug F/A-18.")
|
||||
time.sleep(1)
|
||||
if o == 0 or o == 1:
|
||||
action = input("Hast du das korrekte Ersatzteil dabei und willst es einbauen? ").lower()
|
||||
if action == 'ja' and o == 1:
|
||||
time.sleep(1.5)
|
||||
inventory.remove(Objekt)
|
||||
print("\nSuper, du hast das Flugzeug repariert!")
|
||||
time.sleep(1)
|
||||
print("Nun musst den Kampfjet zum Starten auf die Startbahn bringen.\nÖffne zuerst das Tor vor dir und \
|
||||
hole anschliessend den Pushback, welcher hinter dem Tor steht.")
|
||||
time.sleep(2)
|
||||
d = getUserAction()
|
||||
while d != 'n' and d != 's' and d != 'o' and d != 'w':
|
||||
handleStandardAction(d)
|
||||
d = getUserAction()
|
||||
if d == 'n':
|
||||
return 5,2
|
||||
elif d == 's':
|
||||
return 1,2
|
||||
elif action == 'o':
|
||||
return 2,2
|
||||
elif action == 'w':
|
||||
return 3,2
|
||||
|
||||
elif action != 'ja' and action != 'nein':
|
||||
handleStandardAction(action)
|
||||
|
||||
if o == 0:
|
||||
print("\n Du hast das richtige Ersatzteil leider nicht dabei.\n Hol zuerst das richtige Ersatzteil im \
|
||||
Raum der Techniker.")
|
||||
else:
|
||||
Kampfflugzeug(o)
|
||||
time.sleep(1)
|
||||
action = getUserAction()
|
||||
|
||||
if action == 'o':
|
||||
return 2,0
|
||||
elif action == 'w':
|
||||
return 3,0
|
||||
elif action == 'egal':
|
||||
print("\n Mir auch egal, lass uns einfach sagen du hast es geschafft.")
|
||||
time.sleep(4)
|
||||
elif action == 's':
|
||||
return 1,0
|
||||
else:
|
||||
handleStandardAction(action)
|
||||
return 4,0
|
||||
else:
|
||||
time.sleep(1)
|
||||
action = getUserAction()
|
||||
if action == 'o':
|
||||
return 2,2
|
||||
elif action == 'w':
|
||||
return 3,2
|
||||
elif action == 'egal':
|
||||
print("\n Mir auch egal, lass uns einfach sagen, dass du es geschafft hast.")
|
||||
time.sleep(4)
|
||||
elif action == 's':
|
||||
return 1,2
|
||||
elif action == "n":
|
||||
return 5,2
|
||||
else:
|
||||
handleStandardAction(action)
|
||||
return 4,2
|
||||
|
||||
def Tor():
|
||||
print("\nDu befindest dich beim Tor. Gib den korrekten Code ein um es zu öffnen.\n \
|
||||
Den Code findest du in deinem Inventar")
|
||||
time.sleep(1)
|
||||
Code = input("Code:").lower()
|
||||
|
||||
if Code == '4934':
|
||||
print("Sehr gut, das Tor öffnet sich.")
|
||||
d = getUserAction()
|
||||
while d != 's' and d != 'n':
|
||||
handleStandardAction(d)
|
||||
d = getUserAction()
|
||||
if d == 's':
|
||||
return 4
|
||||
if d == 'n':
|
||||
return 6
|
||||
elif Code == "9768" or Code == "1234" or Code == "1482":
|
||||
print("Dies ist leider nicht der korrekte Code.")
|
||||
tipp = input("Willst du einen Tipp für den korrekten Code?")
|
||||
if tipp == "ja":
|
||||
print("Die erste Nummer des Codes ist die zweite Nachkommastelle von Pi")
|
||||
time.sleep(3)
|
||||
return 5
|
||||
else:
|
||||
return 5
|
||||
else:
|
||||
handleStandardAction(Code)
|
||||
return 5
|
||||
|
||||
|
||||
def draussen():
|
||||
print("\nDu stehst draussen vor dem Hangar.\n Du musst den Flieger nur noch mit dem Pushback auf die Startbahn bringen.")
|
||||
time.sleep(1)
|
||||
print("Geh nach Norden und anschliessen nach Westen um den Pushback zu holen und ihn an den Jet anzuschliessen.\n")
|
||||
D = getUserAction()
|
||||
while D != "n":
|
||||
handleStandardAction(D)
|
||||
D = getUserAction()
|
||||
|
||||
print("Gut")
|
||||
time.sleep(0.5)
|
||||
|
||||
D = getUserAction()
|
||||
while D != "w":
|
||||
handleStandardAction(D)
|
||||
D = getUserAction()
|
||||
|
||||
time.sleep(1)
|
||||
return 7
|
||||
|
||||
def Pushback():
|
||||
print("\nDu bist beim Pushback angekommen und schliesst ihn an das Kampfflugzeug an.")
|
||||
time.sleep(2)
|
||||
print("Du steigst in den Pushback ein und musst ihn mit dem Flieger zum Anfang der Piste fahren.")
|
||||
time.sleep(3)
|
||||
print("Dein Zielort wird auf der Piste mit vier kleinen orangen Vierecken gekennzeichnet sein.")
|
||||
time.sleep(5)
|
||||
print("\nJetzt musst du mit den Rechts- Linkspfeilen deiner Tastatur den Pushback steuern.")
|
||||
print("Wenn du den rechten Pfeil einmal drückst macht der Pushback eine Rechtskurve und umgekehrt.")
|
||||
time.sleep(6)
|
||||
print("Wenn sich kein neues Fenster automatisch öffnet,\n\
|
||||
musst du noch manuell unten in deiner Leiste auf das neue Programm draufklicken.")
|
||||
time.sleep(3)
|
||||
d = input("Bist du bereit?")
|
||||
while d != "ja":
|
||||
handleStandardAction(d)
|
||||
d = input("Bist du bereit?")
|
||||
onkey(golt,"Left")
|
||||
onkey(gort,"Right")
|
||||
listen()
|
||||
ht()
|
||||
pu()
|
||||
speed(0)
|
||||
width(3)
|
||||
tracer(0)
|
||||
sc=Screen()
|
||||
sc.setup(1200,600)
|
||||
|
||||
a = -500
|
||||
b = -300
|
||||
c = True
|
||||
f = 1
|
||||
corx2 = 576
|
||||
cory2 = 260
|
||||
|
||||
while c:
|
||||
clear()
|
||||
Startpunkt()
|
||||
Piste()
|
||||
Ende()
|
||||
setpos(a,b)
|
||||
pd()
|
||||
drawCart()
|
||||
pu()
|
||||
fd(1.5)
|
||||
rt(90)
|
||||
a = xcor()
|
||||
b = ycor()
|
||||
if ((a > 566) and (a < 587)) and ((b > 250) and (b < 270)):
|
||||
lt(90)
|
||||
for i in range(130):
|
||||
clear()
|
||||
Startpunkt()
|
||||
Piste()
|
||||
setpos(corx2,cory2)
|
||||
pd()
|
||||
Jet()
|
||||
pu()
|
||||
lt(180)
|
||||
setheading(towards(620,260))
|
||||
backward(f)
|
||||
f = f + 0.2
|
||||
corx2 = xcor()
|
||||
cory2 = ycor()
|
||||
update()
|
||||
time.sleep(1)
|
||||
clear()
|
||||
setpos(0,0)
|
||||
if __name__ == '__main__':
|
||||
Thread(target = abspann).start()
|
||||
for i in range(10000):
|
||||
a = random()
|
||||
b = random()
|
||||
c = random()
|
||||
bgcolor(a, b, c)
|
||||
color("Black")
|
||||
write("\tNice \nDu hast es geschafft!!!",align = "center", font=("Castellar", 20, "normal"))
|
||||
c = False
|
||||
update()
|
||||
|
||||
def Startpunkt():
|
||||
color("black")
|
||||
setpos(-500,-300)
|
||||
fd(16)
|
||||
lt(90)
|
||||
fd(16)
|
||||
for i in range(4):
|
||||
pd()
|
||||
begin_fill()
|
||||
for i in range(4):
|
||||
fd(6)
|
||||
rt(90)
|
||||
end_fill()
|
||||
pu()
|
||||
lt(90)
|
||||
fd(32)
|
||||
|
||||
def Ende():
|
||||
width(1)
|
||||
color("black","orange")
|
||||
pu()
|
||||
setpos(576,260)
|
||||
fd(10)
|
||||
lt(90)
|
||||
fd(10)
|
||||
for i in range(4):
|
||||
pd()
|
||||
begin_fill()
|
||||
for i in range(4):
|
||||
fd(5)
|
||||
rt(90)
|
||||
end_fill()
|
||||
pu()
|
||||
lt(90)
|
||||
fd(20)
|
||||
rt(90)
|
||||
width(3)
|
||||
|
||||
|
||||
def drawCart():
|
||||
rt(90)
|
||||
color("black","gold")
|
||||
begin_fill()
|
||||
fd(12)
|
||||
left(90)
|
||||
fd(15)
|
||||
left(90)
|
||||
fd(8)
|
||||
rt(90)
|
||||
fd(5)
|
||||
lt(90)
|
||||
fd(8)
|
||||
lt(90)
|
||||
fd(5)
|
||||
rt(90)
|
||||
fd(8)
|
||||
lt(90)
|
||||
fd(15)
|
||||
lt(90)
|
||||
fd(12)
|
||||
lt(90)
|
||||
end_fill()
|
||||
rt(90)
|
||||
width(2)
|
||||
color("black","silver")
|
||||
begin_fill()
|
||||
rt(60)
|
||||
fd(17)
|
||||
rt(120)
|
||||
fd(5)
|
||||
lt(120)
|
||||
fd(30)
|
||||
rt(120)
|
||||
fd(15)
|
||||
lt(90)
|
||||
fd(3)
|
||||
rt(90)
|
||||
fd(6)
|
||||
rt(90)
|
||||
fd(3)
|
||||
lt(90)
|
||||
fd(15)
|
||||
rt(120)
|
||||
fd(30)
|
||||
lt(120)
|
||||
fd(6)
|
||||
rt(120)
|
||||
fd(17)
|
||||
rt(60)
|
||||
end_fill()
|
||||
lt(90)
|
||||
|
||||
def Jet():
|
||||
width(2)
|
||||
color("black","silver")
|
||||
begin_fill()
|
||||
rt(60)
|
||||
fd(17)
|
||||
rt(120)
|
||||
fd(5)
|
||||
lt(120)
|
||||
fd(30)
|
||||
rt(120)
|
||||
fd(15)
|
||||
lt(90)
|
||||
fd(3)
|
||||
rt(90)
|
||||
fd(6)
|
||||
rt(90)
|
||||
fd(3)
|
||||
lt(90)
|
||||
fd(15)
|
||||
rt(120)
|
||||
fd(30)
|
||||
lt(120)
|
||||
fd(6)
|
||||
rt(120)
|
||||
fd(17)
|
||||
rt(60)
|
||||
end_fill()
|
||||
lt(90)
|
||||
|
||||
def Piste():
|
||||
setpos(0,790)
|
||||
width(10)
|
||||
color("dimgray","gray")
|
||||
begin_fill()
|
||||
fd(600)
|
||||
lt(90)
|
||||
pd()
|
||||
fd(600)
|
||||
for i in range(3):
|
||||
lt(90)
|
||||
fd(1200)
|
||||
lt(90)
|
||||
fd(600)
|
||||
rt(90)
|
||||
pu()
|
||||
backward(600)
|
||||
end_fill()
|
||||
width(3)
|
||||
|
||||
|
||||
def gort():
|
||||
right(90)
|
||||
|
||||
def golt():
|
||||
left(90)
|
||||
|
||||
|
||||
def abspannturtle():
|
||||
for i in range(10000):
|
||||
a = random()
|
||||
b = random()
|
||||
c = random()
|
||||
bgcolor(a, b, c)
|
||||
color("Black")
|
||||
write("\tNice \nDu hast es geschafft!!!",align = "center", font=("Castellar", 20, "normal"))
|
||||
|
||||
def abspann():
|
||||
print("\n \n \t Gratuliere!!! \n \t Du hast es geschafft, das Flugzeug korrekt zu reparieren\
|
||||
\n \t und auf die Startbahn zu bringen.\n \t THE END")
|
||||
time.sleep(30)
|
||||
|
||||
def verloren():
|
||||
print("\n\n\t Du hast es leider nicht geschafft und bist gestorben. \n\t Versuch es nochmal!\n")
|
||||
time.sleep(999)
|
||||
|
||||
def showInventory():
|
||||
time.sleep(0.5)
|
||||
a = 0
|
||||
for i in range(len(inventory)):
|
||||
print("-",inventory[a])
|
||||
a = a + 1
|
||||
|
||||
def showHelp():
|
||||
print("""\nnorden = n \tsüden = s
|
||||
osten = o \twesten = w
|
||||
show help = h \tshow inventory = i""")
|
||||
|
||||
def getUserAction():
|
||||
action = input("Wohin willst du gehen?").lower()
|
||||
return action
|
||||
|
||||
def handleStandardAction(action):
|
||||
if action == 'i':
|
||||
#inventar anzeigen:
|
||||
showInventory()
|
||||
elif action == 'h':
|
||||
showHelp()
|
||||
elif action in ['n','s','o','w']:
|
||||
print("Da kannst du leider nicht lang")
|
||||
else:
|
||||
print("\nDas verstehe ich leider nicht")
|
||||
|
||||
inventory = ["Code Tor Nr. 1: 9768","Code Tor Nr. 2: 1234","Code Tor Nr. 3: 4934", "Code Tor Nr. 4: 1482","Schraubenzieher","Messlatte"]
|
||||
|
||||
def main():
|
||||
cover()
|
||||
einfuehrung()
|
||||
grundriss()
|
||||
next = 1
|
||||
objekt = 0
|
||||
while next != 0:
|
||||
if next == 1:
|
||||
next = Hangar()
|
||||
elif next == 2:
|
||||
next1 = Objektraum()
|
||||
next = next1[0]
|
||||
objekt = next1[1]
|
||||
elif next == 3:
|
||||
next = Büro()
|
||||
elif next == 4:
|
||||
next2 = Kampfflugzeug(objekt)
|
||||
next = next2[0]
|
||||
objekt = next2[1]
|
||||
elif next == 5:
|
||||
next = Tor()
|
||||
elif next == 6:
|
||||
next = draussen()
|
||||
elif next == 7:
|
||||
next = Pushback()
|
||||
elif next == 10:
|
||||
abspann()
|
||||
|
||||
main()
|
||||
|
||||
Reference in New Issue
Block a user