Links und Funktionen
Sprachumschaltung

Navigationspfad


Inhaltsbereich

Gesamt

Nur Halb

Neu.py — text/python-source, 6 KB (6201 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,opacity=0.1)
yAchse = arrow(axis=(0,10,0), shaftwidth=0.02, color=(0,0,1),opacity=0.1)
zAchse = arrow(axis=(0,0,10), shaftwidth=0.02, color=color.green,opacity=0.1)
# 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,0,0)):
        Thread.__init__(self)
        frame.__init__(self,pos=pos)
        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.bauch = box(pos=(0,5,-38),height=20,length=10,width=5,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

class haus (Thread,frame):
    def __init__(self,pos=(0,0,0)):
        Thread.__init__(self)
        frame.__init__(self,pos=pos)

        tri=Polygon([(-50,0),(0,50),(50,0)])
        straight = [(0,43,175),(0,43,115)] 
        haus = box(width=(50),length=(100),height=(50),z=150,y=19,opacity=0.1,material=materials.bricks,frame=self)
        dach = extrusion(shape=tri,pos=straight,material=materials.wood,frame=self)

class zaun (Thread,frame):
    def __init__(self,pos):
        Thread.__init__(self)
        frame.__init__(self,pos=pos)

        pfahl = box(height=10,width=5,length=5,pos=(5,5,5),frame=self)

        
    

if __name__ == "__main__":
    feld = box(width=100, length =200,pos=(0,-6,50),axis=(0,0,5),color=color.white)
    untergrund=box(width=300,length=300,pos=(0,-7,50),axis=(0,0,5),color=color.black)
    #himmel = sphere(pos=(0,-7,50),radius=150,material=materials.blazed)
    #wandvorne = box(length=100,height=80,pos=(0,33,150),material=materials.blazed)
    #wandoben = box(width=100, length =200,pos=(0,73,50),axis=(0,0,5),color=color.white)
    #wandlinks = box(lenght=200,height=80,width=200,pos=(50,33,50))
    #wandrechts = box(lenght=200,height=80,width=200,pos=(-50,33,50))
    
    haus= haus()
    haus.start()
    zaun=zaun()
    zaun.start()
    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()

Funktionsleiste