Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Two Rotating Squares,...
#1
Smile I wouldn't waste time or space if I didn't think this was cool.. Minus the slight flicker, (might just be my system), I couldn't get out, its a very neat 2D, guess you could call 3D, heh, rotating squares.. Enjoy!! :wink:

NOTE: You control rotation with Left and Right arrow keys, I'm sure you can figure which one does which, Smile ....

Code:
Centx = 400
Centy = 300
LENS = 256
DIM x(100)
DIM y(100)
DIM z(100)
DIM xp(100)
DIM yp(100)

'Outer Square
DATA 200,200,0
DATA -200,200,0
DATA -200,-200,0
DATA 200,-200,0

'Iner Square
DATA 100,100,0
DATA -100,100,0
DATA -100,-100,0
DATA 100,-100,0

FOR i = 1 TO 8
   READ x(i)
   READ y(i)
   READ z(i)
NEXT
SCREEN 19, 32, 2, 1
a1 = 0
a2 = 0
T! = TIMER
DO
   press$ = INKEY$
   IF av1 <> 0 THEN LINE (0,0)-(800, 600), RGB(00,00,00), BF
   'Outer Square
   ra1! = (a1 * 3.14/ 180)
   cosa1! = COS(ra1!)
   sina1! = SIN(ra1!)
   FOR i = 1 TO 4
      Dist = LENS - z(i)
      xa1! = (x(i) * cosa1!) - (y(i) * sina1!)
      ya1! = (y(i) * cosa1!) + (x(i) * sina1!)
      xp(i) = Centx + (LENS * xa1!/Dist)
      yp(i) = Centy - (LENS * ya1!/Dist)
   NEXT
   'Iner Square
   ra2! = (a2 * 3.14/ 180)
   cosa2! = COS(ra2!)
   sina2! = SIN(ra2!)
   FOR i = 5 TO 8
      Dist = LENS - z(i)
      xa2! = (x(i) * cosa2!) - (y(i) * sina2!)
      ya2! = (y(i) * cosa2!) + (x(i) * sina2!)
      xp(i) = Centx + (LENS * xa2!/Dist)
      yp(i) = Centy - (LENS * ya2!/Dist)
   NEXT
   LINE (xp(1), yp(1))-(xp(2), yp(2)), RGB(00,200,00)
   LINE (xp(2), yp(2))-(xp(3), yp(3)), RGB(00,00,200)
   LINE (xp(3), yp(3))-(xp(4), yp(4)), RGB(200,00,00)
   LINE (xp(4), yp(4))-(xp(1), yp(1)), RGB(200,200,00)
  
   LINE (xp(5), yp(5))-(xp(6), yp(6)), RGB(00,200,00)
   LINE (xp(6), yp(6))-(xp(7), yp(7)), RGB(00,00,200)
   LINE (xp(7), yp(7))-(xp(8), yp(8)), RGB(200,00,00)
   LINE (xp(8), yp(8))-(xp(5), yp(5)), RGB(200,200,00)
   WAIT &H3DA, 8
   SLEEP 10
   IF press$ = CHR$(255) + "K" THEN av1 = av1 + 1:av2 = av2 - 1
   IF press$ = CHR$(255) + "M" THEN av1 = av1 - 1:av2 = av2 + 1
   a1 = (a1 + av1) MOD 360
   a2 = (a2 + av2) MOD 360
   F = F + 1
LOOP UNTIL press$ = CHR$(27)
PRINT "Average FPS:"; F / (TIMER - T!)
SLEEP
Kevin (x.t.r.GRAPHICS)

[Image: 11895-r.png]
Reply
#2
man..did you read rel's tutorials.. cause i see you used lens..and 256 and all thet.. i'm just wondering cause i couldent make any sinse outta it.. was wondering if maybe you could help me learn :bounce:
url=http://www.random-seed.net][Image: asylumsig.png][/url]
Reply
#3
Hmm, if I did, I could only explain what I've learned...

Tip: It really helps doing all the formulas yourself. (Start|Programs|Accessories|Calculator (Set to scientific mode)) This way you can see what FB is doing...
Kevin (x.t.r.GRAPHICS)

[Image: 11895-r.png]
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)