Links und Funktionen
Sprachumschaltung

Navigationspfad


Inhaltsbereich

projekt.py

Version 2.1

projekt1.py — text/python-source, 4 KB (4461 bytes)

Dateiinhalt

"""Labyrint-mit Hindernissen
Kugel als spielfigur
"""
from visual import *
from visual.text import *

"""scene.title = "Labyrinth" # Fenstertitel
scene.x = 0	                # Fensterpos v. links
scene.y = 0	                # Fensterpos v. oben
scene.height = 320              # Fensterhoehe
scene.width = 700               # Fensterbreite
scene.range = (1,1,1)           # Abstand
scene.center = (0,0,-10)         # Festlegung Blickziel
scene.userspin = False          # Blickwechsel abgeschaltet
scene.userzoom = False          # Benutzerzoom abgeschaltet
scene.fov = 15                  # Kamerawinkel
scene.background = (0.8,0.85,1) # Farbe Hintergrund
scene.stereodepth = 2           # Stereotiefe
scene.show_rendertime = True    # Anzeige der Berechnungszeiten
scene.fullscreen = False        # Vollbildmodus"""

oberflaeche = frame ()
a=100
b=0.5
c=10
floor = box (frame = oberflaeche, pos = (0,0,0),length=(a), high= (b), width= (a), color=color.red)



#Grundflaeche und dementsprechend angepasste Aussenwaende
#flaeche = box (frame = oberflaeche, pos = (0.5*a-0.5*b,2*b,0),length=(b), width=(a), high=(c))

wand2= box (frame = oberflaeche, pos = (-0.5*a+0.5*b,2*b,0),length=(b), width=(a), height=(c))
wand3= box (frame = oberflaeche, pos = (0,2*b,0.5*a-0.5*b),length=(a), width=(b), height=(c))
wand4= box (frame = oberflaeche, pos = (0,2*b,-0.5*a+0.5*b),length=(a), width=(b), height=(c))


"""  if scene.kb.keys:
        s = scene.kb.getkey()
        print s
        if   s == 'up':     # nach vorne kippen
            scene.center = scene.center+scene.forward*mag(scene.center-scene.mouse.camera)
        elif s == 'down':   # nach hinten kippen
            scene.center = scene.center-scene.forward*mag(scene.center-scene.mouse.camera)
        elif s == 'ctrl+up':   # links kippen
            newforward = rotate(scene.forward, axis=scene.up, angle=radians(2))
            scene.center = scene.mouse.camera+newforward*mag(scene.center-scene.mouse.camera)
            scene.forward = newforward
            #scene.center = scene.center+scene.forward*ray.y/2.
        elif s == 'alt+up':  # rechts kippen
            newforward = rotate(scene.forward, axis=scene.up, angle=radians(-2))
            scene.center = scene.mouse.camera+newforward*mag(scene.center-scene.mouse.camera)
            scene.forward = newforward"""
            

# Blick auf die Szene
scene.forward=(0,-1,-2)
scene.background=color.black


# Ball mit Geschwindigkeit und repr. Vektorpfeil
ball = sphere(pos=(-a/2+5,5, a/2-5), color=color.green, radius=1,  material=materials.rough, opacity=0.8)

# Zeit in krement
dt = 0.02

# Endlosschleife
#while True:
   # rate(100)
    #ball.pos = ball.pos + ball.velocity*dt

    # Falls Tastatur gedrueckt...
    #if scene.kb.keys:
        #s = scene.kb.getkey()
        #print s
        #if   s == 'left':   # links
        #  #  ball.velocity.x += -0.1
        #elif s == 'right':  # right
           # ball.velocity.x +=  0.1
        #elif s == 'up':     # vor
            #ball.velocity.z -= 0.1
       # elif s == 'down':   # zurueck
          # c

"""if ball.y < 1 and ball.velocity.y < 0:
        # Reduktion der Geschwindigkeit = Daempfung
        ball.velocity.y = -0.65*ball.velocity.y
        ball.y = 1
    else:
        ball.velocity.y = ball.velocity.y - 9.8*dt
    pfeil.pos=ball.pos
    pfeil.axis=ball.velocity
oberflaeche.velocity = vector(0, 0, 0)
pfeil = arrow(pos=oberflaeche.velocity, axis=oberflaeche.velocity, color=color.green, shaftwidth=0.25)"""

e=0
f=0

while True:
    rate(100)
    #oberflaeche.pos= oberflaeche.pos+ oberflaeche.velocity*dt
    #ball.pos = ball.pos + ball.velocity*dt


    # Falls Tastatur gedrueckt...
    if scene.kb.keys:
        s = scene.kb.getkey()
        print s
        print oberflaeche.axis
        if   s == 'left' and f<25 :   # links
            oberflaeche.rotate(angle=radians(0.75), axis=(0,0,1))
            f=f+1
           # ball.velocity.x += -0.1
        elif s == 'right'and f>-25:  # right
            oberflaeche.rotate(angle=radians(0.75), axis=(0,0,-1))
            f=f-1
            #ball.velocity.x +=  0.1
        elif s == 'up' and e<25:     # vor
            oberflaeche.rotate(angle=radians(0.75), axis=(-1,0,0))
            e=e+1
            #ball.velocity.z -= 0.1
        elif s == 'down' and e>-25:   # zurueck
            oberflaeche.rotate(angle=radians(0.75), axis=(1,0,0))
            e=e-1
            # ball.velocity.z += 0.1
      
  
      

Funktionsleiste