Gesamt
Ma alles so Halb
Neu.py — text/python-source, 4 KB (4943 bytes)
Dateiinhalt
from visual import * from threading import Thread scene.userzoom = True # User darf zoomen? scene.userspin = True # User darf rotieren? scene.forward = (0,-5,10) # Kameraposition scene.autoscale = False # Autoskalierung aktiv? scene.range = 70 # Kameraabstand von scene.center scene.center = (0,0,0) # Kamerablickpunkt: norm. (0,0,0) scene.up = (0,1,0) # Rotationsachse Kamera: norm. (0,1,0) scene.background = color.blue # Hintergrundfarbe scene.fov = 1 # Kamerawinkeloeffnung: norm. 1 scene.fullscreen = False # Vollbild? norm. False scene.title = "TEST" # Fenstertitel scene.width = 800 # Fensterbreite: norm. 200 scene.height = 800 # Fensterhoehe: norm 200 scene.x = 50 # x-Koordinate d. Fensters: norm. 0 scene.y = 25 # y-Koordinate d. Fensters: norm. 0 # Koordinatenachsen in Form von Pfeilen xAchse = arrow(axis=(10,0,0), shaftwidth=0.02, color=color.red) yAchse = arrow(axis=(0,10,0), shaftwidth=0.02, color=(0,0,1)) zAchse = arrow(axis=(0,0,10), shaftwidth=0.02, color=color.green) # Beschriftungen #xLabel = label(pos=(100,0,0), text="x") #yLabel = label(pos=(0,100,0), text="y") #zLabel = label(pos=(0,0,100), text="z") #bergf=frame() #berg = box(length=400,width=200,height=200,axis=(1,0.7,5),pos=(0,-15,0),frame=bergf) #class Spielfeld(Thread,frame): # def __init_(self): # Thread.__init__(self) # frame.__init__(self) # self.feld = box(width=60, length =60,pos=(0,-5,0),axis=(0,0,5)) # self.hindernis = box(pos=(10,0,10),height=10,length=10,width=10,color=color.green) class kiste(Thread,frame): def __init__(self,pos=(0,0,0)): Thread.__init__(self) frame.__init__(self,pos=pos) self.kisten = box(pos=(0,0,50),height=10,length=10,width=10,material=materials.earth,frame=self) self.rahmen = sphere(pos=(0.0,0,50),radius=6,opacity=0.2,frame=self) def Entgegenkommen(self): if self.z<=-100: self.z=100 else: rate(50) self.z-=1 def vektoranpassen(self): self.vrahmen= vector(0,0,self.rahmen.z) class baum(Thread, frame): def __init__(self,pos=(0,0,0)): Thread.__init__(self) frame.__init__(self,pos=pos) self.stamm = cylinder(axis=(0,35,0),pos=(self.x,self.y-5,self.z),radius=(4),length=(50),frame=self,material=materials.wood) self.busch = sphere(radius=(15),pos=(self.x,self.y+52,self.z),color=color.green,frame=self) self.vstamm = vector(0,0,self.z) def vektoranpassen(self): self.vstamm = vector(0,0,self.z) def baumBewegtSich(self): if self.z<=-45: self.z=100 else: rate(50) self.z-=1 class skifahrer(Thread, frame): def __init__(self, pos=(0,10,-35)): Thread.__init__(self) frame.__init__(self) self.arm1 = cylinder(radius=(1),length=(4),axis=(-1,0,5),pos=(-5,10,-35),color=color.red,frame=self) self.arm2 = cylinder(radius=(1),length=(4),axis=(1,0,5),pos=(5,10,-35),color=color.red,frame=self) self.ski1 = box(pos=(3,-5,-25),height=(0.5),length=(15),axis=(0,0,5),width=(2),color=color.green,frame=self) self.ski2 = box(pos=(-3,-5,-25),height=(0.5),length=(15),axis=(0,0,5),width=(2),color=color.green,frame=self) self.vski1 = vector(3,0,-25) self.vski2 = vector(-3,0,-25) def vektoranpassen(self): self.vski1 = vector(self.vski1.x,0,-25) self.vski2 = vector(self.vski2.x,0,-25) def einsLinksFahren(self): self.x+=1 self.vski1.x+=1 self.vski2.x+=1 scene.center.x+=1 def einsRechtsFahren(self): self.x-=1 self.vski1.x-=1 self.vski2.x-=1 scene.center.x-=1 if __name__ == "__main__": feld = box(width=100, length =200,pos=(0,-6,50),axis=(0,0,5)) wand1 = box(length=100,height=10,pos=(0,-5,200)) s1 = skifahrer() h1=kiste(pos =(30,0,100)) h2=kiste() h2.start() s1.start() h1.start() b1 = baum() b1.start() while True: s1.vektoranpassen() b1.vektoranpassen() h1.vektoranpassen() h1.Entgegenkommen() h2.Entgegenkommen() b1.baumBewegtSich() if (-8<=s1.vski2.x<= 10) and (s1.vski2.z - b1.z+15 >= 0): print ("Collision -> TOD") #exit() #if mag(s1.vrahmen-h1.vrahmenk)<=10: # print ("Collision") #print h1.pos if scene.kb.keys: skk = scene.kb.getkey() if skk=="left": s1.einsLinksFahren() elif skk=="right": s1.einsRechtsFahren()