Links und Funktionen
Sprachumschaltung

Navigationspfad


Inhaltsbereich

West

Sigma.py — text/python-source, 37 KB (38358 bytes)

Dateiinhalt

# -*- coding: utf-8 -*-
from visual import *
from random import*
from threading import Thread

scene.x = 0	                                # Fensterpos v. links
scene.y = 0	                                # Fensterpos v. oben
scene.height= 1050                              # Fensterhöhe
scene.width = 1280                              # Fensterbreite
scene.range = (-12,1,1)                         # Abstand
scene.center = (175,10,10)                     # Festlegung Blickziel
scene.userspin = False                          # Blickwechsel abgeschaltet
scene.userzoom = False                          # Benutzerzoom abgeschaltet
scene.fov = 1.6                                 # Kamerawinkel
scene.background = (0.8,0.85,1)                 # Farbe Hintergrund
scene.stereodepth = 2                           # Stereotiefe    
scene.fullscreen = True                         # Vollbildmodus


kakteen_zahl = 20               # Konstante: Anzahl der Kakteen
raumschiff_zahl = 5	        # Konstante: Anzahl der Raumschiffe

raumschiffe = []

kakteen_zahl = 20               # Konstante: Anzahl der Kakteen
raumschiff_zahl = 3	        # Konstsnte: Anzahl der Raumschiffe
gegner_zahl = 10                # Konstante: Anzahl der Gegner

raumschiffe = []
shootTimer = 1.0

playercolor = 0.01

# Spieler
class ego(frame):
    def __init__(self):
        frame.__init__(self)
            
        #ArmRechts:
        self.OberarmRechts  = cylinder (frame = self, pos = (-11.7, 5.8, 0), radius = (0.7), color = color.white, axis = (0,-2.5,0))
        self.EllbogenRechts = sphere   (frame = self, pos = (-11.7, 3.3, 0), radius = (0.7))
        self.UnterArmRechts = cylinder (frame = self, pos = (-11.7, 3.3,0), radius = (0.7), axis = (1, 0, 3))
        self.HandRechts     = sphere   (frame = self, pos = (-10.7, 3.3, 3), radius = (0.72))

        #ArmLinks:
        self.OberarmLinks   = cylinder(frame = self, pos = (-8.4, 5.8, 0), radius = (0.7), color = color.white, axis = (-1.5,-2.5,4))
        self.HandLinks  = sphere  (frame = self, pos = (-9.9, 3.3, 4), radius = (0.72))
                
        #Waffe
        self.WAFFE = cylinder (frame = self, pos = (-11.4, 4, -1), axis = (1.3, 1.5,7), radius = 0.4, color = color.black, opacity = (1))
        self.WAFFENLAUF = cylinder (frame = self, pos = (-11.4, 3.5, -1),axis =(1.3, 1.5, 7), radius = 0.4, color = color.black, opacity = (01))
        self.Waffenlaser = ring (frame = self, pos = (-10.1,5.4,6), axis = (1.3, 1.5, 7), radius = 0.4)
        self.Waffenkugel = sphere (frame = self, pos = (-10.1, 5.4, 6), radius= 0.2, color= color.red)
        self.Waffengriffhinten = cylinder (frame = self, pos =(-10.6, 5.1, 3), radius = (0.3),axis = (0,-2.7,0), color = color.black)
        self.Waffengriffvorne = cylinder (frame = self, pos =(-10.5, 3.9, 4), length = (2), radius = (0.3),axis = (0.2, 0.3, 1), color = color.black)
        self.visier = ring (frame = self, pos = (-10.3,5.9,5), axis = (1.3, 1.5, 7), radius = 0.3, color = color.black)

        #Koerper
        self.kopf = sphere(frame = self, pos = (-10, 10,0), radius = (2.5),opacity = (1))
        self.haare = sphere(frame = self, pos = (-10, 10.1,-0.1), radius = (2.5), color= color.black, opacity = (1))
        self.rechtesA = sphere (frame = self, pos = (-11,11,2.2), radius = (0.3), color = color.black)
        self.linkesA  = sphere (frame = self, pos = (-9,11,2.2), radius = (0.3), color = color.black)
        self.Mund = ring (frame = self, pos =(-10,9.3,2.1), radius = (0.8), color = color.red, axis= (0,0,1))

        self.Tshirt = cylinder(frame = self, pos = (-10, 2.5,0), radius = 1.2, color = (0.3,0.6,1), axis = (0,5,0))
        self.Guertel = ring(frame = self, pos = (-10, 2.5, 0), radius = 1, axis = (0,1,0), color = color.black, thickness = 0.3)
        self.SchulterRechts = sphere(frame = self, pos =(-11.3, 6.1, 0), radius = 1.2, color = (0.3,0.6,1) )
        self.SchulterLinks = sphere(frame = self, pos =(-8.7, 6, 0), radius = 1.2, color = (0.3,0.6,1), axis = (0,1.5,0))

        self.hueftelinks = sphere(frame = self, pos =(-11.3, 0.5, 0), radius = 1.2, color = color.blue)
        self.huefterechts = sphere(frame = self, pos =(-8.7, 0.5, 0), radius = 1.2, color = color.blue, axis = (0,1.5,0))
        self.Hosenbund = cylinder(frame = self, pos = (-10,1,0), radius = 1.2, color = color.blue, axis = (0,1.5,0))
        self.HoseRechts = cylinder(frame = self, pos =(-11.3,0.5,0), axis = (0,-1.5,0), radius = 1.2, color = color.blue)
        self.HoseLinks = cylinder(frame = self, pos =(-8.7,0.5,0), axis = (0,-1.5,0), radius = 1.2, color = color.blue)
        self.BreinRechts = cylinder(frame = self, pos =(-11.3,-0.7,0), axis = (0,-4,0), radius = 1.1, color = color.white)
        self.BreinLinks = cylinder(frame = self, pos =(-8.7,-0.7,0), axis = (0,-4,0), radius = 1.1, color = color.white)  

        self.Rucksack = box(frame = self, pos = (-10, 5.7, -1.2), color = color.black, length = 1.6, height = 2.2)
        self.ArmLinks = cylinder(frame = self, pos =(8.7,0.5,0), axis = (0,0,0), radius = 1.2, color = color.red)

        self.p1 = box (frame = self,pos = (0, 5.5,-5), color = color.red, opacity = 0.0, height = 2, width = .01, length = 20)
        self.p2 = box (frame = self,pos = (0, 14.5,-5), color = color.red, opacity = 0.0, height = 2, width = .01, length = 20)
        self.p3 = box (frame = self,pos = (6, 7.5,-5), color = color.red, opacity = 0.0, height = 20, width = .01, length = 2)
        self.p4 = box (frame = self,pos = (-6, 7.5,-5), color = color.red, opacity = 0.0, height = 20, width = .01, length = 2)

        
        #Listeneintrag
        """Kugelx =self.Waffenkugel.pos.x
        Kugely =self.Waffenkugel.pos.y 
        Kugelz =self.Waffenkugel.pos.z

        liste.append( self.Waffenkugel.pos.x)
        liste.append( self.Waffenkugel.pos.y)
        liste.append( self.Waffenkugel.pos.z)"""

        #self.kugel = sphere (pos =(self.pos.x-10,  self.pos.y+5.3,  self.pos.z+6.3), color = color.yellow, opacity = 0.7, frame=self)
        #self.kugel.visible = False
        self.b = box (pos =(self.pos.x-10,  self.pos.y+5.3,  self.pos.z+6.3), color = color.yellow, opacity = 0.7, frame=self, axis = (1,1,1), length = 1, width = 1, height = 1)
        self.b2 = box (pos =(self.pos.x-10,  self.pos.y+5.3,  self.pos.z+6.3), color = color.yellow, opacity = 0.7, frame=self,axis = (1,2,1),  length = 1, width = 1, height = 1)
        self.b3 = box (pos =(self.pos.x-10,  self.pos.y+5.3,  self.pos.z+6.3), color = color.yellow, opacity = 0.7, frame=self, axis = (2,1,0.1), length = 1, width = 1, height = 1) 
        self.b4 = box (pos =(self.pos.x-10,  self.pos.y+5.3,  self.pos.z+6.3), color = color.yellow, opacity = 0.7, frame=self, axis = (0.1,0.7,0.1), length = 1, width = 1, height = 1)
        self.b5 = box (pos =(self.pos.x-10,  self.pos.y+5.3,  self.pos.z+6.3), color = color.yellow, opacity = 0.7, frame=self, axis = (1.8,0.5,0.1), length = 1, width = 1, height = 1)
        self.b.visible = False
        self.b2.visible = False
        self.b3.visible = False
        self.b4.visible = False
        self.b5.visible = False

        self.life = 100

