#Super Mario 3D Beta

#Object Import
from visual import *

scene.title = "Super Mario 3D"

#Boden

Boden = frame()
flaeche1 = box(pos=(39.5,-1,0), \
            length=79,height=2,width=2,  \
            color=(1,.8,.4),  \
            material=materials.wood,  \
            frame=Boden)
            

flaeche2 = box (pos=(88.5,-1,0),  \
            length=15,height=2,width=2,  \
            color=(1,.8,.4),  \
            frame=Boden,  \
            material=materials.wood)
            
flaeche3 = box (pos=(131,-1,0),  \
            length=64,height=2,width=2,  \
            color=(1,.8,.4),  \
            material=materials.wood,  \
            frame=Boden)

flaeche4 = box (pos=(193.5,-1,0),  \
            length=57,height=2,width=2,  \
            color=(1,.8,.4),  \
            material=materials.wood,  \
            frame=Boden)

#Huegel

huegel1=frame()
reihe1 = box (pos=(146,0.5,0),  \
            length=4,width=2,  \
            color=(.3,.2,.1),  \
            material=materials.plastic,  \
            frame=huegel1)
reihe2 = box (pos=(146.5,1.5,0),  \
            length=3,width=2,  \
            color=(.3,.2,.1),  \
            material=materials.plastic,  \
            frame=huegel1)
reihe3 = box (pos=(147,2.5,0),  \
            length=2,width=2,  \
            color=(.3,.2,.1),  \
            material=materials.plastic,  \
            frame=huegel1)
reihe4 = box (pos=(147.5,3.5,0),  \
            length=1,width=2,  \
            color=(.3,.2,.1),  \
            material=materials.plastic,  \
            frame=huegel1)

huegel2 = frame()
reihe1 = box (pos=(152,0.5,0),  \
            length=4,width=2,  \
            color=(.3,.2,.1),  \
            material=materials.plastic,  \
            frame=huegel2)
reihe2 = box (pos=(151.5,1.5,0),  \
            length=3,width=2,  \
            color=(.3,.2,.1),  \
            material=materials.plastic,  \
            frame=huegel2)
reihe3 = box (pos=(151,2.5,0),  \
            length=2,width=2,  \
            color=(.3,.2,.1),  \
            material=materials.plastic,  \
            frame=huegel2)
reihe4 = box (pos=(150.5,3.5,0),  \
            length=1,width=2,  \
            color=(.3,.2,.1),  \
            material=materials.plastic,  \
            frame=huegel2)
            
            
huegel3 = frame()
reihe1 = box (pos=(160.5,0.5,0),  \
            length=5,width=2,  \
            color=(.3,.2,.1),  \
            material=materials.plastic,  \
            frame=huegel3)
reihe2 = box (pos=(161,1.5,0),  \
            length=4,width=2,  \
            color=(.3,.2,.1),  \
            material=materials.plastic,  \
            frame=huegel3)
reihe3 = box (pos=(161.5,2.5,0),  \
            length=3,width=2,  \
            color=(.3,.2,.1),  \
            material=materials.plastic,  \
            frame=huegel3)
reihe4 = box (pos=(162,3.5,0),  \
            length=2,width=2,  \
            color=(.3,.2,.1),  \
            material=materials.plastic,  \
            frame=huegel3)


huegel4 = frame()
reihe1 = box (pos=(167,0.5,0),  \
            length=4,width=2,  \
            color=(.3,.2,.1),  \
            material=materials.plastic,  \
            frame=huegel4)
reihe2 = box (pos=(166.5,1.5,0),  \
            length=3,width=2,  \
            color=(.3,.2,.1),  \
            material=materials.plastic,  \
            frame=huegel4)
reihe3 = box (pos=(166,2.5,0),  \
            length=2,width=2,  \
            color=(.3,.2,.1),  \
            material=materials.plastic,  \
            frame=huegel4)
reihe4 = box (pos=(165.5,3.5,0),  \
            length=1,width=2,  \
            color=(.3,.2,.1),  \
            material=materials.plastic,  \
            frame=huegel4)
            
            
huegel5 =frame()
reihe1 = box(pos=(195.5,0.5,0),  \
            length=9,width=2,  \
            color=(.3,.2,.1),  \
            material=materials.plastic,  \
            frame=huegel5)
reihe2 = box(pos=(196,1.5,0),  \
            length=8,width=2,  \
            color=(.3,.2,.1),  \
            material=materials.plastic,  \
            frame=huegel5)
