Feld V6
Spiel.py — Python Source, 47 KB (48634 bytes)
Dateiinhalt
# -*- coding: utf-8 -*- from visual import * from random import choice import time from threading import Thread PORT = 54321 # Die Spielfiguren: class Spielfigur_Lena(frame): def __init__(self, mat=materials.silver, col=color.hsv_to_rgb((0.84,0.65,0.65))): frame.__init__(self) self.head=ellipsoid(frame=self, pos=(0,0.4,0), length=1.1, height=0.7, width=0.6, material=mat,color=col) self.body=cylinder(frame=self, pos=(0,0.4,0), axis=(0,-0.9,0), radius=0.25, material=mat, color=col) self.beinl=box(frame=self, pos=(-0.1,-0.2,0),length=0.08, width=0.08, height=1.2, material=mat, color=col) self.beinr=box(frame=self, pos=(0.1,-0.2,0),length=0.08, width=0.08, height=1.2, material=mat, color=col) self.antenl=helix(frame=self, pos=(-0.18,0.7,0), axis=(-0.1,0.3,0), radius=0.02, thickness=0.01/2, material=materials.chrome) self.antenr=helix(frame=self, pos=(0.18,0.7,0), axis=(0.1,0.3,0), radius=0.02, thickness=0.01/2, material=materials.chrome) self.eye=sphere(frame=self, pos=(0,0.44,0.27), radius=0.12, color=color.hsv_to_rgb((0.2,0.5,1)),material=materials.chrome) self.eyering=sphere(frame=self, pos=(0,0.44,0.23), radius=0.14,color=color.black, material=materials.shiny) self.name= label(pos=(0, 1.3, 0), linecolor=col, frame= self, text= "Player3") class Spielfigur_Mario (frame): def __init__(self, farbeCube=color.red, farbeSpikes=(0/255.0, 255/255.0, 0/255.0), stoffCube= materials.wood, stoffSpikes= materials.blazed, farbeFace= (255/255.0, 68/255.0, 0/255.0), stoffFace= materials.rough, farbeOthers= (0/255.0, 255/255.0, 0/255.0), stoffOthers= materials.chrome, spielerfarbe1= color.green): frame.__init__(self) self.cube= box(pos=(0.5,0.5,0.5), length=1, heigh=1, width=1,color=farbeCube, material=stoffCube, frame=self) self.spike1= cone (axis=(-0.5,0,0), pos=(0, 0.5,0.5), frame=self, radius= 0.2, color=farbeSpikes, material= stoffSpikes) self.spike2= cone (axis=(0,0,-0.5), pos=(0.5, 0.5, 0), frame=self,radius= 0.2, color=farbeSpikes, material= stoffSpikes) self.spike3= cone (axis=(0.5, 0, 0), pos=(1,0.5,0.5), frame=self,radius= 0.2, color=farbeSpikes, material= stoffSpikes) self.spike4= cone (axis=(0, 0.5, 0), pos=(0.5,1,0.5), frame=self,radius= 0.2, color=farbeSpikes, material= stoffSpikes) self.spikeDown= cone (axis=(0, -1, 0), pos=(0.5,0,0.5), frame=self,radius= 0.2, color=farbeSpikes, material= stoffSpikes) self.eye1= sphere(radius=0.1, pos=(0.25, 0.75, 1), frame=self, color= farbeFace, material= stoffFace) self.eye2= sphere(radius=0.1, pos=(0.75, 0.75, 1), frame=self, color= farbeFace, material= stoffFace) self.nose= cone (axis=(0, 0, 0.25), pos=(0.5,0.5,1), frame=self,radius= 0.1, color=farbeSpikes, material= stoffSpikes) self.mouth= ellipsoid (axis=(0.5,0,0), pos=(0.5,0.2,1), width=0.1, height= 0.22, length= 0.2, frame=self,radius= 0.2, color= farbeFace, material= stoffFace) #self.mouth= box(pos=(0.5, 0.2, 1), axis=(1, 0, 0), width=0.2, height=0.1, length= 0.5, frame=self, color= farbeFace, material= stoffFace) self.plate= cylinder (pos=(0.5, -1, 0.5), axis= (0,0.05,0),radius=0.75, frame= self,color= farbeOthers, material= stoffOthers) self.ring= ring (pos=(0.5, -0.75, 0.5), axis= (0,0.02,0),radius=0.5, frame= self, color= farbeOthers, material= stoffOthers) self.ring2= ring (pos=(0.5, -0.5, 0.5), axis= (0,0.02,0),radius=0.3, frame= self, color= farbeOthers, material= stoffOthers) self.name= label(pos=(0.5, 1.75, 0.5), linecolor= spielerfarbe1, frame= self, text= "Player1") class Spielfigur_Kjell(frame): def __init__(self,): frame.__init__(self) self.koerper = ellipsoid(frame = self,height = 1,length = 0.5, width = 0.5,pos = (0,0,0),color = color.red,material = materials.wood) self.hitbox = box(frame = self, pos = (0,0,0),height = 3, width = 2, length = 2, opacity = 0.001) self.gesicht = pyramid(frame = self ,pos= (-0.1,0.7,0),size = (0.75,0.3,0.5),color = color.red,material = materials.wood, axis = (1,-1,0)) self.beinlinks = curve(frame = self ,pos=[(0,-0.2,0),(0.2,-0.8,0.1),(-0.25,-1.1,0.25)],radius = 0.08,color = color.red, material = materials.wood) self.beinrechts = curve(frame = self ,pos=[(0,-0.2,0),(0.25,-0.8,-0.25),(0.25,-1.1,-0.25)],radius = 0.08,color = color.red, material = materials.wood) self.armlinks = curve(frame = self ,pos=[(0,0.45,0),(0,0,0.3),(0.25,-0.3,0.25)],radius = 0.08,color = color.red, material = materials.wood) self.armlinks = curve(frame = self ,pos=[(0,0.45,0),(0,0,-0.3),(0.25,-0.3,-0.25)],radius = 0.08,color = color.red,material = materials.wood) self.augelinks = sphere(frame = self, pos = (0.1,0.7,0.1),radius = 0.05, material = materials.chrome,color = color.orange) self.augerechts = sphere(frame = self, pos = (0.1,0.7,-0.1),radius = 0.05, material = materials.chrome,color = color.orange) self.ohrlinks = pyramid(frame = self, pos = (-0.05,0.75,0.1),size = (0.35,0.1,0.1),axis = (-0.5,1,0), color = color.red,material = materials.wood) self.ohrrechts = pyramid(frame = self, pos = (-0.05,0.75,-0.1),size = (0.35,0.1,0.1),axis = (-0.5,1,0), color = color.red,material = materials.wood) self.name= label(pos=(0, 1.25, 0), linecolor=color.red, frame= self, text= "Player2") # Das Feld: felderliste=[] class standartfield(frame): def __init__(self, col=color.white, position=(0,0,0), visible=True): frame.__init__(self, pos=position) self.field=box(frame=self, length=2, width=2, height=0.03, color=col) #mention=label(pos=(0,0,0),text='Start') class startfield(frame): def __init__(self, col=color.yellow, positionStart=(0,0,0), position=(0,0,0), visible=True): frame.__init__(self, pos=position) self.startground=box(frame=self, pos= positionStart, length=8, width=8, height=1, color=col, material=materials.emissive) #mention=label(pos=(0,0,0),text='Start') self.player1= standartfield(position=(-2,1,-2), col= color.orange) self.player2= standartfield(position=(-2,1,2), col= color.orange) self.player3= standartfield(position=(2,1,-2), col= color.orange) self.player4= standartfield(position=(2,1,2), col= color.orange) class groupedfield (frame): def __init__(self, farbeGround= color.magenta, farbeSpezial=color.green, farbePyramide=color.green, groupedfieldPosition=(0,0,0)): frame.__init__(self) #self.ground= box(pos=(0,0,10), length= 80, width= 80, height= 0.1, color= farbeGround, frame= self) self.feld1= standartfield(position=(8,1,0),col=farbeGround) #Kreuzung 3Uhr self.feld2= standartfield(position=(13,2, 0),col=farbeGround) self.feld3= standartfield(position=(18,3, 0),col=farbeGround) self.feld4= standartfield(position=(23,4,0),col=farbeGround) self.feld5= standartfield(position=(23,3,5),col=farbeGround) self.feld6= standartfield(position=(23,2,10),col=farbeGround) self.feld7= standartfield(position=(23,1,15),col=farbeGround) #Kreuzung 6Uhr self.feld8= standartfield(position=(23,2,20),col=farbeGround) self.feld9= standartfield(position=(23,3,25),col=farbeGround) self.feld10= standartfield(position=(23,4,30),col=farbeGround) self.feld11= standartfield(position=(18,3,30),col=farbeGround) self.feld12= standartfield(position=(13,2,30),col=farbeGround) self.feld13= standartfield(position=(8,1,30),col=farbeGround) #Kreuzung 9Uhr self.feld14= standartfield(position=(3,2,30),col=farbeGround) self.feld15= standartfield(position=(-2,3,30),col=farbeGround) self.feld16= standartfield(position=(-7,4,30),col=farbeGround) self.feld17= standartfield(position=(-7,3,25),col=farbeGround) self.feld18= standartfield(position=(-7,2,20),col=farbeGround) self.feld19= standartfield(position=(-7,1,15),col=farbeGround) #Kreuzung 12Uhr self.feld20= standartfield(position=(-7,2,10),col=farbeGround) self.feld21= standartfield(position=(-7,3,5),col=farbeGround) self.feld22= standartfield(position=(-7,4,0),col=farbeGround) self.feld23= standartfield(position=(-2,3,0),col=farbeGround) self.feld24= standartfield(position=(3,2,0),col=farbeGround) # self.feldA= standartfield(position=(8,1,-5),col=farbeGround) self.feldB= standartfield(position=(28,1,15),col=farbeGround) self.feldC= standartfield(position=(8,1,35),col=farbeGround) self.feldD= standartfield(position=(-12,1,15),col=farbeGround) self.feldAA= standartfield(position=(8,1,-10),col=farbeGround) self.feldBB= standartfield(position=(33,1,15),col=farbeGround) self.feldCC= standartfield(position=(8,1,40),col=farbeGround) self.feldDD= standartfield(position=(-17,1,15),col=farbeGround) # #self.feldAv= standartfield(position=(8,2,5),col=farbeSpezial, visible=False) #self.feldAAv= standartfield(position=(8,3,10),col=farbeSpezial, visible=False) self.feldBv= standartfield(position=(18,2,15),col=farbeSpezial, visible=False) self.feldBBv= standartfield(position=(13,3,15),col=farbeSpezial, visible=False) #self.feldCv= standartfield(position=(8,2,25),col=farbeSpezial, visible=False) #self.feldCCv= standartfield(position=(8,3,20),col=farbeSpezial, visible=False) self.feldDv= standartfield(position=(-2,2,15),col=farbeSpezial, visible=False) self.feldDDv= standartfield(position=(3,3,15),col=farbeSpezial, visible=False) self.feldE= standartfield(position=(8,4,15), col=farbeSpezial, visible=False) self.deko1= pyramid(pos=(8,4,15), size=(5,5,5), axis=(0,-1,0), color=farbePyramide, visible= True, material=materials.chrome) self.deko2= pyramid(pos=(8,4,15), size=(5,5,5), axis=(0,1,0), color=farbePyramide, visible= True, material=materials.chrome) # self.feld1.frame=self self.feld2.frame=self self.feld3.frame=self self.feld4.frame=self self.feld5.frame=self self.feld6.frame=self self.feld7.frame=self self.feld8.frame=self self.feld9.frame=self self.feld10.frame=self self.feld11.frame=self self.feld12.frame=self self.feld13.frame=self self.feld14.frame=self self.feld15.frame=self self.feld16.frame=self self.feld17.frame=self self.feld18.frame=self self.feld19.frame=self self.feld20.frame=self self.feld21.frame=self self.feld22.frame=self self.feld23.frame=self self.feld24.frame=self self.feldA.frame=self self.feldB.frame=self self.feldC.frame=self self.feldD.frame=self self.feldE.frame=self self.feldAA.frame=self self.feldBB.frame=self self.feldCC.frame=self self.feldDD.frame=self #self.feldAv.frame=self self.feldBv.frame=self #self.feldCv.frame=self self.feldDv.frame=self #self.feldAAv.frame=self self.feldBBv.frame=self #self.feldCCv.frame=self self.feldDDv.frame=self self.deko1.frame=self self.deko2.frame=self def special(self, sichtbar): if sichtbar==True: self.feldAv.visible=True self.feldAAv.visible=True self.feldBv.visible= True self.feldBBv.visible=True self.feldCv.visible= True self.feldCCv.visible= True self.feldDv.visible= True self.feldDDv.visible= True self.feldE.visible= True self.deko2.visible= False else: self.feldAv.visible=False self.feldAAv.visible=False self.feldBv.visible= False self.feldBBv.visible=False self.feldCv.visible= False self.feldCCv.visible= False self.feldDv.visible= False self.feldDDv.visible= False self.feldE.visible= False self.deko2.visible= True class felsen(frame): def __init__(self): frame.__init__(self) #steina=box(pos=(0,0,0), length=16, height=2, width=16, frame=self) #steinb=box(pos=(2,3,0), length=5, height=10, width=8, frame=self) #steinc=box(pos=(1,3,-5), length=12, height=4, width=8, frame=self) #steind=box(pos=(-3,1,-1), length=8, height=2, width=12, frame=self) self.feld0=standartfield(position=(-5,-1.5,20)) self.feld0.frame = self self.feld1=standartfield(position=(-5,0,15)) self.feld1.frame = self self.feld2=standartfield(position=(-5,1.5,10),col=color.red) #portfeldEnde self.feld2.frame=self self.feld2a=standartfield(position=(0,1.5,10),col=color.red) #portfeldEnde2#NICHT IN STANDARTLISTE self.feld2b=standartfield(position=(5,1.5,10),col=color.red) #portfeldEnde3 #NICHT IN STANDARTLISTE self.feld3=standartfield(position=(-5,3,5)) self.feld4=standartfield(position=(-5,4.5,0)) self.feld5=standartfield(position=(-5,6,-5)) self.feld6=standartfield(position=(-5,7.5,-10)) self.feld7=standartfield(position=(0,9,-10)) self.feld8=standartfield(position=(5,10.5,-10)) self.feld9=standartfield(position=(10,12,-10)) self.feld10=standartfield(position=(15,13.5,-10)) self.feld10a=standartfield(position=(20,13.5,-10)) self.feld11=standartfield(position=(20,15,-5)) self.feld12=standartfield(position=(20,16.5,0)) self.feld13=standartfield(position=(20,18,5)) self.feld14=standartfield(position=(20,19.5,10)) self.feld15=standartfield(position=(15,21,10)) self.feld16=standartfield(position=(10,22.5,10),col=color.red) #p-1 self.feld17=standartfield(position=(5,24,10) ,col=color.red) #portfeldAnfangMitte self.feld18=standartfield(position=(5,25.5,5),col=color.red) #p+1 self.feld19=standartfield(position=(5,27,0)) self.feld20=standartfield(position=(5,28.5,-5)) self.feld21=standartfield(position=(5,30,-10)) self.feld22=standartfield(position=(5,31.5,-15)) self.feld23=standartfield(position=(5,33,-20)) self.feld24=standartfield(position=(5,33.5,-25)) # self.feld2a.frame=self self.feld2b.frame=self self.feld3.frame=self self.feld4.frame=self self.feld5.frame=self self.feld6.frame=self self.feld7.frame=self self.feld8.frame=self self.feld9.frame=self self.feld10.frame=self self.feld11.frame=self self.feld12.frame=self self.feld13.frame=self self.feld14.frame=self self.feld15.frame=self self.feld16.frame=self self.feld17.frame=self self.feld18.frame=self self.feld19.frame=self self.feld20.frame=self self.feld21.frame=self self.feld22.frame=self self.feld23.frame=self self.feld24.frame=self self.feld10a.frame=self # self.derfels=box(pos=(5,10,0), width=4, length=4, height=32, color= color.blue, material=materials.plastic) self.derfels2=box(pos=(5,35,0), width=4, length=12, height=4, color= color.blue, material=materials.plastic) self.derfels3=box(pos=(1,27,0), width=4, length=4, height=15, color= color.blue, material=materials.plastic) self.derfels4=box(pos=(9,27,0), width=4, length=4, height=15, color= color.blue, material=materials.plastic) self.derfels.frame=self self.derfels2.frame=self self.derfels3.frame=self self.derfels4.frame=self #Kjell's Bombe event1 = frame() koerper = sphere(frame = event1, radius = 0.2, pos = (0,0,0), color = color.black, material = materials.plastic) hitbox = box(frame = event1, pos = (0,0,0),height = 3, width = 2, length = 2, opacity = 0.1) lunte = curve(frame = event1, pos =[(0,0.25,0),(0,0.3,0.15),(0.1,0.3,0.1),(0.15,0.35,0), (0,0.4,-0.1)], radius = 0.01, material = materials.chrome,color = color.black) hals = cylinder(frame = event1, pos = (0,0.1,0), axis = (0,1,0), radius = 0.05, length = 0.15,color = color.black, material = materials.plastic) class funke(frame): def __init__(self,pos = (0,0,0), groesse = 1): frame.__init__(self) self.funke1 = cone(frame = self, pos =(0,0.4,-0.1), axis = (1,0.5,0.5),radius = 0.005*groesse, length = 0.15*groesse, color = color.yellow, material = materials.emissive) self.funke2 = cone(frame = self, pos =(0,0.4,-0.1), axis = (0.5,1,0.5),radius = 0.005*groesse, length = 0.15*groesse, color = color.yellow, material = materials.emissive) self.funke3 = cone(frame = self, pos =(0,0.4,-0.1), axis = (0.5,0.5,1),radius = 0.005*groesse, length = 0.15*groesse, color = color.yellow, material = materials.emissive) self.funke4 = cone(frame = self, pos =(0,0.4,-0.1), axis = (-1,0.5,0.5),radius = 0.005*groesse, length = 0.15*groesse, color = color.yellow, material = materials.emissive) self.funke5 = cone(frame = self, pos =(0,0.4,-0.1), axis = (1,-0.5,0.5),radius = 0.005*groesse, length = 0.15*groesse, color = color.yellow, material = materials.emissive) self.funke6 = cone(frame = self, pos =(0,0.4,-0.1), axis = (1,0.5,-0.5),radius = 0.005*groesse, length = 0.15*groesse, color = color.yellow, material = materials.emissive) self.funke7 = cone(frame = self, pos =(0,0.4,-0.1), axis = (-0.5,1,0.5),radius = 0.005*groesse, length = 0.15*groesse, color = color.yellow, material = materials.emissive) self.funke8 = cone(frame = self, pos =(0,0.4,-0.1), axis = (0.5,-1,0.5),radius = 0.005*groesse, length = 0.15*groesse, color = color.yellow, material = materials.emissive) self.funke9 = cone(frame = self, pos =(0,0.4,-0.1), axis = (0.5,1,-0.5),radius = 0.005*groesse, length = 0.15*groesse, color = color.yellow, material = materials.emissive) self.funke10 = cone(frame = self, pos =(0,0.4,-0.1), axis = (-0.5,0.5,1),radius = 0.005*groesse, length = 0.15*groesse, color = color.yellow, material = materials.emissive) self.funke11 = cone(frame = self, pos =(0,0.4,-0.1), axis = (0.5,-0.5,1),radius = 0.005*groesse, length = 0.15*groesse, color = color.yellow, material = materials.emissive) self.funke12 = cone(frame = self, pos =(0,0.4,-0.1), axis = (0.5,0.5,-1),radius = 0.005*groesse, length = 0.15*groesse, color = color.yellow, material = materials.emissive) self.funke13 = cone(frame = self, pos =(0,0.4,-0.1), axis = (1,-0.5,-0.5),radius = 0.005*groesse, length = 0.15*groesse, color = color.yellow, material = materials.emissive) self.funke14 = cone(frame = self, pos =(0,0.4,-0.1), axis = (-1,0.5,-0.5),radius = 0.005*groesse, length = 0.15*groesse, color = color.yellow, material = materials.emissive) self.funke15 = cone(frame = self, pos =(0,0.4,-0.1), axis = (-1,-0.5,0.5),radius = 0.005*groesse, length = 0.15*groesse, color = color.yellow, material = materials.emissive) self.funke16 = cone(frame = self, pos =(0,0.4,-0.1), axis = (0.5,-1,-0.5),radius = 0.005*groesse, length = 0.15*groesse, color = color.yellow, material = materials.emissive) self.funke17 = cone(frame = self, pos =(0,0.4,-0.1), axis = (-0.5,1,-0.5),radius = 0.005*groesse, length = 0.15*groesse, color = color.yellow, material = materials.emissive) self.funke18 = cone(frame = self, pos =(0,0.4,-0.1), axis = (-0.5,-1,0.5),radius = 0.005*groesse, length = 0.15*groesse, color = color.yellow, material = materials.emissive) self.funke19 = cone(frame = self, pos =(0,0.4,-0.1), axis = (0.5,-0.5,-1),radius = 0.005*groesse, length = 0.15*groesse, color = color.yellow, material = materials.emissive) self.funke20 = cone(frame = self, pos =(0,0.4,-0.1), axis = (-0.5,0.5,-1),radius = 0.005*groesse, length = 0.15*groesse, color = color.yellow, material = materials.emissive) self.funke21 = cone(frame = self, pos =(0,0.4,-0.1), axis = (-0.5,-0.5,1),radius = 0.005*groesse, length = 0.15*groesse, color = color.yellow, material = materials.emissive) self.funke22 = cone(frame = self, pos =(0,0.4,-0.1), axis = (-1,-0.5,-0.5),radius = 0.005*groesse, length = 0.15*groesse, color = color.yellow, material = materials.emissive) self.funke23 = cone(frame = self, pos =(0,0.4,-0.1), axis = (-0.5,-1,-0.5),radius = 0.005*groesse, length = 0.15*groesse, color = color.yellow, material = materials.emissive) self.funke24 = cone(frame = self, pos =(0,0.4,-0.1), axis = (-0.5,-0.5,-1),radius = 0.005*groesse, length = 0.15*groesse, color = color.yellow, material = materials.emissive) ueberschrift=label(pos=(0,-1,0), text="SNAKES 'N' LADDERS \n XTREME!! \nLoading, please wait...\n\n(C)2013 by Lena, Mario, Kjell") event2 = funke(groesse=1) for x in range(0,15,1): event2.pos = ( x / 100.0, 0 - x / 300.0, -0.0 + x / 150.0) lunte.pos[4] =( x / 100.0, 0.4 - x / 300.0, -0.1 + x / 150.0) time.sleep(0.05) for x in range(0,15,1): event2.pos = (0.15 - x / 300.0, -0.05 - x / 300.0, 0.1 + x / 150.0) lunte.pos[4] =(0.15 - x / 300.0, 0.35 - x / 300.0, 0 + x / 150.0) lunte.pos[3] =(0.15 - x / 300.0, 0.35 - x / 300.0, 0 + x / 150.0) time.sleep(0.05) for x in range(0,15,1): event2.pos = (0.1 - x / 150.0, -0.1 , 0.2 + x / 300.0) lunte.pos[4] =(0.1 - x / 150.0, 0.3 , 0.1 + x / 300.0) lunte.pos[3] =(0.1 - x / 150.0, 0.3 , 0.1 + x / 300.0) lunte.pos[2] =(0.1 - x / 150.0, 0.3 , 0.1 + x / 300.0) time.sleep(0.05) for x in range(0,15,1): event2.pos = (0 , -0.1 - x / 250.0 , 0.25 - x / 100.0) lunte.pos[4] =(0 , 0.3 - x / 250.0 , 0.15 - x / 100.0) lunte.pos[3] =(0 , 0.3 - x / 250.0 , 0.15 - x / 100.0) lunte.pos[2] =(0 , 0.3 - x / 250.0 , 0.15 - x / 100.0) lunte.pos[1] =(0 , 0.3 - x / 250.0 , 0.15 - x / 100.0) time.sleep(0.05) for x in range(0,15,1): event2.pos = (0 , -0.15 - x / 65.0 , 0.1) time.sleep(0.01) for x in range(10): explosion = funke(groesse = ( 1 * x)) time.sleep(0.01) time.sleep(3) ueberschrift.visible=False del ueberschrift ##for x in range(10): ## del explosion ## time.sleep(0.01) # pos =[(0,0.25,0),(0,0.3,0.15),(0.1,0.3,0.1),(0.15,0.35,0), (0,0.4,-0.1)], ############################## start=startfield() # erstePlatte=standartfield(position=(-0,1,6), col=color.orange) platte1=standartfield(position=(0,2,11)) platte2=standartfield(position=(0,3,17)) platte3=standartfield(position=(0,4,22)) platte4=standartfield(position=(0,5,27)) platte5=standartfield(position=(0,6,32)) platte6=standartfield(position=(0,7,37)) platte7=standartfield(position=(5,6,37)) platte8=standartfield(position=(10,5,37)) platte9=standartfield(position=(15,4,37)) platte10=standartfield(position=(20,3,37)) platte11=standartfield(position=(25,2,37)) platte12=standartfield(position=(30,1,37)) platte13=standartfield(position=(35,0,37)) platte14=standartfield(position=(40,-1,37)) platte15=standartfield(position=(45,-2,37), col=color.green) #Kreuzung Ladder platte16=standartfield(position=(50,-3,37), col=color.green) platte17=standartfield(position=(55,-4,37), col=color.green) platte18=standartfield(position=(60,-5,37), col=color.green) platte19=standartfield(position=(65,-6,37), col=color.green) platte20=standartfield(position=(70,-7,37), col=color.green) platte21=standartfield(position=(75,-8,37), col=color.green) platte22=standartfield(position=(80,-9,37), col=color.green) platte23=standartfield(position=(85,-10,37), col=color.green) platte24=standartfield(position=(90,-11,37), col=color.green) # platte25=standartfield(position=(45,-2,42)) platte26=standartfield(position=(45,-2,47)) platte27=standartfield(position=(45,-2,52)) platte28=standartfield(position=(45,-2,57)) platte29=standartfield(position=(45,-2,62)) platte29=standartfield(position=(45,-2,67)) platte30=standartfield(position=(50,-3,67)) platte31=standartfield(position=(55,-4,67)) platte32=standartfield(position=(60,-5,67)) platte33=standartfield(position=(65,-6,67)) platte34=standartfield(position=(70,-7,67)) platte35=standartfield(position=(75,-8,67)) platte36=standartfield(position=(80,-9,67)) platte37=standartfield(position=(85,-10,67)) platte38a=standartfield(position=(90,-11,67)) platte38=standartfield(position=(90,-10,62)) platte39=standartfield(position=(90,-9,57)) platte40=standartfield(position=(90,-8,52)) platte41=standartfield(position=(90,-9,47)) platte42=standartfield(position=(90,-10,42)) platte43=standartfield(position=(90,-11,37)) platte44=standartfield(position=(90,-10,32)) platte45=standartfield(position=(90,-9,27)) platte46=standartfield(position=(90,-8,22)) platte47=standartfield(position=(90,-7,17)) platte48=standartfield(position=(90,-6,12)) platte49=standartfield(position=(90,-5,7)) platte50=standartfield(position=(90,-4,2)) platte51=standartfield(position=(90,-3,-2)) platte52=standartfield(position=(90,-2,-7)) platte53=standartfield(position=(90,-1,-12)) # hindernis1=felsen() hindernis1.pos=(95,2,-37) # platte54=standartfield(position=(100,36, -67)) platte55=standartfield(position=(100,37, -72)) platte56=standartfield(position=(100,38, -77)) platte57=standartfield(position=(100,39, -82)) platte58=standartfield(position=(100,40, -87)) platte59=standartfield(position=(100,41, -92)) platte60=standartfield(position=(100,42, -97))#high-edge platte61=standartfield(position=(95,41, -97)) platte62=standartfield(position=(90,40, -97)) platte63=standartfield(position=(85,39, -97)) platte64=standartfield(position=(80,38, -97)) platte65=standartfield(position=(75,37, -97)) platte66=standartfield(position=(70,36, -97)) platte67=standartfield(position=(65,35, -97)) platte68=standartfield(position=(60,34, -97)) platte69=standartfield(position=(55,33, -97)) platte70=standartfield(position=(50,32, -97)) platte71=standartfield(position=(45,31, -97)) platte72=standartfield(position=(40,30, -97)) platte73=standartfield(position=(35,29, -97),col=color.green) platte74=standartfield(position=(30,28, -97),col=color.green) #low platte75=standartfield(position=(25,29, -97),col=color.green) platte76=standartfield(position=(20,30, -97)) platte77=standartfield(position=(15,31, -97)) platte78=standartfield(position=(10,32, -97)) platte79=standartfield(position=(5,33, -97)) platte80=standartfield(position=(0,34, -97)) platte81=standartfield(position=(-5,35, -97)) platte82=standartfield(position=(-10,36, -97)) platte83=standartfield(position=(-15,37, -97)) platte84=standartfield(position=(-20,38, -97)) platte85=standartfield(position=(-25,39, -97)) platte86=standartfield(position=(-30,40, -97)) platte87=standartfield(position=(-35,41, -97)) platte88=standartfield(position=(-40,42, -97)) # hindernis2=groupedfield() hindernis2.pos=(-79,41,-111) hindernis1.ereignis=False # platte89=standartfield(position=(-71,42, -66)) #Richtung TP 9Uhr platte90=standartfield(position=(-71,41, -61)) platte91=standartfield(position=(-71,40, -56)) platte92=standartfield(position=(-71,39, -51)) platte93=standartfield(position=(-71,38, -46)) platte94=standartfield(position=(-71,37, -41)) platte95=standartfield(position=(-71,36, -36)) platte96=standartfield(position=(-71,35, -31)) platte97=standartfield(position=(-71,34, -26)) platte98=standartfield(position=(-71,33, -21)) platte99=standartfield(position=(-71,32, -16)) platte100=standartfield(position=(-71,31, -11)) # platte101=standartfield(position=(-71,42, -127)) #Richtung TP 3Uhr platte102=standartfield(position=(-71,41, -132)) platte103=standartfield(position=(-71,40, -137)) platte104=standartfield(position=(-71,39, -142)) platte105=standartfield(position=(-71,38, -147)) platte106=standartfield(position=(-71,37, -152)) platte107=standartfield(position=(-71,36, -157)) platte108=standartfield(position=(-71,35, -162)) platte109=standartfield(position=(-71,34, -167)) platte110=standartfield(position=(-71,33, -172)) platte111=standartfield(position=(-71,32, -177)) platte112=standartfield(position=(-71,31, -182)) # platte113=standartfield(position=(-101,42, -96))#Richtung TP 12Uhr platte113A=standartfield(position=(-106,41, -96)) platte113B=standartfield(position=(-111,40, -96)) platte113C=standartfield(position=(-116,39, -96)) platte113D=standartfield(position=(-121,38, -96)) platte113E=standartfield(position=(-126,37, -96)) platte113F=standartfield(position=(-131,36, -96)) platte113G=standartfield(position=(-136,35, -96)) platte113H=standartfield(position=(-141,34, -96)) platte113I=standartfield(position=(-146,33, -96)) platte113J=standartfield(position=(-151,32, -96)) platte113K=standartfield(position=(-156,31, -96)) # teleport1=ellipsoid(pos=(-161,28,-96),length=10, width=10, height=0.5, color=color.yellow) teleport2=ellipsoid(pos=(-71,28,-187),length=10, width=10, height=0.5, color=color.yellow) teleport3=ellipsoid(pos=(-71,28,-6),length=10, width=10, height=0.5, color=color.yellow) platteTP1=standartfield(position=(-161,30, -96), col=color.blue) #TP 12Uhr -> TP2 platteTP2=standartfield(position=(-71,30, -187), col=color.red) #TP 3Uhr -> TP3 platteTP3=standartfield(position=(-71,30, -6), col=color.blue) #TP 9Uhr ->TP1 # teleport1E=ellipsoid(pos=(-20,-30,100),length=10, width=10, height=0.5, color=color.blue) teleport2E=ellipsoid(pos=(0,-19, 65),length=10, width=10, height=0.5, color=color.blue) teleport3E=ellipsoid(pos=(20,-26, 80),length=10, width=10, height=0.5, color=color.blue) platteTP1E=standartfield(position=(-20,-29, 100), col=color.cyan) platteTP2E=standartfield(position=(0,-18, 65)) platteTP3E=standartfield(position=(20,-25, 80)) # platte114=standartfield(position=(-20,-28, 95))#gehört zu TP1=9Uhr platte115=standartfield(position=(-20,-27, 90)) platte116=standartfield(position=(-20,-26, 85)) platte117=standartfield(position=(-20,-25, 80)) platte118=standartfield(position=(-20,-24, 75)) platte119=standartfield(position=(-20,-23, 70)) platte120=standartfield(position=(-20,-22, 65)) platte121=standartfield(position=(-20,-21, 60)) platte122=standartfield(position=(-20,-20, 55)) platte123=standartfield(position=(-15,-19, 55)) platte124=standartfield(position=(-10,-18, 55)) platte125=standartfield(position=(-5,-17, 55)) #platte126=standartfield(position=(0,-16, 55)) # platte127=standartfield(position=(0,-16, 55)) #gehört zu TP2=12Uhr platte128=standartfield(position=(0,-17, 60)) #platte129=standartfield(position=(0,-18, 65)) # platte130=standartfield(position=(5,-17, 55)) #gehört zu TP3=3Uhr platte131=standartfield(position=(10,-18, 55)) platte132=standartfield(position=(15,-19, 55)) platte133=standartfield(position=(20,-20, 55))#edge platte134=standartfield(position=(20,-21, 60)) platte135=standartfield(position=(20,-22, 65)) platte136=standartfield(position=(20,-23, 70)) platte137=standartfield(position=(20,-24, 75)) # platte138=standartfield(position=(0,-17, 50)) platte139=standartfield(position=(0,-18, 45)) platte140=standartfield(position=(0,-19, 40)) platte141=standartfield(position=(0,-20, 35)) platte142=standartfield(position=(0,-21, 30)) platte143=standartfield(position=(0,-22, 25)) platte144=standartfield(position=(0,-23, 20)) platte145=standartfield(position=(0,-24, 15)) platte146=standartfield(position=(0,-25, 10), col=color.orange) platte147=standartfield(position=(0,-26, 5), col=color.orange) platte148=standartfield(position=(0,-27, 0)) platte149=standartfield(position=(0,-28, -5)) platte150=standartfield(position=(0,-29, -10)) platte151=standartfield(position=(0,-30, -15)) platte152=standartfield(position=(0,-31, -20)) platte153=standartfield(position=(0,-32, -25)) platte154=standartfield(position=(0,-33, -30)) # zielground=box(pos=(0,-35, -35), length=8, width=8, height=1, color=color.red, material=materials.emissive) letztePlatte=standartfield(position=(0,-34,-35), col=(0.5, 0.5, 0.5)) felderliste=[] felderliste.append(erstePlatte) felderliste.append(platte1) felderliste.append(platte2) felderliste.append(platte3) felderliste.append(platte4) felderliste.append(platte5) felderliste.append(platte6) felderliste.append(platte7) felderliste.append(platte8) felderliste.append(platte9) felderliste.append(platte10) felderliste.append(platte11) felderliste.append(platte12) felderliste.append(platte13) felderliste.append(platte14) felderliste.append(platte15) #16-24: Ladder felderliste.append(platte16) felderliste.append(platte17) felderliste.append(platte18) felderliste.append(platte19) felderliste.append(platte20) felderliste.append(platte21) felderliste.append(platte22) felderliste.append(platte23) felderliste.append(platte24)#Ende Ladder felderliste.append(platte25) felderliste.append(platte26) felderliste.append(platte27) felderliste.append(platte28) felderliste.append(platte29) felderliste.append(platte30) felderliste.append(platte31) felderliste.append(platte32) felderliste.append(platte33) felderliste.append(platte34) felderliste.append(platte35) felderliste.append(platte36) felderliste.append(platte37) felderliste.append(platte38) felderliste.append(platte39) felderliste.append(platte40) felderliste.append(platte41) felderliste.append(platte42) felderliste.append(platte43) felderliste.append(platte44) felderliste.append(platte45) felderliste.append(platte46) felderliste.append(platte47) felderliste.append(platte48) felderliste.append(platte49) felderliste.append(platte50) felderliste.append(platte51) felderliste.append(platte52) felderliste.append(platte53) felderliste.append(hindernis1.feld0) felderliste.append(hindernis1.feld1) felderliste.append(hindernis1.feld2) felderliste.append(hindernis1.feld3) felderliste.append(hindernis1.feld4) felderliste.append(hindernis1.feld5) felderliste.append(hindernis1.feld6) felderliste.append(hindernis1.feld7) felderliste.append(hindernis1.feld8) felderliste.append(hindernis1.feld9) felderliste.append(hindernis1.feld10) felderliste.append(hindernis1.feld10a) felderliste.append(hindernis1.feld11) felderliste.append(hindernis1.feld12) felderliste.append(hindernis1.feld13) felderliste.append(hindernis1.feld14) felderliste.append(hindernis1.feld15) felderliste.append(hindernis1.feld16) felderliste.append(hindernis1.feld17) felderliste.append(hindernis1.feld18) felderliste.append(hindernis1.feld19) felderliste.append(hindernis1.feld20) felderliste.append(hindernis1.feld21) felderliste.append(hindernis1.feld22) felderliste.append(hindernis1.feld23) felderliste.append(hindernis1.feld24) felderliste.append(platte54) felderliste.append(platte55) felderliste.append(platte56) felderliste.append(platte57) felderliste.append(platte58) felderliste.append(platte59) felderliste.append(platte60) felderliste.append(platte61) felderliste.append(platte62) felderliste.append(platte63) felderliste.append(platte64) felderliste.append(platte65) felderliste.append(platte66) felderliste.append(platte67) felderliste.append(platte68) felderliste.append(platte69) felderliste.append(platte70) felderliste.append(platte71) felderliste.append(platte72) felderliste.append(platte73) felderliste.append(platte74) felderliste.append(platte75) felderliste.append(platte76) felderliste.append(platte77) felderliste.append(platte78) felderliste.append(platte79) felderliste.append(platte80) felderliste.append(platte81) felderliste.append(platte82) felderliste.append(platte83) felderliste.append(platte84) felderliste.append(platte85) felderliste.append(platte86) felderliste.append(platte87) felderliste.append(platte88) felderliste.append(hindernis2.feld1) felderliste.append(hindernis2.feld2) felderliste.append(hindernis2.feld3) felderliste.append(hindernis2.feld4) felderliste.append(hindernis2.feld5) felderliste.append(hindernis2.feld6) felderliste.append(hindernis2.feld7) felderliste.append(hindernis2.feld8) felderliste.append(hindernis2.feld9) felderliste.append(hindernis2.feld10) felderliste.append(hindernis2.feld11) felderliste.append(hindernis2.feld12) felderliste.append(hindernis2.feld13) felderliste.append(hindernis2.feld14) felderliste.append(hindernis2.feld15) felderliste.append(hindernis2.feld16) felderliste.append(hindernis2.feld17) felderliste.append(hindernis2.feld18) felderliste.append(hindernis2.feld19) felderliste.append(hindernis2.feld20) felderliste.append(hindernis2.feld21) felderliste.append(hindernis2.feld22) felderliste.append(hindernis2.feld23) felderliste.append(hindernis2.feld24) felderliste.append(hindernis2.feldA) felderliste.append(hindernis2.feldAA) #felderliste.append(hindernis2.feldAv) #felderliste.append(hindernis2.feld1AAv) felderliste.append(hindernis2.feldB) felderliste.append(hindernis2.feldBB) felderliste.append(hindernis2.feldBv) felderliste.append(hindernis2.feldBBv) felderliste.append(hindernis2.feldC) felderliste.append(hindernis2.feldCC) #felderliste.append(hindernis2.feldCv) #felderliste.append(hindernis2.feldCCv) felderliste.append(hindernis2.feldD) felderliste.append(hindernis2.feldDD) felderliste.append(hindernis2.feldDv) felderliste.append(hindernis2.feldDDv) felderliste.append(hindernis2.feldE) # felderliste.append(platte89) #98-100: TP 9Uhr felderliste.append(platte90) felderliste.append(platte91) felderliste.append(platte92) felderliste.append(platte93) felderliste.append(platte94) felderliste.append(platte95) felderliste.append(platte96) felderliste.append(platte97) felderliste.append(platte98) felderliste.append(platte99) felderliste.append(platte100) felderliste.append(platte101) #101-112: TP 3Uhr felderliste.append(platte102) felderliste.append(platte103) felderliste.append(platte104) felderliste.append(platte105) felderliste.append(platte106) felderliste.append(platte107) felderliste.append(platte108) felderliste.append(platte109) felderliste.append(platte110) felderliste.append(platte111) felderliste.append(platte112) felderliste.append(platte113) #113-113K: TP 12Uhr felderliste.append(platte113A) felderliste.append(platte113B) felderliste.append(platte113C) felderliste.append(platte113D) felderliste.append(platte113E) felderliste.append(platte113F) felderliste.append(platte113G) felderliste.append(platte113H) felderliste.append(platte113I) felderliste.append(platte113J) felderliste.append(platte113K) felderliste.append(platteTP3)#114-125: TP3 (links) felderliste.append(platteTP3E) felderliste.append(platte114) felderliste.append(platte115) felderliste.append(platte116) felderliste.append(platte117) felderliste.append(platte118) felderliste.append(platte119) felderliste.append(platte120) felderliste.append(platte121) felderliste.append(platte122) felderliste.append(platte123) felderliste.append(platte124) felderliste.append(platte125) felderliste.append(platteTP1)#127-128: TP1 (mitte) felderliste.append(platteTP1E) felderliste.append(platte127)##Kreuzung!! felderliste.append(platte128) felderliste.append(platteTP2)#130-137: TP2 (rechts) felderliste.append(platteTP3E) felderliste.append(platte130) felderliste.append(platte131) felderliste.append(platte132) felderliste.append(platte133) felderliste.append(platte134) felderliste.append(platte135) felderliste.append(platte136) felderliste.append(platte137) #Zielgerade 138-154 felderliste.append(platte138) felderliste.append(platte139) felderliste.append(platte140) felderliste.append(platte141) felderliste.append(platte142) felderliste.append(platte143) felderliste.append(platte144) felderliste.append(platte145) felderliste.append(platte146) felderliste.append(platte147) felderliste.append(platte148) felderliste.append(platte149) felderliste.append(platte150) felderliste.append(platte151) felderliste.append(platte152) felderliste.append(platte153) felderliste.append(platte154) felderliste.append(letztePlatte) ##if figur1.pos==platte73.position or figur1.pos==platte74.position or figur1.pos==platte75.position or figur2.pos==platte73.position or figur2.pos==platte74.pos or figur2.pos==platte75.position or figur3.pos==platte73.position or figur3.pos==platte74.position or figur3.pos==platte75.position: ## hindernis2.ereignis=True # Der Würfel: zufallszahl=(1,2,3,4,5,6) class wuerfel(frame): def __init__(self): frame.__init__(self) bowurfel=box(frame=self, pos=(20,20,0), height=4,width=4,length=4, color=color.green) lab=label(pos=(20,20,0), color=color.green, text="Wurfel", opacity=0.5) def wuerfeln(): aus=label(pos=(-20,30,0), color=color.green, text="Du darfst " + str(choice(zufallszahl))+ " Schritte gehen.") time.sleep(5) aus.visible=False # Das Spiel: class spiel(Thread): def __init__(self, pos=(-20,20,0), color=color.green): Thread.__init__(self) self.bowurfel=wuerfel() ausgabe=label(text="Willkommen zu Snakes'n'ladders XTREME!",height=15) time.sleep(3) ausgabe.visible=False del ausgabe ausgabe=label(text="Wie viele Spieler wollen spielen?", height=15) time.sleep(3) ausgabe.visible=False del ausgabe def wuerfeln(self): aus=label(pos=(-10,10,0), color=color.green, text="Du darfst " + str(choice(zufallszahl))+ " Schritte gehen.") time.sleep(2) aus.visible=False def figursetzen(self, figurnr, feldnr): for f in self.felderliste: if f.feldnr==feldnr: break if figurnr==1: player=self.figur1 elif figurnr==2: player=self.figur2 elif figurnr==3: player=self.figur3 player.pos=f.pos def run(self): while True: rate(50) if scene.mouse.events: m1=scene.mouse.getevent() if m1.pick in self.bowurfel.objects: self.wuerfeln() if scene.kb.keys: zeichen=scene.kb.getkey() if zeichen=="2": ausgabe=label(text="Es spielen 2 Spieler!", height=15) spielerzahl=2 elif zeichen=="3": ausgabe=label(text="Es spielen 3 Spieler!", height=15) spielerzahl=3 else: ausgabe=label(text="Diese Spielerzahl is ungültig!", height=15) time.sleep(3) ausgabe.visible=False del ausgabe self.figur1=Spielfigur_Mario() self.figur1.visible=False self.figur2=Spielfigur_Kjell() self.figur2.visible=False self.figur3=Spielfigur_Lena() self.figur3.visible=False if spielerzahl==2: self.figur1.pos=(-2.5,2,-2.5) self.figur1.visible=True self.figur2.pos=(-2,2.1,2) self.figur2.visible=True elif spielerzahl==3: self.figur1.pos=(-2.5,2,-2.5) self.figur1.visible=True self.figur2.pos=(-2,2.1,2) self.figur2.visible=True self.figur3.pos=(2,1.8,-2) self.figur3.visible=True time.sleep(2) feldone=-1 feldtwo=-1 feldthree=-1 gamerun=True while gamerun==True: ausgabe=label(text="Player1 ist dran!", height=15) time.sleep(2) ausgabe.visible=False del ausgabe if scene.kb.keys: zeichen=scene.kb.getkey() if zeichen=="up": feldone=feldone+1 self.figur1.pos=felderliste[feldone].pos+(-0.5,1,-0.5) if self.figur1.pos==letztePlatte.pos: gamerun=False ausgabe=label(text="Player1 hat das Spiel gewonnen!", height=15) break time.sleep(2) ausgabe=label(text="Player2 ist dran!", height=15) time.sleep(2) ausgabe.visible=False del ausgabe if scene.kb.keys: zeichen=scene.kb.getkey() if zeichen=="up": feldtwo=feldtwo+1 self.figur2.pos=felderliste[feldtwo].pos+(0,1.1,0) if self.figur2.pos==letztePlatte.pos: gamerun=False ausgabe=label(text="Player2 hat das Spiel gewonnen!", height=15) break time.sleep(2) if spielerzahl==3: ausgabe=label(text="Player3 ist dran!", height=15) time.sleep(2) ausgabe.visible=False del ausgabe if scene.kb.keys: zeichen=scene.kb.getkey() if zeichen=="up": feldthree=feldthree+1 self.figur3.pos=felderliste[feldthree+1].pos+(0,0.8,0) time.sleep(2) if self.figur2.pos==letztePlatte.pos: gamerun=False ausgabe=label(text="Player3 hat das Spiel gewonnen!", height=15) break class Steuerung(Thread): def __init__(self, spiel, port=50000): Thread.__init__(self) self.view=spiel # UDP-Client, der den Server als Subprozess startet import subprocess # Modul zum Starten von Subprozessen import socket # Modul fuer Netzwerkkommunikation self.PORT = port #Anlegen eines Socket self.s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) # AF_INET = IPv4, SOCK_DGRAM = UDP self.s.setsockopt(socket.SOL_SOCKET,socket.SO_BROADCAST,1) # Broadcast ermoeglichen #Testen, ob es schon einen Server auf diesem Port gibt, notfalls selber starten try: self.s.sendto("print 'wer hoert mich?'", ('255.255.255.255', self.PORT)) # sende Nachricht 'an alle' self.s.settimeout(2) # warte 1/2 Sekunde.. print (self.s.recvfrom(64)[0]) # gibt Servermeldung aus #ein Problem, wenn timeout einmal gesetzt ist... self.s.settimeout(3000) except: # reagiert auf Zeitueberschreitung print ("Kein Server vorhanden - starte Server") # Rueckmeldung subprocess.Popen(['python','server_class.py',str(self.PORT)]) # Server starten self.s.setblocking(1) # nicht-blockierend self.s.sendto("print 'hallo'", ('255.255.255.255', self.PORT)) self.start() #Endlosmethode zum Abhoeren des Ports auf Nachrichten def run(self): while True: nachricht = self.s.recvfrom(128)[0] self.auswerten(nachricht) #Methode zum Auswerten der eingegangenen Nachricht def auswerten(self,nachricht): exec (nachricht) #Methode zum Weiterleiten, wird von Spiel genutzt def weiterleiten(self, nachricht): # HIER CODE EINFUEGEN, DER AUSGEFUEHRT WERDEN SOLL teile=nachricht.split(",") nachricht = "self.view.figursetzen("+teile[0]+","+teile[1]+")" self.s.sendto(nachricht, ('255.255.255.255', self.PORT)) # versenden der Nachricht an Tupel(IP, PORT) if __name__ == "__main__": spiel = spiel() #das eigentliche Spiel steuerung = Steuerung(spiel, PORT) #Die Steuerung, mit dem Spiel und einem Port als Argument spiel.controller = steuerung #Setzen des Referenzattributs spiel.start() #Das Spiel muss von Thread erben, hier wird dessen run-Methode gestartet