#Spieler erzeugen       
player = ego()

class raumschiff(Thread, frame):        # Raumschiffe
    def __init__(self,x,y,z):
        Thread.__init__(self)
        frame.__init__(self)
        self.raum = ellipsoid(pos=(x,y,z), color=color.black, length=70, height=20, width=70, material=materials.plastic, frame=self) 
        self.raums = sphere(pos=(x,y+10,z), radius=20, opacity=.4, color=color.blue, material=materials.plastic, frame=self) 
        self.raump1 = sphere(pos=(x+25,y+5,z), radius=5, frame=self) 
        self.raump2 = sphere(pos=(x,y+5,z+25), radius=5, frame=self) 
        self.raump3 = sphere(pos=(x,y+5,z-25), radius=5, frame=self) 
        self.raump4 = sphere(pos=(x-25,y+5,z), radius=5, frame=self) 
        self.raump5 = sphere(pos=(x+18,y+5,z+18), radius=5, frame=self) 
        self.raump6 = sphere(pos=(x+18,y+5,z-18), radius=5, frame=self) 
        self.raump7 = sphere(pos=(x-18,y+5,z+18), radius=5, frame=self) 
        self.raump8 = sphere(pos=(x-18,y+5,z-18), radius=5, frame=self) 
        self.raumpk1 = sphere(pos=(x+25,y+9,z), radius=2, color=color.yellow, material=materials.plastic, frame=self) 
        self.raumpk2 = sphere(pos=(x,y+9,z+25), radius=2, color=color.yellow, material=materials.plastic, frame=self) 
        self.raumpk3 = sphere(pos=(x,y+9,z-25), radius=2, color=color.yellow, material=materials.plastic, frame=self) 
        self.raumpk4 = sphere(pos=(x-25,y+9,z), radius=2, color=color.yellow, material=materials.plastic, frame=self) 
        self.raumpk5 = sphere(pos=(x+18,y+9,z+18), radius=2, color=color.yellow, material=materials.plastic, frame=self) 
        self.raumpk6 = sphere(pos=(x+18,y+9,z-18), radius=2, color=color.yellow, material=materials.plastic, frame=self) 
        self.raumpk7 = sphere(pos=(x-18,y+9,z+18), radius=2, color=color.yellow, material=materials.plastic, frame=self) 
        self.raumpk8 = sphere(pos=(x-18,y+9,z-18), radius=2, color=color.yellow, material=materials.plastic, frame=self) 
        self.rauma = ellipsoid(pos=(x,y-10,z), color=color.red, length=30, width=30, height=5, frame=self) 
        self.raumss = sphere(pos=(x,y,z), radius=45, color=color.green, opacity=.1, material=materials.plastic, frame=self) 

        self.winkel = 2

    def run(self):
        "Thread starten"
        while True:
            rate(50)
            # Rotation um y-Achse durch Mittelpunkt
            self.rotate(angle=radians(self.winkel), axis=(0,1,0))


