Results 1 to 2 of 2

Thread: Starfield

  1. #1

    Thread Starter
    Fanatic Member alkatran's Avatar
    Join Date
    Apr 2002
    Location
    Canada
    Posts
    860

    Starfield

    Lately I've been trying to make a 3d program (with Qb) i started out by trying to make a 3d starfield (like the screensaver), I've got most of it down, but i can't seem to get the math for placing a star right... I can get the direction, but not the distance away from the center...

    Here's the placement code:

    VB Code:
    1. Far = ABS(Dir1)+ABS(Dir2) / 2
    2. 'Far is how far from the center
    3. 'Dir1 is the angle from you to the star (X and Z axis)
    4. 'Dir2 is the angle from you to the star (Y and Z axis)
    5. 'Dir3 is the angle from you to the star (X and Y axis)
    6.  
    7. X = 320 + (((ABS(Far)*SIN(Rad(Dir3))) / 180) * 640)
    8. Y = 210 + (((ABS(Far)*COS(Rad(Dir3))) / 180) * 420)
    9. 'Rad is a function that converts degrees to radians
    10. 'X is x position, and Y is y position
    11. '320+ and 210+ put the startign point in mid of screen
    12. '/180)*640 and /180)*420 stretch the circle out so it coveres the screen

    The problem is with the first line of course, i used the angles... the actual moving forward looks pretty real, but if i tell it to move to the side... well the stars seem to go in a circle

    Any ideas?
    Don't pay attention to this signature, it's contradictory.

  2. #2
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    I made one like this a while ago, and what I did is create the finishing point and a speed for the star. That speed is how many ticks it should take for the star to get there. I then subtracted the centrex from the endx, same with the y, and divided that by the speed. Then I added that to the star's position and it worked like cake.
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width