Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
3D Stars....
#1
Smile Okay, I programed these stars in Screen 19 for the heck of it while learning 3D.. [Edit] Calculate the FPS wrong fist time, so easy to put the F = F + 1 in the wrong loop, oh well.. Code corrected :wink: [/edit]

[syntax="FreeBasic"]'3DStars! Enjoy! Big Grin

Centx = 400
Centy = 300
LENS = 256
DIM x(1000)
DIM y(1000)
DIM z(1000)
DIM zv(1000)
DIM xp(1000)
DIM yp(1000)
FOR i = 1 TO 1000
x(i) = -200 + INT(RND * 800)
y(i) = -200 + INT(RND * 400)
z(i) = INT(RND * 255)
zv(i) = 1 + INT(RND * 20)
NEXT

SCREEN 19
az = 0
T! = TIMER
DO
press$ = INKEY$
F = F + 1
LINE (0,0)-(800,600), 0, BF
ra! = az * 3.14 / 180
cosz! = COS(ra!)
sinz! = SIN(ra!)

FOR i = 1 TO 1000
z(i) = z(i) + zv(i)
Dist = LENS - z(i)
IF z(i) > 256 THEN z(i) = 0

Tx! = x(i)
Ty! = y(i)
sx! = (Tx! * cosz!) - (Ty! * sinz!)
sy! = (Ty! * cosz!) + (Tx! * sinz!)

IF Dist > 0 THEN
xp(i) = Centx + (LENS * sx! / Dist)
yp(i) = Centy - (LENS * sy! / Dist)
ELSE
END IF

PSET (xp(i), yp(i)), 15
IF press$ = CHR$(27) THEN CLS: PRINT "Average: FPS"; F / (TIMER - T!): SLEEP: END
NEXT
az = (az + 1) MOD 360
WAIT &H3DA, 8
SLEEP 5
LOOP[/syntax]
Kevin (x.t.r.GRAPHICS)

[Image: 11895-r.png]
Reply
#2
To Rattrapmax6:

After looking at your 3D stars program in FB, I no doubt say that you are off and running to a real good start on that! Big Grin And you know what I found out? The average FPS so far on the Pionex 450-mhz “Pentium III”-based computer that I currently use is a staggering 49326 FPS, *way* more than you expected, my man! Amazing! :o

Still, a pretty cool job from you on your program here, Rattrapmax6, and thank you!! Cool



WISHING YOU SO WELL TONIGHT,

[Image: file.php?id=32]
Adigun Azikiwe Polack
One of the Founders of “Aura Flow” ::: Continuing Developer of “Frantic Journey”
Current Developer of “Star Angelic Slugger” ::: Webmaster of the “AAP Official Projects Squad”
Original Creator of the “The New FreeBASIC 8-Bit Palette Machine”
url=http://dhost.hopto.org/aapproj/][Image: file.php?id=194][/url]
Your *official* home of the FreeBasic GFX Demo Central, now holding over 150 FB graphics demos so far!!! Big Grin !
Reply
#3
:???: Heh, you got the one with the Frame conter (F = F + 1) in the FOR NEXT loop, or the one with the one in the main loop? Smile Could have caused a over count if you had my first post b4 I edited the code... Just checking, cause I had 10,000FPS b4 a fixed it, and it went back to round 12FPS... Just making sure I didn't lead you astray. :wink:

Thanks for the comments tho,. Had no problem with the flying part, but had too look and recheck the formulas to get it to spiral like that.. Smile .. I finialy figured that out tho,.. Also had to port and modified what I learned since I'm reading up on Rel's which uses screen 13... :o ... to screen 19........ :roll: .. that part was fun...
Kevin (x.t.r.GRAPHICS)

[Image: 11895-r.png]
Reply
#4
To Rattrapmax6 again:

Let us get things on the up and up now, shall we? Big Grin

On my last reply here, I talked about your first copy of your FB code in this thread. But then, I found out eventually about your editing of that exact same code, and went ahead and gone for it, man. And so far on that same computer I use, the FPS rate has balanced out to 36.7 FPS. Very nicely done! Wink

And don’t you even worry, Rattrapmax6. You are alright with me. Smile=b

Talk to you again, and thanks!!! Big Grin



[Image: file.php?id=32]
- Adigun Azikiwe Polack
One of the Founders of “Aura Flow” ::: Continuing Developer of “Frantic Journey”
Current Developer of “Star Angelic Slugger” ::: Webmaster of the “AAP Official Projects Squad”
Original Creator of the “The New FreeBASIC 8-Bit Palette Machine”
url=http://dhost.hopto.org/aapproj/][Image: file.php?id=194][/url]
Your *official* home of the FreeBasic GFX Demo Central, now holding over 150 FB graphics demos so far!!! Big Grin !
Reply
#5
I converted it into qb, it looks quite good in screen 12, and i changed the sleep 5 to a delay,

this is what i ran

Code:
'3DStars! Enjoy!

Centx = 400
Centy = 300
LENS = 256
DIM x(1000)
DIM y(1000)
DIM z(1000)
DIM zv(1000)
DIM xp(1000)
DIM yp(1000)
FOR i = 1 TO 1000
   x(i) = -200 + INT(RND * 800)
   y(i) = -200 + INT(RND * 400)
   z(i) = INT(RND * 255)
   zv(i) = 1 + INT(RND * 20)
NEXT

SCREEN 12
az = 0
T! = TIMER
DO
   press$ = INKEY$
   F = F + 1
   LINE (0, 0)-(800, 600), 0, BF
   ra! = az * 3.14 / 180
   cosz! = COS(ra!)
   sinz! = SIN(ra!)
    
   FOR i = 1 TO 1000
      z(i) = z(i) + zv(i)
      Dist = LENS - z(i)
      IF z(i) > 256 THEN z(i) = 0
            
      Tx! = x(i)
      Ty! = y(i)
      sx! = (Tx! * cosz!) - (Ty! * sinz!)
      sy! = (Ty! * cosz!) + (Tx! * sinz!)

      IF Dist > 0 THEN
         xp(i) = Centx + (LENS * sx! / Dist)
         yp(i) = Centy - (LENS * sy! / Dist)
      ELSE
      END IF

      PSET (xp(i), yp(i)), 15
      IF press$ = CHR$(27) THEN CLS : PRINT "Average: FPS"; F / (TIMER - T!): SLEEP: END
   NEXT
   az = (az + 1) MOD 360
   WAIT &H3DA, 8
    
    FOR i = 1 TO 50000
    NEXT


LOOP

Though i could only see a part of the screen, it looks quite good
url=http://www.sloganizer.net/en/][Image: style4,TheDarkJay.png][/url]
Reply
#6
Good start. Keep it up!!!
y smiley is 24 bit.
[Image: anya2.jpg]

Genso's Junkyard:
http://rel.betterwebber.com/
Reply
#7
Quote:Though i could only see a part of the screen, it looks quite good

:lol: Of course...

[syntax="FreeBasic"] x(i) = -200 + INT(RND * 800)
y(i) = -200 + INT(RND * 400)[/syntax]

^^ That was one of the things I had to modify.. Change that to..

[syntax="QBasic"] x(i) = -60 + INT(RND * 400)
y(i) = -60 + INT(RND * 300)[/syntax]

What Relsoft orginaly had for QB,. :wink:

Smile To Adigun: Glad you got all that strait, I havn't been doing a FPS but here lately, not used to it,. heh, :wink:

To Relsoft: I will, really fun, math and all!... :bounce: [/code]
Kevin (x.t.r.GRAPHICS)

[Image: 11895-r.png]
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)