class kaktus(Thread, frame):            # Kakteen
    def __init__(self,x,z,axis=(0,1,0)):
        frame.__init__(self)
        Thread.__init__(self)
        self.ht = cylinder(length=20, color=color.green, radius=2, axis=(0,1,0), pos=(x,0,z), frame=self) 
        self.o1 = sphere(pos=(x,20,z), radius=2, color=color.green, frame=self)
        self.m1 = cylinder(length=6, color=color.green, radius=1.5, pos=(x,8,z), frame=self)
        self.m2 = cylinder(length=6, color=color.green, radius=1.5, pos=(x-6,10,z), frame=self)
        self.m3 = cylinder(length=5, color=color.green, radius=1.5, pos=(x,9,z-5), axis=(0,0,1), frame=self)
        self.m4 = cylinder(length=6, color=color.green, radius=1.5, pos=(x,7,z), axis=(0,0,1), frame=self)
        self.k1 = sphere(pos=((x+6),8,z), color=color.green, radius=1.5, frame=self)
        self.k2 = sphere(pos=((x-6),10,z), color=color.green, radius=1.5, frame=self)
        self.a1 = cylinder(pos=((x+6),8,z), color=color.green, radius=1.5, length=7, axis=(0,1,0), frame=self)
        self.k3 = sphere(pos=((x+6),15,z), color=color.green, radius=1.5, frame=self)
        #self.d1 = cylinder(pos=(x,0,z), radius=10, length=22, axis=(0,1,0), opacity=.1, frame=self)
        self.k4 = sphere(pos=(x,9,z-5), color=color.green, radius=1.5, frame=self)
        self.k5 = sphere(pos=(x,7,z+6), color=color.green, radius=1.5, frame=self)
        self.a2 = cylinder(length=5, color=color.green, radius=1.5, pos=(x,9,z-5), axis=(0,1,0), frame=self)
        self.k6 = sphere(pos=(x,14,z-5), color=color.green, radius=1.5, frame=self)
        self.o2 = sphere(pos=(x,21,z), color=color.red, radius=1.5, frame=self)
        self.pos=(x,0,z)

    def drehen(self):
        self.rotate(axis=(0,1,0), angle=random()*2*pi)

    def run(self):
        "Thread starten"
        while True:
            rate(50)
            v1 = mag(vector(self.pos.x, self.pos.z))
            v2 = mag(vector(player.kopf.pos.x, player.kopf.pos.z))
            if ((v1 - v2)**2)**0.5 < 10:
                #self.o2.visible = False
                #del self.o2
                player.kopf.color = color.red


# Wüstenlandschaft
boden = box(pos=(175,-1,175), width=350, height=1, length=350, color=color.white, material=materials.wood)
wand1 = box(pos=(350,24,175), width=350, height=50, length=1, color=(.9,.6,.2))
wand2 = box(pos=(0,24,175), width=350, height=50, length=1, color=(.9,.6,.2))
wand3 = box(pos=(175,24,350), width=1, height=50, length=350, color=(.9,.6,.2))
wand4 = box(pos=(175,24,0), width=1, height=50, length=350, color=(.9,.6,.2))
sonne = sphere(pos=(325,250,325), color=color.yellow, radius=50, opacity=.5, material=materials.plastic)

 #Raumschiffe werden erzeugt
for j in range(raumschiff_zahl):
    r1 = raumschiff(((random()*350)-175),((random()*50)+100),((random()*350)-175))
    r1.start()
    raumschiffe.append(r1)
    

# Kakteenliste
liste=[]

# Zufallskakteen
k = kaktus(87.5,87.5)
k.start()
liste.append(k)
while len(liste) < kakteen_zahl:
    k1 = kaktus((random()*150)+12.5,(random()*150)+12.5)
    k1.start()
    liste.append(k1)
    for i in liste[:-1]:
        if mag(i.pos - liste[-1].pos)<20:
            liste[-1].visible=False
            del liste[-1]
            break
        

