Computer Science Canada

I've finally tried 3d

Author:  petree08 [ Fri Sep 14, 2007 10:31 am ]
Post subject:  I've finally tried 3d

I was making this black hole thing and i noticed it looked 3d
so i based the rotation of it on the mouse

not as great as all the other 3d posts but i think its a start

code:

% my psudeo 3d
% i actually stumbled on this by mistake, origionally
% it was suposed to be a worm hole, but then i realised it
% looked 3d , so i based all the angles on the position of the mouse
setscreen ("graphics:max,max,nobuttonbar,offscreenonly")
const ORB_X := maxx div 2
const ORB_Y := maxy div 2
const NUM_OF_POINTS := 200
const SIZE := 600
var MX, MY, Click : int
var X, Y, Angle, Length : array 1 .. NUM_OF_POINTS of int

for I : 1 .. NUM_OF_POINTS

    randint (Angle (I), 0, 360)
    randint (Length (I), 1, SIZE - 210)
    X (I) := round (ORB_X + (cosd (Angle (I)) * Length (I)))
    Y (I) := round (ORB_Y + (sind (Angle (I)) * Length (I)))

end for
colorback (7)
cls
loop
    mousewhere (MX, MY, Click)
    cls
    for I : 1 .. NUM_OF_POINTS
        drawfilloval (X (I), Y (I), Length (I) div 30, Length (I) div 30,
            Rand.Int (12, 13))

        if Length (I) > 1 then

            if Angle (I) > 360 then
                Angle (I) := 0
            end if

        else
            Length (I) := SIZE
        end if
       
        X (I) := round (ORB_X + (cosd (Angle (I) + ORB_X - MX) * Length (I)))
        Y (I) := round (ORB_X + (sind (Angle (I) + ORB_Y - MY) * Length (I)))
       
      %  drawline (ORB_X, ORB_Y, X (I), Y (I), 0)
    end for
 


    View.Update

end loop



Author:  MichaelM [ Fri Sep 14, 2007 1:51 pm ]
Post subject:  Re: I've finally tried 3d

Shocked Wow, thats the most amazing 50 lines of code ive ever seen. Very smart, very impressive

Author:  Nick [ Fri Sep 14, 2007 2:16 pm ]
Post subject:  RE:I\'ve finally tried 3d

DAM!!! thats good... amzing fps for a 3-D program... on my ME i could acctually see it do things!!!!!!!!!! yea it's that amazing lol nice job Razz

Author:  petree08 [ Sun Sep 16, 2007 9:09 am ]
Post subject:  RE:I\'ve finally tried 3d

yeah ive got a better version of this
it only uses 3 variables
30 lines and it looks sooo better Smile

code:


setscreen ("graphics:max,max,nobuttonbar,offscreenonly")
const NUM_OF_POINTS := 360 % increase this to make a bigger spiral

const ORB_X := maxx div 2
const ORB_Y := maxy div 2

var XM, YM, Click : int
colorback (7)
loop
    cls
    mousewhere (XM, YM, Click)

    for I : 1 .. NUM_OF_POINTS
        if I mod 2 = 0 then
            drawfilloval (round
                (cosd (I * 2 + (XM + ORB_X)) * (I div 2)) + ORB_X,
                round (sind (I * 2 + (YM + ORB_Y)) * (I div 2)) + ORB_Y,
                round ((I div 2) div 20),
                round ((I div 2) div 20), 0)
        else
            drawfilloval (round
                (cosd (I * 2 + (XM - ORB_X)) * (I div 2)) + ORB_X,
                round (sind (I * 2 + (YM - ORB_Y)) * (I div 2)) + ORB_Y,
                round ((I div 2) div 20),
                round ((I div 2) div 20), 1)
        end if

    end for

    View.Update
end loop

Author:  Nick [ Sun Sep 16, 2007 10:31 am ]
Post subject:  RE:I\'ve finally tried 3d

nicely done Razz looks great with almost no lag


: