//Image All's Pinpression thingy that has the thing under it and go whee
 
sync on : sync rate 60 : hide mouse
disable escapekey : autocam off : randomize timer( )
 
//Pinpression variables
    type pos
        x as float
        y as float
        z as float
    endtype
 
    type pin
        id as integer
        pos as pos
    endtype
 
    type base
        id as integer
        pos as pos
    endtype
 
    #CONSTANT MAX_PINS 600
 
    global pinpressionbase as base
    global MasterPin as integer
    global dim pinpression(MAX_PINS) as pin
 
 
 
//Construct the pinpression
    MasterPin=freeObject( )
    make object box MasterPin, 0.35, 5.0, 0.35
    hide object MasterPin
 
    for x=1 to 20
        for y=1 to 30
            i=((30*(x-1))+y)
            pinpression(i).id=freeObject( )
            clone object pinpression(i).id, MasterPin
            pinpression(i).pos.x=((x*0.50)-5.25)
            pinpression(i).pos.y=0.00
            pinpression(i).pos.z=((y*0.50)-7.75)
        next y
    next x
 
    pinpressionbase.id=freeObject( )
    make object box pinpressionbase.id, 10.25, 1.50, 15.25
    set object diffuse pinpressionbase.id, 0x000088
    pinpressionbase.pos.x=0.0
    pinpressionbase.pos.y=10.0
    pinpressionbase.pos.z=0.0
 
 
 
//Build a random object for the Pinpression
    global Subject as integer
    Subject=constructRandomObject( 5, 2.0, 5.0 )
 
 
 
 
 
position camera 8, 15, -17.50
point camera 0, 0, 0
 
//Main Loop
while escapekey( )=0
    text 5,5,"Move the mouse forward and back to elevate the Pinpression"
    text 5,25,"Move the mouse left and right to rotate the objects below"
 
    ymove#=mousemovey( )*0.02
    inc pinpressionbase.pos.y, ymove#
    if pinpressionbase.pos.y<=2.75 then pinpressionbase.pos.y=2.75
 
    xmove#=mousemovex( )*0.04
    yrotate object Subject, object angle y( Subject )+xmove#
 
    for i=1 to MAX_PINS
        pinpression(i).pos.y=pinpressionbase.pos.y-1.5
            x#=pinpression(i).pos.x
            y1#=100.0
            y2#=pinpressionbase.pos.y-4.0
            z#=pinpression(i).pos.z
        ray#=intersect object( Subject, x#,y1#,z#, x#,y2#,z# )
        if ray#>0.0
            pinpression(i).pos.y=(100-ray#)+2.5
        endif
    next i    
 
    readyGameObjects( )
 
    sync
 
endwhile
 
cls
center text screen width( )/2, screen height( )/2, "exiting..." : sync
deleteGameObjects( )
end
 
 
 
 
 
 
//Function Declarations
 
function freeObject( )
    obj=0
    repeat
        inc obj, 1
    until object exist( obj )=0
endfunction obj
 
function constructRandomObject( limbs as integer, size# as float, radius# as float )
    object=freeObject( )
    make object sphere object, size#*2
    for i=1 to limbs
        limb=freeObject( )
        otype=rnd(2)
        select otype
        case 1
            make object sphere limb, size#*1.5
        endcase
        case 2
            make object cube limb, size#*2
        endcase
        case 0
            make object cone limb, size#*2
        endcase
        endselect
        make mesh from object 1, limb
        add limb object, i, 1
        delete mesh 1
        delete object limb
        offset limb object, i, rnd(radius#*2)-radius#, 0, rnd(radius#*2)-radius#
    next i
endfunction object       
 
function readyGameObjects( )
    base=pinpressionbase.id
    x1#=pinpressionbase.pos.x
    y1#=pinpressionbase.pos.y
    z1#=pinpressionbase.pos.z
    position object base, x1#, y1#, z1#
 
    for i=1 to MAX_PINS
        obj=pinpression(i).id
        x#=pinpression(i).pos.x
        y#=pinpression(i).pos.y
        z#=pinpression(i).pos.z
        position object obj, x#+x1#, y#, z#+z1#
    next i
endfunction
 
function deleteGameObjects( )
    failures=0
    objects=1
    do
        if object exist( objects )=1
            delete object objects
            inc objects, 1
        else
            inc failures, 1
        endif
 
        if failures=20
            exit
                endif
    loop
endfunction