class enemy(Thread, frame):
    def __init__(self, x, z, lives = 10, axis=(0,1,0), sx = 1, sz = 1):
        Thread.__init__(self)
        frame.__init__(self, pos = (x, 0, z))
        self.x = x
        self.z = z
        self.kopf = sphere(frame = self, pos  = (self.x,10, self.z), radius = (3), color = color.white)
        self.kbody = sphere(frame = self, pos = (self.x, 5, self.z), radius =(4))
        self.zbody = cylinder(frame = self, pos= (self.x, 0, self.z), axis= (0,5,0), radius = (4))
        self.Ring1 = ring(frame = self, pos = (self.x,5,self.z), radius= (4), axis = (0,1,0), color = color.black, thickness = (0.1))
        self.Ring2 = ring(frame = self, pos = (self.x,0,self.z), radius= (4), axis = (0,1,0), color = color.black, thickness = (0.1))
        self.Ring3 = ring(frame = self, pos = (self.x,1,self.z), radius= (4), axis = (0,1,0), color = color.black, thickness = (0.1))
        self.Ring4 = ring(frame = self, pos = (self.x,2,self.z), radius= (4), axis = (0,1,0), color = color.black, thickness = (0.1))
        self.Ring5 = ring(frame = self, pos = (self.x,3,self.z), radius= (4), axis = (0,1,0), color = color.black, thickness = (0.1))
        self.Ring6 = ring(frame = self, pos = (self.x,4,self.z), radius= (4), axis = (0,1,0), color = color.black, thickness = (0.1))
        self.Scheibe = cylinder (frame = self, pos = (self.x,-4,self.z), radius = (4), axis = (0,0.1,0), color = color.red) # Scheibe
        self.RechterArm  = cylinder (frame = self, pos = (self.x-3, 6, self.z), axis = (0,0,6.5))
        self.LinkerArm   = cylinder (frame = self, pos = (self.x+3, 6, self.z), axis = (0,0,6.5))
        self.rechteSchulter  = sphere (frame = self, pos = (self.x-1.7, 5.3, self.z), radius = (2.9))
        self.linkeSchulter = sphere (frame = self, pos = (self.x+1.7, 5.3, self.z),   radius = (2.9))
        self.rechteHand = sphere (frame = self, pos = (self.x+3,6,self.z+6.4),  radius = (1.3))
        self.rechteHand = sphere (frame = self, pos = (self.x-3,6,self.z+6.4), radius = (1.3))
        self.rechtesA = sphere (frame = self, pos = (self.x+1.3,11,self.z+2.6), radius = (0.3), color = color.red)
        self.linkesA  = sphere (frame = self, pos = (self.x-1.3,11,self.z+2.6), radius = (0.3), color = color.red)
        self.speer = arrow (frame = self, pos = (self.x+3, 2.4, self.z+6.4), color= color.black, axis =(0,11,0), shaftwidth = 0.6, material = materials.rough)
        self.Mund = ellipsoid(frame = self, pos=(self.x+0,9.4,self.z+3),length=3, height=1, width=1, color =(0.8,0.3,0.4))
        
        self.winkel = 1
        self.speedx = sx
        self.speedz = sz
        self.shots = []
        self.chasingPlayer = false
        self.lives = lives
        self.anzeige = label(pos=(x,12,z), \
                            box=False, line=False, yoffset=50, height=10, text="Feind")

    def run(self):
        "Thread starten"
        while len(self.shots)<self.lives+1:
            rate(50)
            # Rotation um y-Achse durch Mittelpunkt
            #self.rotate(angle=radians(self.winkel), axis=(0,1,0))
            self.x += self.speedx
            self.z += self.speedz
            if (((self.speedx)**2)**.5 < 0.1 and ((self.speedz)**2)**.5 < 0.1):
                self.speedx = random()*2-1
                self.speedz = random()*2-1
                
            self.colControl()
            #print "X: ", self.x, "Z: ", self.z
            """if (self.colControl()):
                szOld = self.speedz
                if (self.speedx != 0.0 and self.speedz != 0.0):
                    self.speedz = ((self.speedx**4+self.speedx**2*self.speedz**2)/(self.speedz**2+self.speedx**2))**.5
                    self.speedx = (self.speedx**2+szOld**2-(self.speedz**2))**.5
                else:
                    self.speedz -= 2*self.speedz
                    self.speedx -= 2*self.speedx
                    speed = vector (self.speedx, self.speedz)
                    speed2 = (random()*2+.1)*speed
                    self.speedz = speed2.z
                    self.speedx = speed2.x"""

            if self.chasingPlayer == true:
                abstandEnemyPlayer = vector(player.pos.x - self.x, 0, player.pos.z - self.z)
                self.x += abstandEnemyPlayer.x * 0.02
                self.z += abstandEnemyPlayer.z * 0.02
                self.anzeige.pos = (self.x, 12, self.z)

            v1 = mag(vector(self.pos.x, self.pos.z))
            v2 = mag(vector(scene.center.x, scene.center.z))
            if ((v1 - v2)**2)**0.5 < 4:
                #self.o2.visible = False
                #del self.o2
                if (player.life > 0):
                    player.life -= 1

                else:
                    player.life = 0

                print "Leben:",player.life


    def colControl(self):
        col = False
        if (self.x > 175.0):
            self.x -= random()*10.0
            self.speedx = -self.speedx
            col = True

        if (self.z > 175.0):
            self.z -= random()*10.0
            self.speedz = -self.speedz
            col = True

        if (self.x < 0.0):
            self.x += random()*10.0
            self.speedx = -self.speedx
            col = True

        if (self.z < 0.0):
            self.z += random()*10.0
            self.speedz = -self.speedz
            col = True
        """if self.x > wand1.pos.x:
            col = True

        if self.x < wand2.pos.x:
            col = True

        if self.z > wand4.pos.z:
            col = True

        if self.z < wand3.pos.z:
            col = True"""
            
        return col

    def shoot(self,sme):
        "Gegner via Mausevent (sme) beschossen"
        # wurde der Gegner am Kopf abgeschossen?
        if sme.pick == self.kopf and len(self.shots) < self.lives:
            # erzeuge Schüsse und fuegt in Liste ein
            self.shots.append(sphere(pos=self.world_to_frame(sme.pickpos), \
                                color=color.red, \
                                radius=0.5, material=materials.plastic, \
                                frame=self) )
            self.anzeige.visible = true
            self.anzeige.text="Leben: "+str((self.lives+1)-len(self.shots))
            # Erhoehung der Drehgeschwindigkeit
            self.winkel*=1.4
            self.chasingPlayer = true

        elif len(self.shots) >= self.lives:
            self.visible = false
            self.anzeige.visible = false
            if (player.life < 90):
                player.life += 10

            else:
                player.life = 100