reihe3 = box(pos=(196.5,2.5,0),  \
            length=7,width=2,  \
            color=(.3,.2,.1),  \
            material=materials.plastic,  \
            frame=huegel5)
reihe4 = box(pos=(197,3.5,0),  \
            length=6,width=2,  \
            color=(.3,.2,.1),  \
            material=materials.plastic,  \
            frame=huegel5)
reihe5 = box(pos=(197.5,4.5,0),  \
            length=5,width=2,  \
            color=(.3,.2,.1),  \
            material=materials.plastic,  \
            frame=huegel5)
reihe6 = box(pos=(198,5.5,0),  \
            length=4,width=2,  \
            color=(.3,.2,.1),  \
            material=materials.plastic,  \
            frame=huegel5)
reihe7 = box(pos=(198.5,6.5,0),  \
            length=3,width=2,  \
            color=(.3,.2,.1),  \
            material=materials.plastic,  \
            frame=huegel5)
reihe8 = box(pos=(199,7.5,0),  \
            length=2,width=2,  \
            color=(.3,.2,.1),  \
            material=materials.plastic,  \
            frame=huegel5)


#Roehren

pipes = frame()
pipe1 = cylinder (pos=(29,0,0),  \
                axis=(0,1,0),  \
                radius=0.9,  \
                length=1.8,  \
                color=(0,1,0),  \
                frame=pipes)
pipe1top= cylinder (pos=(29,1.8,0),  \
                axis=(0,1,0),  \
                radius=1,  \
                length=0.2,  \
                color=(0,1,0),  \
                frame=pipes)
pipe2 = cylinder (pos=(39,0,0),  \
                axis=(0,1,0),  \
                radius=0.9,  \
                length=2.8,  \
                color=(0,1,0),  \
                frame=pipes)
pipe2top= cylinder (pos=(39,2.8,0),  \
                axis=(0,1,0),  \
                radius=1,  \
                length=0.2,  \
                color=(0,1,0),  \
                frame=pipes)
pipe3 = cylinder (pos=(47,0,0),  \
                axis=(0,1,0),  \
                radius=0.9,  \
                length=3.8,  \
                color=(0,1,0),  \
                frame=pipes)
pipe3top= cylinder (pos=(47,3.8,0),  \
                axis=(0,1,0),  \
                radius=1,  \
                length=0.2,  \
                color=(0,1,0),  \
                frame=pipes)
pipe4 = cylinder (pos=(58,0,0),  \
                axis=(0,1,0),  \
                radius=0.9,  \
                length=3.8,  \
                color=(0,1,0),  \
                frame=pipes)
pipe4top= cylinder (pos=(58,3.8,0),  \
                axis=(0,1,0),  \
                radius=1,  \
                length=0.2,  \
                color=(0,1,0))
pipe5 = cylinder (pos=(174,0,0),  \
                axis=(0,1,0),  \
                radius=0.9,  \
                length=1.8,  \
                color=(0,1,0),  \
                frame=pipes)
pipe5top= cylinder (pos=(174,1.8,0),  \
                axis=(0,1,0),  \
                radius=1,  \
                length=0.2,  \
                color=(0,1,0),  \
                frame=pipes)
pipe6 = cylinder (pos=(190,0,0),  \
                axis=(0,1,0),  \
                radius=0.9,  \
                length=1.8,  \
                color=(0,1,0),  \
                frame=pipes)
pipe6top= cylinder (pos=(190,1.8,0),  \
                axis=(0,1,0),  \
                radius=1,  \
                length=0.2,  \
                color=(0,1,0),  \
                frame=pipes)

#Normale Bloecke

blocks = frame()
block1 = box (pos=(20.5,3.5,0),  \
            color=(.6,.4,.2))
block2 = box (pos=(22.5,3.5,0),  \
            color=(.6,.4,.2))
block3 = box (pos=(24.5,3.5,0),  \
            color=(.6,.4,.2))
block4 = box (pos=(67.5,3.5,0),  \
            color=(.6,.4,.2))
block5 = box (pos=(69.5,3.5,0),  \
            color=(.6,.4,.2))
block6 = box (pos=(74,7.5,0),  \
            length=8,
            color=(.6,.4,.2))
block7 = box (pos=(82.5,7.5,0),  \
            length=3,
            color=(.6,.4,.2))
block8 = box (pos=(91,3.5,0),  \
            length=2,
            color=(.6,.4,.2))
block9 = box (pos=(108.5,3.5,0),  \
            color=(.6,.4,.2))
