Update game.py

2D, 3D
This commit is contained in:
EmanuelLoos 2017-07-06 11:51:38 +02:00 committed by GitHub
parent c895254fb6
commit 04934958a2
1 changed files with 135 additions and 41 deletions

176
game.py
View File

@ -1,27 +1,55 @@
#Dungeon Spiel Emanuel
import random
eg=("Mmh...","Mhh...","Schmatz...","Mampf...")
lg=("Lecker!","Das war aber gut!")
dungeon="..w..K.w.G...K.w.G..K..w..K..G.w.K.$..K.w.G.K.w.w.K.w.G.K.€.K.G.w.K..wKG.K.G.K.€.G.K.G.K.w.G.K.G.K..€.G.K.G.K.w..K.G.w.K.w.$.w.K.w.G.K.p"
#dungeon="""
#dungeon="..w..K.w.G...K.w.G..K..w..K..G.w.K.$..K.w.G.K.w.w.K.w.G.K.€.K.G.w.K..wKG.K.G.K.€.G.K.G.K.w.G.K.G.K..€.G.K.G.K.w..K.G.w.K.w.$.w.K.w.G.K.p"
dungeon1="""
############################################################################################################################
#..........................................................................................................................#
#..........................................................................................................................#
#..........................................................................................................................#
#..........................................................................................................................#
#..........................................................................................................................#
#..........................................................................................................................#
#..........................................................................................................................#
#..........................................................................................................................#
#..........................................................................................................................#
#..........................................................................................................................#
#..........................................................................................................................#
#..........................................................................................................................#
#..........................................................................................................................#
#..........................................................................................................................#
#..........................................................................................................................#
#..........................................................................................................................#
#.<################################################################################################.#######.################
##.#########################################################################################################################
##.#########################################################################################################################
##.###...........................................................................................................###########
##.###.###############.#########################################################################################.###########
##.###.....###########......#####..#############################################################################.###########
##.#######..##########.####......##..###########################################################################.###########
##.#####...###########.#########################################################################################.###########
##.#####.#############.#########################################################################################.###########
##.#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#########.###########
#......k.....#.........#.........#.........#...........#.........#.........#...........#.....#...#....B#########.###########
####d#d#s#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#########.###########
########p#####k#.#.#.#.#########################################################################################.###########
################.#.#.#.#########################################################################################.###########
################.#.#.#.#########################################################################################.###########
################.#.#.#.############################################################################.#######.####.###########
################.#.#.#.#########################################################################################.###########
################.................................................................................................###########
############################################################################################################################
############################################################################################################################
############################################################################################################################
############################################################################################################################
############################################################################################################################
############################################################################################################################
############################################################################################################################
############################################################################################################################
"""
dungeon2="""
############################################################################################################################
#.>.................................................................................................#######.....#######....#
#......................................................................................................#...........#.......#
#......................................................................................................#...........#.......#
#......................................................................................................#...........#.......#
#......................................................................................................#...........#.......#
#......................................................................................................#...........#.......#
#......................................................................................................#...........#.......#
#......................................................................................................#...........#.......#
#......................................................................................................#...........#.......#
#......................................................................................................#...........#.......#
-->....................................................................................................#...........#.......#
#......................................................................................................#...........#.......#
#......................................................................................................#...........#.......#
#......................................................................................................#...........#.......#
#......................................................................................................#...........#.......#
#...................................................................................................#######.....#######....#
#..........................................................................................................................#
#..........................................................................................................................#
#..........................................................................................................................#
@ -32,15 +60,55 @@ dungeon="..w..K.w.G...K.w.G..K..w..K..G.w.K.$..K.w.G.K.w.w.K.w.G.K.€.K.G.w.K..
#..........................................................................................................................#
#..........................................................................................................................#
############################################################################################################################
#"""
"""
dungeon3="""
############################################################################################################################
#..........................................................................................#######..#######..#######.......#
#.............................................................................................#........#........#..........#
#.............................................................................................#........#........#..........#
#.............................................................................................#........#........#..........#
#.............................................................................................#........#........#..........#
#.............................................................................................#........#........#..........#
#.............................................................................................#........#........#..........#
#.............................................................................................#........#........#..........#
#.............................................................................................#........#........#..........#
#.............................................................................................#........#........#..........#
-->...........................................................................................#........#........#..........#
#.............................................................................................#........#........#..........#
#.............................................................................................#........#........#..........#
#.............................................................................................#........#........#..........#
#.............................................................................................#........#........#..........#
#..........................................................................................#######..#######..#######.......#
#..........................................................................................................................#
#..........................................................................................................................#
#..........................................................................................................................#
#..........................................................................................................................#
#..........................................................................................................................#
#..........................................................................................................................#
#..........................................................................................................................#
#..........................................................................................................................#
#..........................................................................................................................#
############################################################################################################################
"""
hero="@"
herox=0
herox=1
heroy=2
heroz=0
hero_Gold=0
hero_Wurstsemmel=0
hero_Wurstsemmel=3000
hero_hunger=0
hero_hp=1000
hero_hp=1
#level=list(dungeon)
level=[]
for d in (dungeon1,dungeon2,dungeon3):
l=[]
for line in d.splitlines():
l.append(list(line))
level.append(l)
level=list(dungeon)
while True:
if hero_hunger>30:
print("Du bist verhungert!\nVersager")
@ -48,24 +116,41 @@ while True:
if hero_hunger<-1:
print("Dein Bauch ist geplatzt!\nVersager")
break
hero_hunger+=random.choice((0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,2))
for x,c in enumerate(level):
if x==herox:
print(hero,end="")
else:
print (c,end="")
print()
hero_hunger+=random.choice((0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,2))
#for x,c in enumerate(level):
# if x==herox:
# print(hero,end="")
# else:
# print (c,end="")
#print()
for y, line in enumerate(level[heroz]):
for x,c in enumerate(line):
if x==herox and y==heroy:
print(hero,end="")
else:
print(c,end="")
print()
command=input("Gold:{} \nWurstsemmeln:{} \nHunger:{}\nLeben:{}\n?".format(hero_Gold,hero_Wurstsemmel,hero_hunger,hero_hp))
dx=0
dy=0
if command=="a":
#herox-=1
dx=-1
if command=="d":
#herox+=1
dx=1
if command=="s":
#heroy-=1
dy=1
if command=="w":
#heroy=1
dy=-1
if command=="e":
if hero_Wurstsemmel>0:
hero_hunger-= random.randint(4,20)
@ -75,26 +160,33 @@ while True:
print("Hilfe!!!\nkein essen mehr!!")
if command=="Zaubertrank":
hero_hp+=100
# ---in Wand gelaufen---
target=level[heroz][heroy+dy][herox+dx]
if target=="#":
dx=0
dy=0
print("Autch ich bin in eine Mauer gelaufen!\nIch werde von einem Trottel kontrolliert!!")
# in Monster gelaufen?
target=level[herox+dx]
#
#target=level[herox+dx]
#---Gorilla anfang---
if target=="G":
print("Ein Gorilla blockiert deinen Weg!")
print("Der Gorilla schlägt dich mit einer Banane!")
schaden=random.randint(1,10)
hero_hp -=schaden
hero_hp-=schaden
print("Du erleidest {} Schaden".format(schaden))
if hero_hp<1:
print:("Du stirbst!\nVersager!")
break
sieg=0.333333
if random.random() < sieg:
level[herox+dx]="."
level[heroz][heroy+dy][herox+dx]="."
print("Du erledigst heldenhaft den Gorilla!!")
else:
print("Du Verlierst!")
dx=0
dy=0
# -------- gorilla ende ---------
#---kobold anfang---
if target=="K":
@ -109,23 +201,25 @@ while True:
sieg=0.7
if random.random() < sieg:
print("Du erledigst heldenhaft den Kobold!!")
level[herox+dx]="."
level[heroz][heroy+dy][herox+dx]="."
else:
print("Du Verlierst!")
dx=0
dy=0
# -------- kobold ende ---------
herox+=dx
heroy+=dy
#Aufheben
stuff=level[herox]
stuff=level[heroz][heroy][herox]
if stuff=="" or stuff=="$":
hero_Gold+=1
level[herox]="."
level[heroz][heroy][herox]="."
if stuff=="w":
hero_Wurstsemmel+=1
level[herox]="."
level[heroz][heroy][herox]="."
if stuff=="p":
print("Du hast die Prinzessin befreit!")
level[herox]="p"
level[heroz][heroy][herox]="p"
break