Links und Funktionen
Sprachumschaltung

Navigationspfad


Inhaltsbereich

Labyrinth

Version 4.2 (Welt hinzugefügt)

projekt1.py — text/python-source, 10 KB (10615 bytes)

Dateiinhalt

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

oberflaeche = frame ()
a=100
b=0.5
c=2.5
flaeche = box (frame = oberflaeche, pos = (25,0,0),\
                length=(50), height= (1), width= (a), color=color.blue, material=materials.wood)
#Aussenwaende:
wand1= box (frame = oberflaeche, pos = (0.5*a-0.5*b,1.75,0),\
            length=(b), width=(a), height=(1),color=color.blue, material=materials.wood)
wand2= box (frame = oberflaeche, pos = (0,1.75,0),\
            length=(b), width=(a), height=(1), color=color.blue, material=materials.wood)
wand3= box (frame = oberflaeche, pos = (25,1.75,0.5*a-0.5*b),\
            length=(0.5*a), width=(b), height=(1), color=color.blue, material=materials.wood)
wand4= box (frame = oberflaeche, pos = (25,1.75,-0.5*a+0.5*b),\
            length=(0.5*a), width=(b), height=(1), color=color.blue, material=materials.wood)
#Trennwaende:
wand5 = box(frame= oberflaeche, pos = ( 30,1.75,45),\
            length= (40), width = (1), height= (c),color=color.green , material=materials.wood) #1
wand7 = box(frame= oberflaeche, pos = ( 5,1.75,47),\
            length= (1), width = (5), height= (c),color=color.green , material=materials.wood)  #3
wand11 = box(frame= oberflaeche, pos = ( 40,1.75,40),\
            length= (20), width = (1), height= (c),color=color.green , material=materials.wood) #7
wand12  =box(frame= oberflaeche, pos = ( 25,1.75,40 ),\
            length= (1), width = (10), height= (c),color=color.green , material=materials.wood) #8
wand13 = box(frame= oberflaeche, pos = ( 10,1.75,40),\
            length= (20), width = (1), height= (c),color=color.green , material=materials.wood) #9
wand14  =box(frame= oberflaeche, pos = ( 30,1.75,35.5 ),\
            length= (1), width = (10), height= (c),color=color.green , material=materials.wood) #10
wand15 = box(frame= oberflaeche, pos = ( 15,1.75,35),\
            length= (21), width = (1), height= (c),color=color.green , material=materials.wood) #11
wand16 = box(frame= oberflaeche, pos = ( 23,1.75,30),\
            length= (15), width = (1), height= (c),color=color.green , material=materials.wood) #12
wand17  =box(frame= oberflaeche, pos = ( 10,1.75,-5 ),\
            length= (1), width = (80), height= (c),color=color.green , material=materials.wood) #13
wand18  =box(frame= oberflaeche, pos = ( 15,1.75,28 ),\
            length= (1), width = (5), height= (c),color=color.green , material=materials.wood)  #14
wand19 = box(frame= oberflaeche, pos = ( 24.5,1.75,25),\
            length= (20), width = (1), height= (c),color=color.green , material=materials.wood) #15
wand20 = box(frame= oberflaeche, pos = ( 32.5,1.75,20),\
            length= (35), width = (1), height= (c),color=color.green , material=materials.wood) #16
wand21  =box(frame= oberflaeche, pos = ( 35,1.75,29.5 ),\
            length= (1), width = (10), height= (c),color=color.green , material=materials.wood) #17
wand22  =box(frame= oberflaeche, pos = ( 45,1.75,29.5 ),\
            length= (1), width = (10), height= (c),color=color.green , material=materials.wood) #18
wand23 = box(frame= oberflaeche, pos = ( 40,1.75,35),\
            length= (11), width = (1), height= (c),color=color.green , material=materials.wood) #19
wand24 = box(frame= oberflaeche, pos = ( 43,1.75,25),\
            length= (4), width = (1), height= (c),color=color.green, material=materials.wood ) #20
wand25  =box(frame= oberflaeche, pos = ( 40.5,1.75,27.5 ),\
            length= (1), width = (6), height= (c),color=color.green , material=materials.wood) #21
wand26  =box(frame= oberflaeche, pos = ( 15,1.75,13 ),\
            length= (1), width = (15), height= (c),color=color.green, material=materials.wood ) #22
wand27  = box(frame= oberflaeche, pos = ( 17,1.75,5),\
            length= (5), width = (1), height= (c),color=color.green , material=materials.wood) #23
wand28  =box(frame= oberflaeche, pos = ( 20,1.75,9.5 ),\
            length= (1), width = (10), height= (c),color=color.green , material=materials.wood) #24
wand29  =box(frame= oberflaeche, pos = ( 25.25,1.75,-5 ),\
            length= (1), width = (31), height= (c),color=color.green , material=materials.wood) #25
wand30 = box(frame= oberflaeche, pos = ( 32.25,1.75,15),\
            length= (25.5), width = (1), height= (c),color=color.green , material=materials.wood) #26
wand31 = box(frame= oberflaeche, pos = ( 35,1.75,10),\
            length= (20.5), width = (1), height= (c),color=color.green , material=materials.wood) #27
wand32  =box(frame= oberflaeche, pos = ( 5,1.75,-5 ),\
            length= (1), width = (80), height= (c),color=color.green , material=materials.wood) #28
wand33  = box(frame= oberflaeche, pos = ( 15.5,1.75,0),\
            length= (10), width = (1), height= (c),color=color.green , material=materials.wood) #29
wand34 = box(frame= oberflaeche, pos = ( 27,1.75,-45),\
            length= (35), width = (1), height= (c),color=color.green , material=materials.wood) #30