block10 = box (pos=(112.5,7.5,0),  \
            length=3,
            color=(.6,.4,.2))
block11 = box (pos=(118.5,7.5,0),  \
            color=(.6,.4,.2))
block12 = box (pos=(121.5,7.5,0),  \
            color=(.6,.4,.2))
block13 = box (pos=(120,3.5,0),  \
            length=2,
            color=(.6,.4,.2))
block14 = box (pos=(179,3.5,0),  \
            length=2,
            color=(.6,.4,.2))
block15 = box (pos=(181.5,3.5,0),  \
            color=(.6,.4,.2))
            

#?-Bloecke

bloxs=frame()
blox1 = box (pos=(16.5,3.5,0),  \
            color=(.89,.75,.09))

blox2 = box (pos=(21.5,3.5,0),  \
            color=(.89,.75,.09))

blox3 = box (pos=(23.5,3.5,0),  \
            color=(.89,.75,.09))

blox4 = box (pos=(22.5,7.5,0),  \
            color=(.89,.75,.09))

blox5 = box (pos=(54.5,4.5,0),  \
            color=(.89,.75,.09))

blox6 = box (pos=(68.5,3.5,0),  \
            color=(.89,.75,.09))

blox7 = box (pos=(84.5,7.5,0),  \
            color=(.89,.75,.09))

blox8 = box (pos=(84.5,3.5,0),  \
            color=(.89,.75,.09))

blox9 = box (pos=(96.5,3.5,0),  \
            color=(.89,.75,.09))

blox10 = box (pos=(99.5,3.5,0),  \
            color=(.89,.75,.09))

blox11 = box (pos=(102.5,3.5,0),  \
            color=(.89,.75,.09))

blox12 = box (pos=(99.5,7.5,0),  \
            color=(.89,.75,.09))

blox13 = box (pos=(119.5,7.5,0),  \
            color=(.89,.75,.09))

blox14 = box (pos=(120.5,7.5,0),  \
            color=(.89,.75,.09))

blox15 = box (pos=(180.5,3.5,0),  \
            color=(.89,.75,.09))

#Zielflagge

flag = frame()
podest = box (pos=(208.5,0.5,0),  \
            color=(.3,.2,.1),  \
            frame=flag)
mast = cylinder (pos=(208.5,1,0),  \
                axis=(0,1,0),  \
                color=(0,1,0),  \
                length=11,  \
                radius=0.1,  \
                frame=flag)
top = sphere (pos=(208.5,12,0),  \
            radius=0.2,  \
            color=(0,1,0), \
            frame=flag)
fahne = pyramid (pos=(208.5,11.5,0),  \
                width=0.0000001,  \
                color=(1,0,0),  \
                frame=flag)
fahne.rotate(angle=(radians(180)),origin=fahne.pos,axis=(0,1,0))

#Festung

burg = frame()
unten = box (pos=(214.5,0.5,-3.5),  \
            height=5,width=5,length=5,  \
            color=(0.5,0.5,0.5),  \
            frame=burg)
oben = box (pos=(214.5,4.5,-3.5),  \
            height=3,length=3,width=3,  \
            color=(0.5,0.5,0.5),  \
            frame=burg)

#Mario

Mario = frame()
koerper = ellipsoid (pos=(1.5,1,0),  \
                    height=2,length=1,width=1,  \
                    color=(1,0,0),  \
                    frame=Mario)

Mario.velocity=-1
dt=0.1
scene.range=15
while True:
    #i=i+1
    rate(200)
    Mario.y = Mario.y + Mario.velocity*dt
    print Mario.pos, Mario.velocity
    scene.center=Mario.pos
    if Mario.pos[1]<0:
        Mario.velocity=0
    # Falls Tastatur gedrueckt...
    if scene.kb.keys:
        s = scene.kb.getkey()
        print s
        if   s == 'left':   # links
            Mario.pos = Mario.pos+(-1,0,0)
            #Mario.velocity.x += -0.1
        elif s == 'right':  # right
            Mario.pos=Mario.pos+(1,0,0)
            #Mario.velocity.x +=  0.1
        else :     # vor
            
            Mario.velocity = 1
        #elif s == 'down':   # zurueck
            #Mario.ve locity.z += 0

    if Mario.y>10:
        Mario.velocity=-1
    if Mario.pos.x==15 and Mario.pos.y>1:
        Mario.velocity=-1
    #for i in pipes.objects:
        #if Mario.pos==i.pos:
            #Mario.velocity=0 and Mario.pos.x=i.pos.x 
        