### Author Topic: Rotating Cube  (Read 217 times)

#### Rick3137 ##### Rotating Cube
« on: 10. November 2015, 20:29:46 »
Since Pulsar seems to lack a 3D system like opengl, I have become interested in pre-windows methods for faking 3D.
What I have so far is just simple Isometric drawing. I might not make it all the way to real 3d, but at least it is interesting.
The rotating cube idea would give me something to build a Rubik's Cubic on . I hope it is not too big a problem to solve.

Code: [Select]
```    -- Written by Rick3137.   Tested on Windows10 win = openwindow ("Start",-1,-1,1200,700) setactivewindow (win) backcolor (0,0,0,255) cls() sync()     x=0 ; y=0 ; f= 0 ; x1=0 ; y1 = 0 ; Ang = 0 ; r = 500     Pi = math.pi ; AngleS = Pi / 180 -- Angle Segment equal to 1.0 degrees     px = {0,0,0,0,0,0,0,0,0,0}    --  Point X     py = {0,0,0,0,0,0,0,0,0,0}    --  Point Y     Ang = { 0,0,0,0 }             -- Holds the 4 bottom cube angles                color (255,225,255,100) function DrawQuad( cx,cy,radius, Ang1)           --Ang1 moves from 0 to 200           local Angle = 0 ; a1 = Pi / 180 ; x2=0 ; y2=0 ; x3=400 ; y3 = 400           Ang = Ang1             for a=0,360 do            Angle = a * AngleS            x2 = cos(Angle) * radius + cx            y2 = -.3 * sin(Angle) * radius + cy            --dot(x2,y2)            Ang = Ang1 + 90 ; Ang = Ang1 + 180 ; Ang = Ang1 + 270                 for b=1,4 do                     if (Ang[b] > 360 ) then                         Ang[b] = Ang[b] - 360                     end                     if (a == Ang[b] ) then      -- start at 45                          px[b] =  x2  ; py[b] = y2                     end                 end                end        DrawLines(radius) end function DrawLines(radius)        line( px, py, px, py ) ;line( px, py, px, py ) ;line( px, py, px, py )        line( px, py, px, py )        line( px, py - radius, px, py - radius ) ;line( px, py - radius, px, py - radius )        line( px, py - radius, px, py - radius ) ; line( px, py - radius, px, py - radius )             line( px, py, px, py - radius ) ; line( px, py, px, py - radius )        line( px, py, px, py - radius ) ; line( px, py, px, py - radius )                drawtext ( Ang1,0,30)        sync()        --wait( 100) end    color (100,100,0,255)   a = 45 ; cnt = 0 ; key = 200     while key > 100 do         color (0,0,0,255)         --cls()         fillrectangle( 0,40,1000,700 )         color (255,255,255,255)         DrawQuad( 400,400,200,a )   -- x,y,radius,angle         wait(5)         sync()         a = a + 1 ; cnt = cnt + 1         if (a>360) then            a = a - 360         end         key = getkey()         drawtext ("Press any key to exit ..",0,0)         sync()      end sync() closewindow(win) closeapplication() ```
http://rb23.yolasite.com  Ricks Programs
http://rb27.synthasite.com   Sight and Sound