wand35  =box(frame= oberflaeche, pos = ( 45,1.75,-5 ),\
            length= (1), width = (31), height= (c),color=color.green , material=materials.wood) #31
wand36  =box(frame= oberflaeche, pos = ( 45,1.75,-35.5 ),\
            length= (1), width = (20), height= (c),color=color.green , material=materials.wood) #32
wand37 = box(frame= oberflaeche, pos = ( 35,1.75,-20),\
            length= (20.5), width = (1), height= (c),color=color.green , material=materials.wood) #33
wand38 = box(frame= oberflaeche, pos = ( 35.25,1.75,-25),\
            length= (20.5), width = (1), height= (c),color=color.green , material=materials.wood) #34
wand39  =box(frame= oberflaeche, pos = ( 20,1.75,-10 ),\
            length= (1), width = (21), height= (c),color=color.green , material=materials.wood) #35
wand40  =box(frame= oberflaeche, pos = ( 15,1.75,-12.5 ),\
            length= (1), width = (15), height= (c),color=color.green , material=materials.wood) #36
wand41  = box(frame= oberflaeche, pos = ( 17,1.75,-20),\
            length= (5), width = (1), height= (c),color=color.green , material=materials.wood) #37
wand42  = box(frame= oberflaeche, pos = ( 17,1.75,-25),\
            length= (5), width = (1), height= (c),color=color.green, material=materials.wood ) #38
wand43  = box(frame= oberflaeche, pos = ( 17,1.75,-35),\
            length= (5), width = (1), height= (c),color=color.green, material=materials.wood ) #39
wand44  =box(frame= oberflaeche, pos = ( 20,1.75,-30 ),\
            length= (1), width = (11), height= (c),color=color.green, material=materials.wood ) #40
wand45  =box(frame= oberflaeche, pos = ( 15,1.75,-30 ),\
            length= (1), width = (10), height= (c),color=color.green , material=materials.wood) #41
wand44  =box(frame= oberflaeche, pos = ( 25,1.75,-32.25 ),\
            length= (1), width = (15.5), height= (c),color=color.green , material=materials.wood) #42
wand45 = box(frame= oberflaeche, pos = ( 27,1.75,-40),\
            length= (25), width = (1), height= (c),color=color.green , material=materials.wood) #43
wand46  =box(frame= oberflaeche, pos = ( 40,1.75,-35.5 ),\
            length= (1), width = (10), height= (c),color=color.green , material=materials.wood) #44
wand47 = box(frame= oberflaeche, pos = ( 35.25,1.75,-30.5),\
            length= (10.5), width = (1), height= (c),color=color.green , material=materials.wood) #45
wand44  =box(frame= oberflaeche, pos = ( 30,1.75,-32.5 ),\
            length= (1), width = (5), height= (c),color=color.green , material=materials.wood) #46
#Smilie:
wand45  =box(frame= oberflaeche, pos = ( 30,1.75,-11 ),\
            length= (1), width = (5), height= (c),color=color.green , material=materials.wood) #s1
wand46  =box(frame= oberflaeche, pos = ( 30,1.75,1 ),\
            length= (1), width = (5), height= (c),color=color.green , material=materials.wood) #s2
wand47  =box(frame= oberflaeche, pos = ( 40,1.75,-5 ),\
            length= (1), width = (17), height= (c),color=color.green , material=materials.wood) #s3
wand48 = box(frame= oberflaeche, pos = ( 38,1.75,3),\
            length= (4), width = (1), height= (c),color=color.green , material=materials.wood) #s4
wand49 = box(frame= oberflaeche, pos = ( 38,1.75,-13),\
            length= (4), width = (1), height= (c),color=color.green, material=materials.wood ) #s5
wand50 = box(frame= oberflaeche, pos = ( 34,1.75,-5),\
            length= (3), width = (1), height= (c),color=color.green , material=materials.wood) #s6

#Zielfeld:
feld = box(frame = oberflaeche, pos = (47.5,0.51,42.5),\
            length=(5), width = (5), height=(0.1),color = color.red, material=materials.wood)
# Blick auf die Szene
scene.forward=(0,-1,-2)
scene.background=color.black


# Ball mit Geschwindigkeit und repr. Vektorpfeil
ball = sphere (frame= oberflaeche, pos= (47.5,1.5,47.5),radius =( 1),color=color.orange, opacity=0.8, material=materials.wood)
oberflaeche.velocity=vector(0, 0, -1)
ball.velocity = oberflaeche.velocity

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
    #Moeglichkeit des uebertretens des Feldes verhindern:
    if ball.x>1 and ball.x<48:
        ball.x= ball.x+(-0.01*f) #Bewegegung des Balls in x-Richtung
    else:
        if ball.x>=48:
            ball.x=47.9999
        if ball.x<=1:
            ball.x=1.0001
    if ball.z>-48 and ball.z<48:
        ball.z=ball.z+(-0.01*e) #Bewegung des Balls in z-Richtung
    else:
        if ball.z>=48:
            ball.z=47.9999
        if ball.z<=-48:
            ball.z=-47.9999
    #1 grenze wand5
    if ball.z>20.5 and ball.z<30.5:
        ball.z=ball.z+(-0.01*e)
    if ball.x>25 and ball.x<65:
        ball.x=ball.x+(-0.01*f)
"""
def check (wand, position):
    #Ecken der Grundflaeche der Wand
    x1=wand.pos-1.5+0.5*wand.length-0.5*wand.width
    x2=wand.pos-1.5+0.5*wand.length+0.5*wand.width
    x3=wand.pos-1.5-0.5*wand.length+0.5*wand.width
    x4=wand.pos-1.5-0.5*wand.length-0.5*wand.width
    
    if """

Funktionsleiste