# Donutliste
donuts = []

# Enemyliste
enemies = []

Kugelx = 0
Kugely = 0
Kugelz = 0
liste = []
#Schuss
"""Muendungsfeuer = sphere (pos = (liste[0], liste[1], liste[2]), radius = (1), opacity = (0.70), color = color.yellow)
Muendungsfeuer2 = sphere (pos = (liste[0]+0.1, liste[1], liste[2]), radius = (0.9), opacity = (0.70), color = color.yellow)
kugel = sphere (pos =(liste[0], liste[1], liste[2]), radius = 0.3, color = color.red)"""


class RandomDonut(Thread, frame):
    "Klasse modelliert Donut"
    def __init__(self, pos=(0,0,0), axis=(0,1,0), streuselMax = 10, size=0.5, glasurColor = (.3,.2,.1)):
        # Aufruf der Oberklassenkonstruktoren fuer Nebenlaeufigkeit und Objektcontainer
        Thread.__init__(self)
        frame.__init__(self, pos=pos)
        self.size = size
        self.teig = ring(thickness=self.size, color=(.9,.8,.2), axis=(0,1,0), frame=self, radius = self.size*2)
        self.glasur = ring(thickness=self.size+(self.size/50.0), color=glasurColor,\
                     material=materials.plastic, y=(self.size/5), axis=(0,1,0), frame=self, radius = self.size*2)
        self.streusel = []
        self.winkel = 0.5
        self.speed = 0.1
        self.movingUp = true
        self.chasingPlayer = false
        self.streuselMax = streuselMax
        self.anzeige = label(pos=self.pos, text="RandomDonut",
                            box=False, line=False, yoffset=50, height=10)
        self.anzeige.visible = true

    def run(self):
        "Thread starten"
        while len(self.streusel)<self.streuselMax+1:
            rate(50)
            # Rotation um y-Achse durch Mittelpunkt
            self.rotate(angle=radians(self.winkel), axis=(1,1,1))

            if self.chasingPlayer == true:
                abstandDonutPlayer = vector(player.pos.x - self.pos.x, 0, player.pos.z - self.pos.z)
                #print ("abstandDonutPlayer: ", abstandDonutPlayer.x, abstandDonutPlayer.y, abstandDonutPlayer.z)
                self.pos += (abstandDonutPlayer.x*0.005, 0, abstandDonutPlayer.z*0.005)

            v1 = mag(vector(self.pos.x, self.pos.z))
            v2 = mag(vector(scene.center.x, scene.center.z))
            if ((v1 - v2)**2)**0.5 < self.size:
                #self.o2.visible = False
                #del self.o2
                if (player.life > 0):
                    player.life -= 1

                else:
                    player.life = 0

                print "Leben:",player.life
                    
                
                    
    def garnieren(self,sme):
        "Donut via Mausevent (sme) mit Streuseln versehen"
        if sme.pick == self.glasur and len(self.streusel) < self.streuselMax:
            # erzeuge Streusel und f� Liste ein
            self.streusel.append(sphere(pos=self.world_to_frame(sme.pickpos), \
                                color=color.hsv_to_rgb((random(),1,1)), \
                                radius=(self.size/10), material=materials.plastic, \
                                frame=self) )
            self.anzeige.visible = true
            self.anzeige.text="Leben: "+str((self.streuselMax+1)-len(self.streusel))
            # Erhoehung der Drehgeschwindigkeit
            self.winkel*=1.1
            self.teig.thickness -= self.size/50
            self.glasur.thickness -= self.size/50+(self.size/50/50)
            self.teig.radius -= self.size/50
            self.glasur.radius -= self.size/25
            self.glasur.y -= (self.size/25)
            self.chasingPlayer = true
            # Streuselprotokoll
            print len(self.streusel)

        elif len(self.streusel) >= self.streuselMax:
            self.visible = false
            self.anzeige.visible = false
            if (player.life < 90):
                player.life += 10

            else:
                player.life = 100


class Donut(Thread, frame):
    def __init__(self, pos=(0,0,0), axis=(0,1,0), streuselMax=10, size=4,glasurColor = (.3,.2,.1),):
        # Aufruf der Oberklassenkonstruktoren fuer Nebenlaeufigkeit und Objektcontainer
        Thread.__init__(self)
        frame.__init__(self, pos=pos)
        self.size = size
        self.teig = ring(thickness=self.size, color=(.9,.8,.2), axis=(0,1,0), frame=self, radius = self.size*2)
        self.glasur = ring(thickness=self.size+(self.size/50.0), color=glasurColor,\
                     material=materials.plastic, y=(self.size/2), axis=(0,1,0), frame=self, radius = self.size*2)
        self.streusel = []
        self.winkel = 1
        self.speed = 0.1
        self.movingUp = true
        self.chasingPlayer = false
        self.streuselMax = streuselMax
        self.anzeige = label(pos=self.pos, text="Donut", \
                            box=False, line=False, yoffset=50, height=10)

    def run(self):
        "Thread starten"
        while len(self.streusel)<self.streuselMax:
            rate(200)
            # Rotation um y-Achse durch Mittelpunkt
            self.rotate(angle=radians(self.winkel), axis=(0,1,0))
            if self.chasingPlayer == true:
                abstandDonutPlayer = vector(player.pos.x - self.pos.x, 0, player.pos.z - self.pos.z)
                #print ("abstandDonutPlayer: ", abstandDonutPlayer.x, abstandDonutPlayer.y, abstandDonutPlayer.z)
                self.pos += (abstandDonutPlayer.x*0.005, 0, abstandDonutPlayer.z*0.005)

            """v1 = mag(vector(self.pos.x, self.pos.z))
            v2 = mag(vector(scene.center.x, scene.center.z))
            if ((v1 - v2)**2)**0.5 < 4:
                #self.o2.visible = False
                #del self.o2
                if (player.life > 0):
                    player.life -= 1
                    player.p.opacity += 0.01

                else:
                    player.life = 0

                print "Leben:",player.life"""
           
    def garnieren(self,sme):
        "Donut via Mausevent (sme) mit Streuseln versehen"
        if sme.pick == self.glasur and len(self.streusel) < self.streuselMax:
            # erzeuge Streusel und f� Liste ein
            self.streusel.append(sphere(pos=self.world_to_frame(sme.pickpos), \
                                color=color.hsv_to_rgb((random(),1,1)), \
                                radius=0.5, material=materials.plastic, \
                                frame=self) )  
            self.anzeige.text="Leben: "+str(11-len(self.streusel))
            # Erhoehung der Drehgeschwindigkeit
            self.winkel*=1.1
            self.chasingPlayer = true
            # Streuselprotokoll
            print len(self.streusel)
        elif len(self.streusel) >= self.streuselMax:
            self.visible=false
            self.anzeige.visible=false
            if (player.life < 90):
                player.life += 10

            else:
                player.life = 100
            

class SuperDonut(Thread, frame):
    "Klasse modelliert Donut"
    def __init__(self, pos=(0,0,0), axis=(0,1,0), streuselMax=25, size=6,glasurColor = (.3,.2,.1),):
        # Aufruf der Oberklassenkonstruktoren fuer Nebenlaeufigkeit und Objektcontainer
        Thread.__init__(self)
        frame.__init__(self, pos=pos)
        self.size = size
        self.teig = ring(thickness=self.size, color=(.9,.8,.2), axis=(0,1,0), frame=self, radius = self.size*2)
        self.glasur = ring(thickness=self.size+(self.size/50.0), color=glasurColor,\
                     material=materials.plastic, y=(self.size/5), axis=(0,1,0), frame=self, radius = self.size*2)
        self.streusel = []
        self.winkel = 0
        self.speed = 0.1
        self.movingUp = true
        self.chasingPlayer = false
        self.streuselMax = streuselMax
        self.anzeige = label(pos=self.pos, text="SuperDonut", \
                            box=False, line=False, yoffset=50, height=10)

    def run(self):
        "Thread starten"
        while len(self.streusel)<self.streuselMax:
            rate(200)
            # Rotation um y-Achse durch Mittelpunkt
            self.rotate(angle=radians(self.winkel), axis=(0,1,0))
            self.rotate(angle=radians(self.winkel), axis=(1,0,0))
            self.rotate(angle=radians(self.winkel), axis=(0,0,1))
            if self.chasingPlayer == true:
                abstandDonutPlayer = vector(player.pos.x - self.pos.x, 0, player.pos.z - self.pos.z)
                #print ("abstandDonutPlayer: ", abstandDonutPlayer.x, abstandDonutPlayer.y, abstandDonutPlayer.z)
                self.pos += (abstandDonutPlayer.x*0.005, 0, abstandDonutPlayer.z*0.005)
           
    def garnieren(self,sme):
        "Donut via Mausevent (sme) mit Streuseln versehen"
        if sme.pick == self.glasur and len(self.streusel) < self.streuselMax:
            # erzeuge Streusel und f� Liste ein
            self.streusel.append(sphere(pos=self.world_to_frame(sme.pickpos), \
                                color=color.hsv_to_rgb((random(),1,1)), \
                                radius=0.5, material=materials.plastic, \
                                frame=self) )  
            self.anzeige.text="Leben: "+str(26-len(self.streusel))
            # Erhoehung der Drehgeschwindigkeit
            self.winkel+=0.1
            self.chasingPlayer = true
            # Streuselprotokoll
            print len(self.streusel)
        elif len(self.streusel) >= self.streuselMax:
            self.visible=false
            self.anzeige.visible=false

