23.09. und 22.09.
This commit is contained in:
+118
-17
@@ -1,25 +1,60 @@
|
||||
import copy
|
||||
import pygame
|
||||
import random
|
||||
pygame.init()
|
||||
pygame.mixer.init()
|
||||
|
||||
class MeinSpiel:
|
||||
bilder = []
|
||||
for i in range(20):
|
||||
bilder.append("Bilder/"+str(i)+".jpg")
|
||||
hintergrundstile = ["Sand","Gras"]
|
||||
hintergrundstil = random.choice(hintergrundstile)
|
||||
bilder = ["Bilder/Spieler.xcf"]
|
||||
for i in range(6):
|
||||
bilder.append("Bilder/"+hintergrundstil+str(i+1)+".xcf")
|
||||
bilder.append("Bilder/Monster.xcf")
|
||||
spielfeld = []
|
||||
feldunterspieler=random.randint(0,5)
|
||||
feldunterspieler=random.randint(1,5)
|
||||
felduntermonster=random.randint(1,5)
|
||||
game_over = False
|
||||
|
||||
def __init__(self, felderX, felderY):
|
||||
for x in range(felderX):
|
||||
self.spielfeld.append([])
|
||||
for y in range(felderY):
|
||||
self.spielfeld[x].append(random.randint(0,5))
|
||||
self.spielfeld[x].append(random.randint(1,6))
|
||||
|
||||
def anfangsKonfiguration(self):
|
||||
self.spielerx = random.randint(5,9)
|
||||
self.spielery = random.randint(5,9)
|
||||
self.spielfeld[self.spielerx][self.spielery] = 6
|
||||
self.spielfeld[self.spielerx][self.spielery] = 1
|
||||
self.monsterx = random.randint(5,9)
|
||||
self.monstery = random.randint(5,9)
|
||||
self.spielfeld[self.monsterx][self.monstery] = 1
|
||||
|
||||
|
||||
|
||||
def spawnSpieler(self):
|
||||
self.spielfeld[self.spielerx][self.spielery] = 0
|
||||
self.spielfeld[self.monsterx][self.monstery] = self.felduntermonster
|
||||
self.altmonsterx = self.monsterx
|
||||
self.altmonstery = self.monstery
|
||||
self.felduntermonsteralt = self.felduntermonster
|
||||
self.monsterx,self.monstery = monster.bewegen(monster,self.monsterx,self.monstery)
|
||||
self.felduntermonster = self.spielfeld[self.monsterx][self.monstery]
|
||||
|
||||
if self.felduntermonster != 6:
|
||||
self.spielfeld[self.monsterx][self.monstery] = 7
|
||||
|
||||
else:
|
||||
self.spielfeld[self.altmonsterx][self.altmonstery] = 7
|
||||
self.spielfeld[self.monsterx][self.monstery] = 6
|
||||
self.felduntermonster = self.felduntermonsteralt
|
||||
self.monsterx = self.altmonsterx
|
||||
self.monstery = self.altmonstery
|
||||
|
||||
|
||||
if self.spielerx == self.monsterx and self.spielery == self.monstery:
|
||||
self.game_over = True
|
||||
|
||||
def rechts(self):
|
||||
self.spielerx += 1
|
||||
def links(self):
|
||||
@@ -34,35 +69,101 @@ class MeinSpiel:
|
||||
self.spielfeld[self.spielerx][self.spielery] = self.feldunterspieler
|
||||
posalt=[self.spielerx,self.spielery]
|
||||
feldunterspieleralt=self.feldunterspieler
|
||||
if taste == 1:
|
||||
|
||||
if taste == 1 and self.spielerx < 41:
|
||||
self.rechts()
|
||||
if taste == 2:
|
||||
sound.Schrittsound(sound)
|
||||
if taste == 2 and self.spielerx > 0:
|
||||
self.links()
|
||||
if taste == 3:
|
||||
sound.Schrittsound(sound)
|
||||
if taste == 3 and self.spielery < 41:
|
||||
self.unten()
|
||||
if taste == 4:
|
||||
sound.Schrittsound(sound)
|
||||
if taste == 4 and self.spielery > 0:
|
||||
self.oben()
|
||||
sound.Schrittsound(sound)
|
||||
self.feldunterspieler = self.spielfeld[self.spielerx][self.spielery]
|
||||
if self.feldunterspieler== 5:
|
||||
if self.feldunterspieler== 6:
|
||||
self.spielerx,self.spielery = posalt
|
||||
self.feldunterspieler=feldunterspieleralt
|
||||
verschiebung = self.hinergrundverschieben(xverschiebungaktuell,yverschiebungaktuell)
|
||||
|
||||
self.spielfeld[self.spielerx][self.spielery] = 6
|
||||
self.spielfeld[self.spielerx][self.spielery] = 0
|
||||
return verschiebung
|
||||
|
||||
|
||||
def hinergrundverschieben(self,xverschiebungaktuell,yverschiebungaktuell):
|
||||
xverschiebung=0
|
||||
yverschiebung=0
|
||||
if self.spielerx >= 11-xverschiebungaktuell:
|
||||
if self.spielerx >= 11-xverschiebungaktuell and self.spielerx <= 38 and self.spielerx >= 3:
|
||||
xverschiebung = -1
|
||||
if self.spielerx <= 2-xverschiebungaktuell:
|
||||
if self.spielerx <= 2-xverschiebungaktuell and self.spielerx <= 38 and self.spielerx >= 3:
|
||||
xverschiebung = 1
|
||||
if self.spielery >= 11-yverschiebungaktuell:
|
||||
if self.spielery >= 11-yverschiebungaktuell and self.spielery <= 38 and self.spielery >= 3:
|
||||
yverschiebung = -1
|
||||
if self.spielery <= 2-yverschiebungaktuell:
|
||||
if self.spielery <= 2-yverschiebungaktuell and self.spielery <= 38 and self.spielery >= 3:
|
||||
yverschiebung = 1
|
||||
verschiebung=[xverschiebung,yverschiebung]
|
||||
return verschiebung
|
||||
|
||||
|
||||
|
||||
|
||||
class sound:
|
||||
hintergrundsong1 = pygame.mixer.Sound("Sounds/Ritter Der Kokosnuss - ending song.mp3")
|
||||
hintergrundsong1.set_volume(0.8)
|
||||
SchleimSchritt = pygame.mixer.Sound("Sounds/Schleim_Schritt.mp3")
|
||||
Hintergrundkanal = pygame.mixer.Channel(0)
|
||||
Kanal1 = pygame.mixer.Channel(1)
|
||||
Kanal2 = pygame.mixer.Channel(2)
|
||||
Kanal3 = pygame.mixer.Channel(3)
|
||||
Kanal4 = pygame.mixer.Channel(4)
|
||||
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
def hintergrundmusik(self):
|
||||
if not self.Hintergrundkanal.get_busy():
|
||||
self.Hintergrundkanal.play(self.hintergrundsong1)
|
||||
def Schrittsound(self):
|
||||
self.Kanal1.play(self.SchleimSchritt)
|
||||
|
||||
|
||||
class monster:
|
||||
cooldownx = 1
|
||||
cooldowny = 1
|
||||
|
||||
def __init__(self):
|
||||
pass
|
||||
def bewegen(self,xpos,ypos):
|
||||
print(self.cooldowny)
|
||||
print()
|
||||
print(self.cooldownx)
|
||||
print()
|
||||
print()
|
||||
print()
|
||||
xrichtung = random.randint(1,50*(self.cooldownx))
|
||||
if xrichtung == 1 and xpos < 41:
|
||||
xpos += 1
|
||||
self.cooldownx = 100
|
||||
if xrichtung == 2 and xpos > 0:
|
||||
xpos -= 1
|
||||
self.cooldownx = 100
|
||||
|
||||
if self.cooldownx != 1:
|
||||
self.cooldownx -= 1
|
||||
|
||||
|
||||
yrichtung = random.randint(1,50*(self.cooldowny))
|
||||
if yrichtung == 1 and xpos < 41:
|
||||
ypos += 1
|
||||
self.cooldowny = 100
|
||||
if yrichtung == 2 and ypos > 0:
|
||||
ypos -= 1
|
||||
self.cooldowny = 100
|
||||
|
||||
if self.cooldowny != 1:
|
||||
self.cooldowny -= 1
|
||||
|
||||
|
||||
return xpos,ypos
|
||||
|
||||
|
||||
Reference in New Issue
Block a user