Labyrinth
Version 3.0
projekt1.py — text/python-source, 2 KB (2669 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 = materials.earth # 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)) # Blick auf die Szene scene.forward=(0,-1,-2) scene.background=color.black # Ball mit Geschwindigkeit und repr. Vektorpfeil ball = sphere(frame= oberflaeche, pos=(-a/2+5,5, a/2-5), color=color.green, radius=1, material=materials.rough, opacity=0.8) oberflaeche.velocity=vector(0, 0, -1) ball.velocity = oberflaeche.velocity pfeil = arrow(pos=ball.pos, axis=ball.velocity, color=color.green, shaftwidth=0.25) # Zeit in krement dt = 0.02 e=0 f=0 while True: rate(100) #oberflaeche.pos= oberflaeche.pos+ oberflaeche.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 elif s == 'right'and f>-25: # right oberflaeche.rotate(angle=radians(0.75), axis=(0,0,-1)) f=f-1 elif s == 'up' and e<25: # vor oberflaeche.rotate(angle=radians(0.75), axis=(-1,0,0)) e=e+1 elif s == 'down' and e>-25: # zurueck oberflaeche.rotate(angle=radians(0.75), axis=(1,0,0)) e=e-1 ball.pos=ball.pos+(-0.1*f,0,-0.1*e) scene.forward=(0,-1,-2)