class BreakdanceDonut(Thread, frame):
    "Klasse modelliert Donut"
    def __init__(self, pos=(0,0,0), axis=(0,1,0), streuselMax=12,size=4,glasurColor = (.3,.2,.1),):
        # Aufruf der Oberklassenkonstruktoren fuer Nebenlaeufigkeit und Objektcontainer
        Thread.__init__(self)
        frame.__init__(self, pos=pos)
        self.size = size
        self.teig = ring(thickness=self.size, color=(.9,.8,.2), axis=(0,1,0), frame=self, radius = self.size*2)
        self.glasur = ring(thickness=self.size+(self.size/50.0), color=glasurColor,\
                     material=materials.plastic, y=(self.size/2), axis=(0,1,0), frame=self, radius = self.size*2)
        self.streusel = []
        self.winkel = 0
        self.speed = 0.2
        self.movingUp = true
        self.chasingPlayer = false
        self.streuselMax = streuselMax
        self.anzeige = label(pos=self.pos, text="BreakdanceDonut", \
                            box=False, line=False, yoffset=50, height=10)


    def run(self):
        "Thread starten"
        while len(self.streusel)<self.streuselMax:
            rate(400)
            # Rotation um y-Achse durch Mittelpunkt
            self.rotate(angle=radians(self.winkel), axis=(0,1,0))
            self.rotate(angle=radians(self.winkel), axis=(1,0,0))
            self.rotate(angle=radians(self.winkel), axis=(0,0,1))
            if self.chasingPlayer == true:
                abstandDonutPlayer = vector(player.pos.x - self.pos.x, 0, player.pos.z - self.pos.z)
                #print ("abstandDonutPlayer: ", abstandDonutPlayer.x, abstandDonutPlayer.y, abstandDonutPlayer.z)
                self.pos += (abstandDonutPlayer.x*0.005, 0, abstandDonutPlayer.z*0.005)
           
    def garnieren(self,sme):
        "Donut via Mausevent (sme) mit Streuseln versehen"
        if sme.pick == self.glasur and len(self.streusel) < self.streuselMax:
            # erzeuge Streusel und f� Liste ein
            self.streusel.append(sphere(pos=self.world_to_frame(sme.pickpos), \
                                color=color.hsv_to_rgb((random(),1,1)), \
                                radius=0.5, material=materials.plastic, \
                                frame=self) )  
            self.anzeige.text="Leben: "+str(13-len(self.streusel))
            # Erhoehung der Drehgeschwindigkeit
            self.winkel+=0.2
            self.chasingPlayer = true
            # Streuselprotokoll
            print len(self.streusel)
        elif len(self.streusel) >= self.streuselMax:
            self.visible=false
            self.anzeige.visible=false

class MONSTERDonut(Thread, frame):
    "Klasse modelliert Donut"
    def __init__(self, pos=(0,0,0), axis=(0,1,0), streuselMax=100, size=10,glasurColor = (.3,.2,.1)):
        # Aufruf der Oberklassenkonstruktoren fuer Nebenlaeufigkeit und Objektcontainer
        Thread.__init__(self)
        frame.__init__(self, pos=pos)
        self.size = size
        self.teig = ring(thickness=self.size, color=(.9,.8,.2), axis=(0,1,0), frame=self, radius = self.size*2)
        self.glasur = ring(thickness=self.size+(self.size/50.0), color=glasurColor,\
                     material=materials.plastic, y=(self.size/5), axis=(0,1,0), frame=self, radius = self.size*2)
        self.streusel = []
        self.winkel = 0
        self.speed = 0.05
        self.movingUp = true
        self.chasingPlayer = false
        self.streuselMax = streuselMax
        self.anzeige = label(pos=self.pos, text="MONSTERDonut", \
                            box=False, line=False, yoffset=50, height=10)

    def run(self):
        "Thread starten"
        while len(self.streusel)<self.streuselMax:
            rate(200)
            # Rotation um y-Achse durch Mittelpunkt
            self.rotate(angle=radians(self.winkel), axis=(0,1,0))
            self.rotate(angle=radians(self.winkel), axis=(1,0,0))
            self.rotate(angle=radians(self.winkel), axis=(0,0,1))
            if self.chasingPlayer == true:
                abstandDonutPlayer = vector(player.pos.x - self.pos.x, 0, player.pos.z - self.pos.z)
                #print ("abstandDonutPlayer: ", abstandDonutPlayer.x, abstandDonutPlayer.y, abstandDonutPlayer.z)
                self.pos += (abstandDonutPlayer.x*0.005, 0, abstandDonutPlayer.z*0.005)
           
    def garnieren(self,sme):
        "Donut via Mausevent (sme) mit Streuseln versehen"
        if sme.pick == self.glasur and len(self.streusel) < self.streuselMax:
            # erzeuge Streusel und f� Liste ein
            self.streusel.append(sphere(pos=self.world_to_frame(sme.pickpos), \
                                color=color.hsv_to_rgb((random(),1,1)), \
                                radius=0.5, material=materials.plastic, \
                                frame=self) )  
            self.anzeige.text="Leben: "+str(101-len(self.streusel))
            # Erhoehung der Drehgeschwindigkeit
            self.winkel+=0.01
            self.chasingPlayer = true
            # Streuselprotokoll
            print len(self.streusel)
        elif len(self.streusel) >= self.streuselMax:
            self.visible=false
            self.anzeige.visible=false

                

if __name__ == "__main__":

     for i in range(20):
        x=random()
        """if(x<0.2):
            d1 = SuperDonut(pos=(random()*350,size,random()*350))
        elif(x<0.3):
            d1 = BreakdanceDonut(pos=(random()*350,size,random()*350))
        elif(x<0.35):
            d1 = MONSTERDonut(pos=(random()*350,size,random()*350))"""
        if(x<0.50):
            size = random()*3+3
            d1 = RandomDonut(pos=(random()*350,size,random()*350), size = size, glasurColor = (random(), random(), random()))
        else:
            d1 = Donut(pos=(random()*350,size,random()*350))
        d1.start()
        donuts.append(d1)

     """for i in range(5):  
        e1 = enemy(x = (random()*170), z = (random()*170), sx = random()*2-1, sz = random()*2-1)
        e1.start()
        enemies.append(e1)"""


while True:
    rate(100)
    if (shootTimer > 0.0):
        shootTimer -= 0.05
        player.b.opacity -= 0.2
        player.b2.opacity -= 0.2
        player.b3.opacity -= 0.24
        player.b4.opacity -= 0.18
        player.b5.opacity -= 0.3
        

    else:
        player.b.visible = False
        player.b2.visible = False
        player.b3.visible = False
        player.b4.visible = False
        player.b5.visible = False

    if (scene.center.x < 20):
        #player.kopf.color = color.red
        scene.center.x = 20

    if (scene.center.x > 330):
        #player.kopf.color = color.green
        scene.center.x = 330

    if (scene.center.z < 20):
        #player.kopf.color = color.blue
        scene.center.z = 20

    if (scene.center.z > 330):
        #player.kopf.color = color.yellow
        scene.center.z = 330

    #else:
       #player.kopf.color = color.white

    if (player.life > 0):
        player.p1.opacity = 0.01 * (100-player.life)
        player.p2.opacity = 0.01 * (100-player.life)
        player.p3.opacity = 0.01 * (100-player.life)
        player.p4.opacity = 0.01 * (100-player.life)

    else:
        tot = box (pos = scene.center-(0,0,5), color = color.red, opacity = 1.0, height = 20, width = .01, length = 20)
    

    """for i in liste:
        v1 = vector(i.pos.x, i.pos.z)
        v2 = vector(player.pos.x, player.pos.z)
        if mag(v1 - v2) < 10:
            i.o2.visible = False
            del i.o2
            player.kopf.color = color.red"""

        #else:
       #     player.kopf.color = color.white
        
    player.pos=scene.center-(0,10,0)
    if scene.kb.keys:
        s = scene.kb.getkey()
        #if player.color==color.red:
        if   s == 'up' or s=='w':     # vor
            scene.center += scene.forward*mag(scene.center-scene.mouse.camera)/-12

        elif s == 'down' or s=='s':   # hinter 
            scene.center -= scene.forward*mag(scene.center-scene.mouse.camera)/-12
    
        elif s == 'left' or s=='a':   # links 
            scene.center -= cross(scene.forward,scene.up)/-2   
        elif s == 'right' or s=='d':  # rechts 
            scene.center += cross(scene.forward,scene.up)/-2

        elif s == "l":
            if (player.life < 90):
                player.life += 10

            else:
                player.life = 100
            
        elif s == "r":
            ray = scene.mouse.ray
            newray = norm(vector(ray.x, 0, ray.z))
            angle = arcsin(dot(cross(scene.forward,newray),scene.up))
            player.rotate(scene.forward, axis=scene.up, angle=angle/-50)
            newforward = rotate(scene.forward, axis=scene.up, angle=angle/-50)
            scene.forward = newforward

    # LOOKS LIKE I´M DOING STUFF !                          
    player.pos=scene.center-(0,10,0)
    
    if scene.mouse.events:
        # Maus-Event in Variable speichern
            sme = scene.mouse.getevent()     
           # Verarbeitung des Maus-Events: Maus auf Objekt gedrueckt?
            if sme.pick and sme.press:
                for i in donuts:
                    i.garnieren(sme)
                for i in enemies:
                    i.shoot(sme)
                player.b.visible = True
                player.b2.visible = True
                player.b3.visible = True
                player.b4.visible = True
                player.b5.visible = True
                shootTimer = 1.0
                player.b.opacity = 0.7
                player.b2.opacity = 0.6
                player.b3.opacity = 0.8
                player.b4.opacity = 0.9
                player.b5.opacity = 1.0

Funktionsleiste