QB64.org Forum

Active Forums => Programs => Topic started by: johnno56 on June 04, 2018, 09:15:23 pm

Title: Star Backgound
Post by: johnno56 on June 04, 2018, 09:15:23 pm
I'm an not sure where to post this...

I have attached a space background (800 x 600). I made this using Gimp. Please feel free to use as you see fit. Credit is not required.

ps: I do planets as well... But they take a LOT longer to make...

Enjoy.

J
Title: Re: Star Backgound
Post by: odin on June 04, 2018, 09:22:29 pm
This is probably the best spot.
Title: Re: Star Backgound
Post by: FellippeHeitor on June 04, 2018, 09:23:11 pm
That looks gorgeous, johnno56! I wonder if it could be generated with code.
Title: Re: Star Backgound
Post by: johnno56 on June 05, 2018, 12:22:10 am
You are quite welcome to try. I have absolutely no idea how to do that... It took me many attempts to create the image using the principles of a tutorial as a guide

J
Title: Re: Star Backgound
Post by: Ashish on June 05, 2018, 07:06:58 am
Wow johnno56! Seems like you are very good at graphics designing! Good work!
Title: Re: Star Backgound
Post by: bplus on June 05, 2018, 09:39:34 am
Hey Johnno,

That looks great for Lander project. Do you take requests? say for buttons, say for forward thruster, turning clockwise and counter-clockwise, for restarters?  ;-))
Title: Re: Star Backgound
Post by: Petr on June 05, 2018, 10:09:45 am
Johnno56 thank you for sharing this nice image!
Title: Re: Star Backgound
Post by: johnno56 on June 05, 2018, 11:40:44 am
Hey Johnno,

That looks great for Lander project. Do you take requests? say for buttons, say for forward thruster, turning clockwise and counter-clockwise, for restarters?  ;-))

N.B. I've already made a Lander using that background (sdlbasic) ;)

Flat; Glossy; Metallic; Rectangular; Circular; "Surprise Me"
Info: Dimensions; Colour; Text or symbol; Format: png etc

or perhaps a "hand drawing"

Just let me know what you need?

J

ps: Gold or Platinum plated will take longer and cost more... Nah. Kidding! Cost WAY more... lol
Title: Re: Star Backgound
Post by: bplus on June 05, 2018, 12:07:21 pm
Hey Johnno,

You can use your best judgment with Lander Project, the button sizes are around 200 x 50 but InForm can stretch them to fit.

Another collaboration? Feel free to add images to Lander Project thread.

Do you even have an idea for the Restart button?
Title: Re: Star Backgound
Post by: johnno56 on June 05, 2018, 05:27:28 pm
I'll start with perhaps a brushed metal finish... I do not think this project needs to have 'glossy' or 3D-type buttons... These beasties scream 'Hey look at me' and will 'distract'. After all, you do not want the player to crash, because their attention was 'drawn' to the fancy buttons... lol

Quick question: Regardless of the 'style', will you be wanting a duplicate 'clicked' button? (ie: slight colour change to indicate clicked)

J
Title: Re: Star Backgound
Post by: bplus on June 05, 2018, 05:37:24 pm
Hi Johnno,

You know what would be fancy cool, crystal buttons.

I'd say crystal buttons would glow a bit with mouse over and light up when pressed.

Don't know if we could do all that, don't know if we could do any of that. ;-))

Your Star Background is looking good with a black silhouette terrain.
Title: Re: Star Backgound
Post by: johnno56 on June 05, 2018, 10:26:47 pm
"Crystal" buttons. Hmm.. Not sure if I've seen any of those. Slight glow with mouse-over. Brighter glow when clicked. How will that work if the player only uses the arrow keys? Perhaps just a change of state from no glow to full glow? So, in essence, you need a set of 12 buttons, right? Crystal you say? I suppose you needed them yesterday? lol  I'm going to need a bottomless cup of coffee for 'this' project... lol

J
Title: Re: Star Backgound
Post by: Petr on June 06, 2018, 10:15:44 am
Hi. Crystal buttons can be very easy realised using _SETAPLHA if button is image&. I muss going out now, but i can writing demo when am back.
Title: Re: Star Backgound
Post by: Petr on June 06, 2018, 03:50:08 pm
So here it is, it use one Johnno56 picture:

Code: QB64: [Select]
  1. SCREEN _NEWIMAGE(800, 600, 32)
  2.  
  3. Image& = _LOADIMAGE("restart.png", 32)
  4. hide& = _NEWIMAGE(_WIDTH(Image&), _HEIGHT(Image&), 32)
  5.  
  6.     SELECT CASE Quad_Button(400, 300, Image&, 200, 0, 120) ' set alpha channel (transparency), 0 is full transparent, 255 is NOT transparent
  7.         CASE 0: LOCATE 1, 1: PRINT "Button not pressed"
  8.         CASE 1: LOCATE 1, 1: PRINT "Button pressed    "
  9.         CASE 2: LOCATE 1, 1: PRINT "Mouse on position "
  10.     END SELECT
  11.     _DISPLAY
  12.  
  13.  
  14.  
  15. FUNCTION Quad_Button (X AS INTEGER, Y AS INTEGER, ButtonImage AS LONG, OFF_Color, ON_Color, On_PosColor AS LONG)
  16.     _DEST hide&: LINE (0, 0)-(_WIDTH, _HEIGHT), _RGB32(0, 0, 0), BF: _DEST 0
  17.     IF _MOUSEX >= X AND _MOUSEX <= X + _WIDTH(ButtonImage&) AND _MOUSEY >= Y AND _MOUSEY <= Y + _HEIGHT(ButtonImage&) THEN
  18.         IF _MOUSEBUTTON(1) THEN GOSUB Button_Active
  19.         GOSUB OnPosition
  20.     END IF
  21.  
  22.     _SETALPHA OFF_Color, _RGB32(0, 0, 0), hide&
  23.     _PUTIMAGE (X, Y), ButtonImage&
  24.     _PUTIMAGE (X, Y), hide&
  25.     _LIMIT 30
  26.     Quad_Button = 0: EXIT FUNCTION
  27.  
  28.     OnPosition:
  29.     _SETALPHA On_PosColor, _RGB32(0, 0, 0), hide&
  30.     _PUTIMAGE (X, Y), ButtonImage&
  31.     _PUTIMAGE (X, Y), hide&
  32.     Quad_Button = 2: EXIT FUNCTION
  33.     RETURN
  34.  
  35.     Button_Active:
  36.     _SETALPHA ON_Color, _RGB32(0, 0, 0), hide&
  37.     _PUTIMAGE (X, Y), ButtonImage&
  38.     _PUTIMAGE (X, Y), hide&
  39.     Quad_Button = 1
  40.  

Please use picture RESTART.PNG from https://www.qb64.org/forum/index.php?topic=249.30 because attachments now works not.
Title: Re: Star Backgound
Post by: bplus on June 07, 2018, 10:11:33 am
Hi Petr,

Works fine and as expected for me; I had never noticed _SETALPHA before this. A rather complex function that one!

Thanks for your demo.

Title: Re: Star Backgound
Post by: johnno56 on June 11, 2018, 06:56:02 am
Not a problem. It's an image I through together using Gimp. Enjoy.

J
Title: Re: Star Backgound
Post by: Ashish on June 16, 2018, 12:29:57 pm
+[banned user]
Its cool to see spaceship running!
Title: Re: Star Backgound
Post by: bplus on June 16, 2018, 01:02:01 pm
Nice one [banned user]! Just like coming home again!

BTW, weren't you already a member here??? eg post in this thread June 11???
Title: Re: Star Backgound
Post by: johnno56 on June 16, 2018, 06:06:18 pm
Just a couple of things...

Firsly, VERY cool demo...

Can I assume correctly that QB64's default transparency colour is black? If so, a couple of the planets, have transparent 'patches'... If you like I can fix that... and one of the 'Mars' images is upside down... I can fix that too if you wish... I have limited time today (Sunday), as we will be out most of the day, but I can make the changes later this afternoon if that's ok?

Other than these few 'cosmetic' effects the demo ran very smoothly... I like it!!!

J

ps: Never mind about Mars. Ran the demo longer and notice the image was 'flipped'....
Title: Re: Star Backgound
Post by: Ashish on June 17, 2018, 02:19:06 am
Hi [banned user]!
Here's my fire MOD to your spaceship. :)
The amount of flame vary with speed of spaceship.

Code: QB64: [Select]
  1.  
  2. 'Original by [banned user]
  3. 'Fire MOD by Ashish
  4. _TITLE "Space the Final Frontier [Fire MOD]"
  5.  
  6.  
  7. DIM SHARED fireSizeX, fireSizeY
  8. fireSizeX = 120
  9. fireSizeY = 19
  10. DIM SHARED fireBuffer(fireSizeX, fireSizeY), colorPal(255) AS _UNSIGNED LONG, fuelControl
  11. fuelControl = 0.23
  12. 'creating our palette for fire
  13. FOR i = 255 TO 0 STEP -1
  14.     IF i <= 255 AND i >= 200 THEN 'white to yellow
  15.         colorPal(i) = _RGB32(map(i, 255, 200, 255, 255), map(i, 255, 200, 255, 242), map(i, 255, 200, 255, 0))
  16.     ELSEIF i <= 201 AND i >= 79 THEN 'yellow to orange
  17.         colorPal(i) = _RGB32(map(i, 201, 79, 255, 221), map(i, 201, 79, 242, 140), map(i, 201, 79, 0, 0))
  18.     ELSEIF i <= 89 AND i >= 79 THEN 'orange to dark orange red
  19.         colorPal(i) = _RGB32(map(i, 89, 79, 221, 183), map(i, 89, 79, 140, 45), map(i, 89, 79, 0, 0))
  20.     ELSEIF i <= 78 AND i >= 0 THEN 'dark orange red to transparent
  21.         colorPal(i) = _RGBA32(map(i, 78, 0, 183, 0), map(i, 78, 0, 45, 0), map(i, 78, 0, 0, 0), map(i, 78, 0, 255, 0))
  22.     END IF
  23.  
  24.  
  25. DIM Touch AS STRING
  26.  
  27. DIM SHARED frameRate AS INTEGER
  28. DIM SHARED frameCount AS INTEGER
  29.  
  30. DIM SHARED frameTime AS STRING
  31. frameTime = RIGHT$(TIME$, 2)
  32.  
  33. ' \/\/\/\/\/\/\/\/\/\/\/\/
  34. ' Screen Width and Height
  35. ' /\/\/\/\/\/\/\/\/\/\/\/\
  36. sWidth = 800
  37. sHeight = 600
  38.  
  39. SCREEN _NEWIMAGE(sWidth, sHeight, 32)
  40.  
  41. ' \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
  42. ' Stars Background and the Starship
  43. ' /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
  44. DIM SHARED starBack AS LONG
  45. DIM SHARED Starship AS LONG
  46.  
  47. ' Stars Background:
  48. ' https://www.qb64.org/forum/index.php?PHPSESSID=fe200737599194549d14a890bf46be14&topic=250.0
  49. starBack = _LOADIMAGE(".\images\Stars.png")
  50. _PUTIMAGE (0, 0), starBack
  51.  
  52. ' Starship:
  53. ' http://www.clipartlord.com/category/space-clip-art/spaceship-clip-art/
  54. Starship = _LOADIMAGE(".\images\Starship.png")
  55. _CLEARCOLOR _RGB(0, 0, 0), Starship
  56.  
  57. ' \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
  58. ' Used to make sure Starship doesn't go offscreen
  59. ' /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
  60. wShip = sWidth - 400
  61. hShip = sHeight - 170
  62.  
  63. ' \/\/\/\/\/\/\/\/\/\/\/\/\/\/
  64. ' Starship Location (Centered)
  65. ' /\/\/\/\/\/\/\/\/\/\/\/\/\/\
  66. shipX = sWidth \ 2 - 200
  67. shipY = sHeight \ 2 - 85
  68.  
  69. ' \/\/\/\/\/\/\/\/\/\/\/
  70. ' Speed of the Starship
  71. ' /\/\/\/\/\/\/\/\/\/\/\
  72. DIM SHARED warpSpeed AS INTEGER
  73. warpSpeed = 2
  74.  
  75. ' \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
  76. ' Celestial Objects (Stars and Planets)
  77. ' /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
  78. TYPE Celestial
  79.     ' Location
  80.     x AS INTEGER
  81.     y AS INTEGER
  82.  
  83.     ' Size
  84.     w AS INTEGER
  85.     h AS INTEGER
  86.  
  87.     ' Rotation
  88.     c AS INTEGER
  89.     r AS INTEGER
  90.  
  91.     ' Planet used
  92.     used AS INTEGER
  93.  
  94.     ' Planet Spins
  95.     spin AS INTEGER
  96.  
  97.     image AS LONG
  98.  
  99. ' \/\/\/\/\/\/\/\/
  100. ' Stars Background
  101. ' /\/\/\/\/\/\/\/\
  102. DIM SHARED Stars(2) AS Celestial
  103.  
  104. Stars(1).x = 0
  105. Stars(2).x = 800
  106.  
  107. Stars(1).image = _NEWIMAGE(800, 600, 32)
  108. _PUTIMAGE (0, 0), starBack, Stars(1).image
  109.  
  110. Stars(2).image = _NEWIMAGE(800, 600, 32)
  111. Frontier
  112.  
  113. ' \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
  114. ' Display text while Planets load
  115. ' /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
  116. Touch = "Loading Planet Data...."
  117.  
  118. y = sHeight \ 2 - 8
  119. x = sWidth \ 2 - (LEN(Touch) * 4)
  120. _PRINTSTRING (x, y), Touch
  121.  
  122. DIM SHARED PlanetView(4) AS INTEGER
  123.  
  124. DIM SHARED Planet(40) AS Celestial
  125.  
  126. ' \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
  127. ' Load all the planets (40 total)
  128. ' /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
  129. FOR p = 1 TO 40
  130.     ' Planets:
  131.     ' http://www.clipartlord.com/category/space-clip-art/planets-clip-art/
  132.     Planet(p).image = _LOADIMAGE(".\images\Planet" + RIGHT$("0" + LTRIM$(STR$(p)), 2) + ".png")
  133.     _CLEARCOLOR _RGB(0, 0, 0), Planet(p).image
  134.  
  135.     ' \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
  136.     ' Get the Width and Height of the planet
  137.     ' /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
  138.     Planet(p).w = _WIDTH(Planet(p).image)
  139.     Planet(p).h = _HEIGHT(Planet(p).image)
  140.  
  141. ' \/\/\/\/\/\/\/\/\/\/\/\/\/
  142. ' Starship enters the scene
  143. ' /\/\/\/\/\/\/\/\/\/\/\/\/\
  144. FOR x = -400 TO shipX STEP 10
  145.     'fire
  146.     FOR fy = 3 TO fireSizeY - 2
  147.         fireBuffer(fireSizeX - 2, fy) = INT(RND * 128) + 128
  148.     NEXT
  149.     FOR fy = 3 TO fireSizeY - 2
  150.         FOR fx = 0 TO fireSizeX - 2
  151.             fireBuffer(fx, fy) = (fireBuffer(fx + 1, fy - 1) + fireBuffer(fx + 1, fy) + fireBuffer(fx + 2, fy) + fireBuffer(fx + 1, fy + 1)) * (fuelControl + .018327)
  152.     NEXT fx, fy
  153.  
  154.     _PUTIMAGE (0, 0), starBack
  155.  
  156.     'rendering fire
  157.     FOR fy = 0 TO fireSizeY
  158.         FOR fx = 0 TO fireSizeX
  159.             'PRINT INT(fireBuffer(fx, fy))
  160.             PSET (fx + x + 115 - fireSizeX + 2, fy + shipY + 100), colorPal(INT(fireBuffer(fx, fy)))
  161.     NEXT fx, fy
  162.  
  163.     _PUTIMAGE (x, shipY), Starship
  164.  
  165.     _DISPLAY
  166.     _LIMIT 30
  167.  
  168. ' \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
  169. ' Show the animations until ESC is pressed
  170. ' /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
  171. WHILE Touch <> CHR$(27)
  172.     Background
  173.  
  174.  
  175.     ' \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
  176.     ' Checks to see if a key is pressed
  177.     ' /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
  178.     Touch = INKEY$
  179.     IF Touch <> "" THEN
  180.         ' \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
  181.         ' Keys 0-9 changes the warpspeed
  182.         ' /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
  183.         IF ASC(Touch) > 47 AND ASC(Touch) < 58 THEN warpSpeed = VAL(Touch)
  184.  
  185.         ' \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
  186.         ' Home key centers the Starship
  187.         ' /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
  188.         IF Touch = CHR$(0) + CHR$(71) THEN
  189.             shipX = sWidth \ 2 - 200
  190.             shipY = sHeight \ 2 - 85
  191.         END IF
  192.  
  193.         ' \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
  194.         ' Up and Down Arrow Keys moves the Starship
  195.         ' /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
  196.         IF Touch = CHR$(0) + CHR$(72) THEN
  197.             shipY = shipY - warpSpeed
  198.             IF shipY < 0 THEN shipY = 0
  199.         END IF
  200.  
  201.         IF Touch = CHR$(0) + CHR$(80) THEN
  202.             shipY = shipY + warpSpeed
  203.             IF shipY > hShip THEN shipY = hShip
  204.         END IF
  205.     END IF
  206.  
  207.     Framed
  208.  
  209.     _DISPLAY
  210.     _LIMIT 60
  211.  
  212. SUB Background
  213.     ' \/\/\/\/\/\/\/\/\/\/\/\/\/\/
  214.     ' Places the stars Backgrounds
  215.     ' /\/\/\/\/\/\/\/\/\/\/\/\/\/\
  216.     _PUTIMAGE (Stars(1).x, 0), Stars(1).image
  217.     _PUTIMAGE (Stars(2).x, 0), Stars(2).image
  218.  
  219.     ' \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
  220.     ' Show planet(s)  (if available)
  221.     ' /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
  222.     FOR v = 1 TO 2
  223.         IF PlanetView(v) > 0 THEN
  224.             ViewPlanet PlanetView(v), v
  225.         END IF
  226.     NEXT
  227.     acc = (warpSpeed + 1) * .001905#
  228.     'fire
  229.     FOR fy = 3 TO fireSizeY - 2
  230.         fireBuffer(fireSizeX - 2, fy) = INT(RND * 128) + 128
  231.     NEXT
  232.     FOR fy = 3 TO fireSizeY - 2
  233.         FOR fx = 0 TO fireSizeX - 2
  234.             fireBuffer(fx, fy) = (fireBuffer(fx + 1, fy - 1) + fireBuffer(fx + 1, fy) + fireBuffer(fx + 2, fy) + fireBuffer(fx + 1, fy + 1)) * (fuelControl + acc)
  235.     NEXT fx, fy
  236.     'rendering fire
  237.     FOR fy = 0 TO fireSizeY
  238.         FOR fx = 0 TO fireSizeX
  239.             'PRINT INT(fireBuffer(fx, fy))
  240.             PSET (fx + shipX + 115 - fireSizeX + 2, fy + shipY + 100), colorPal(INT(fireBuffer(fx, fy)))
  241.     NEXT fx, fy
  242.  
  243.  
  244.     ' \/\/\/\/\/\/\/\/\/
  245.     ' Show the Starship
  246.     ' /\/\/\/\/\/\/\/\/\
  247.     _PUTIMAGE (shipX, shipY), Starship
  248.  
  249.     ' \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
  250.     ' Have the background shift left by warpspeed
  251.     ' /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
  252.     Stars(1).x = Stars(1).x - warpSpeed
  253.     Stars(2).x = Stars(2).x - warpSpeed
  254.  
  255.     ' \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
  256.     ' When the background reaches the end reset background
  257.     ' /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
  258.     IF Stars(2).x < 0 THEN
  259.         Stars(1).x = 0
  260.         Stars(2).x = 800
  261.  
  262.         ' \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
  263.         ' Put the second image on the first to keep the animation proper
  264.         ' /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
  265.         _PUTIMAGE (0, 0), Stars(2).image, Stars(1).image
  266.  
  267.         ' \/\/\/\/\/\/\/\/\/\/\/\/\/\/
  268.         ' Add Planets to the animation
  269.         ' /\/\/\/\/\/\/\/\/\/\/\/\/\/\
  270.         Frontier
  271.     END IF
  272.  
  273. SUB Frontier
  274.     ' \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
  275.     ' Reset the background and rotate to make things different
  276.     ' /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
  277.     SELECT CASE INT(4 * RND)
  278.         CASE 0: _PUTIMAGE (0, 0), starBack, Stars(2).image
  279.         CASE 1: _PUTIMAGE (799, 0)-(0, 599), starBack, Stars(2).image
  280.         CASE 2: _PUTIMAGE (0, 599)-(799, 0), starBack, Stars(2).image
  281.         CASE 3: _PUTIMAGE (799, 599)-(0, 0), starBack, Stars(2).image
  282.     END SELECT
  283.  
  284.     ' \/\/\/\/\/\/\/\/\/\/\/\/\/
  285.     ' Choose a Planet to display
  286.     ' /\/\/\/\/\/\/\/\/\/\/\/\/\
  287.     tag1:
  288.     p1 = INT(40 * RND) + 1
  289.     IF Planet(p1).used = 1 THEN GOTO tag1
  290.  
  291.     ' \/\/\/\/\/\/\/\/\/\/\/\/
  292.     ' Get the Width and Height
  293.     ' /\/\/\/\/\/\/\/\/\/\/\/\
  294.     w = Planet(p1).w
  295.     h = Planet(p1).h
  296.  
  297.     ' \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
  298.     ' Make sure planet isn't going off the screen
  299.     ' /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
  300.     x1 = INT((sWidth - w) * RND)
  301.     y1 = INT((sHeight - h) * RND)
  302.  
  303.     ' \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
  304.     ' Set the Planet as used and save the location
  305.     ' /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
  306.     IF PlanetView(1) = 0 THEN
  307.         PlanetView(1) = p1
  308.         'ELSE
  309.         '  PlanetView(3) = p1
  310.     END IF
  311.  
  312.     Planet(p1).x = 800 + x1
  313.     Planet(p1).y = y1
  314.  
  315.     Planet(p1).used = 1
  316.     Planet(p1).spin = INT(2 * RND)
  317.  
  318.     IF INT(2 * RND) = 1 THEN
  319.         tag2:
  320.         p2 = INT(40 * RND) + 1
  321.         IF Planet(p2).used = 1 THEN GOTO tag2
  322.  
  323.         w = Planet(p2).w
  324.         h = Planet(p2).h
  325.  
  326.         IF p2 <> p1 THEN
  327.             IF w < Planet(p1).w AND h < Planet(p1).h THEN
  328.                 x2 = INT((sWidth - w) * RND)
  329.                 y2 = INT((sHeight - h) * RND)
  330.             END IF
  331.         END IF
  332.  
  333.         IF PlanetView(2) = 0 THEN
  334.             PlanetView(2) = p2
  335.             'ELSE
  336.             '  PlanetView(4) = p2
  337.         END IF
  338.  
  339.         Planet(p2).x = 800 + x2
  340.         Planet(p2).y = y2
  341.  
  342.         Planet(p2).used = 1
  343.         Planet(p2).spin = INT(2 * RND)
  344.     END IF
  345.  
  346. SUB ViewPlanet (p, v)
  347.     'w = Planet(p).w
  348.  
  349.     'x = Planet(p).x
  350.     'y = Planet(p).y
  351.     '_PUTIMAGE (x, y), Planet(p).image, 0
  352.  
  353.     'x = x - 2
  354.     'Planet(p).x = x
  355.     '_PRINTSTRING (4, sHeight \ 2 - 8), STR$(x) + "    "
  356.  
  357.     'IF x + w < 0 THEN
  358.     '  BEEP
  359.     '  PlanetView(v) = 0
  360.     '  Planet(p).used = 0
  361.     'END IF
  362.     'EXIT SUB
  363.  
  364.     w = Planet(p).w
  365.     h = Planet(p).h
  366.  
  367.     x1 = Planet(p).x
  368.     x2 = Planet(p).x + w
  369.  
  370.     y1 = Planet(p).y
  371.     y2 = Planet(p).y + h
  372.  
  373.     SELECT CASE Planet(p).r
  374.         CASE 0: _PUTIMAGE (x1, y1), Planet(p).image, 0
  375.         CASE 1: _PUTIMAGE (x2, y1)-(x1, y2), Planet(p).image, 0
  376.         CASE 2: _PUTIMAGE (x1, y2)-(x2, y1), Planet(p).image, 0
  377.         CASE 3: _PUTIMAGE (x2, y2)-(x1, y1), Planet(p).image, 0
  378.     END SELECT
  379.  
  380.     IF Planet(p).spin = 1 THEN
  381.         Planet(p).c = Planet(p).c + 1
  382.  
  383.         IF Planet(p).c = 16 THEN
  384.             Planet(p).c = 0
  385.  
  386.             Planet(p).r = Planet(p).r + 1
  387.             IF Planet(p).r > 3 THEN Planet(p).r = 0
  388.         END IF
  389.     END IF
  390.  
  391.     x1 = x1 - warpSpeed
  392.     Planet(p).x = x1
  393.  
  394.     IF x2 < 0 THEN
  395.         PlanetView(v) = 0
  396.         Planet(p).used = 0
  397.     END IF
  398.  
  399. SUB Framed
  400.     IF RIGHT$(TIME$, 1) = frameTime THEN
  401.         frameCount = frameCount + 1
  402.     ELSE
  403.         frameRate = frameCount
  404.  
  405.         frameCount = 0
  406.         frameTime = RIGHT$(TIME$, 1)
  407.     END IF
  408.  
  409.     _PRINTSTRING (4, 8), STR$(frameRate)
  410.  
  411.  
  412. 'from p5js.bas
  413. FUNCTION map! (value!, minRange!, maxRange!, newMinRange!, newMaxRange!)
  414.     map! = ((value! - minRange!) / (maxRange! - minRange!)) * (newMaxRange! - newMinRange!) + newMinRange!
  415.  
  416.  
Title: Re: Star Backgound
Post by: Petr on June 17, 2018, 05:07:42 am
Very nice original by [banned user] and also modification by Ashish! :-D
Title: Re: Star Backgound
Post by: johnno56 on June 17, 2018, 05:11:38 am
Ok. I have modified ALL of the images. All images now have a transparent background and all 'black' has been replaced by a complimentary colour. All images resized and centered. I ran the program with the modified images and everything looks fine. No missing patches... Cool.

BUT... In the meantime... 'Rotating' planets has been introduced... All of the modified spherical planets 'rotate' just fine. All that have rings look weird when rotating. Suggest that these planets do not rotate.

I have some ideas for rotating ringed planets but it may take some time to work on them.

I have attached all of the modified images. Make a backup copy of the originals then replace them with these....

J

ps: "Attachments and other options" does NOT include a browse to file. I will attempt to include a link. I hope I get this right...

https://www.dropbox.com/s/zgpmn9ly4tnp3bx/planets.zip?dl=0
Title: Re: Star Backgound
Post by: FellippeHeitor on June 17, 2018, 10:13:57 am
Great job, [banned user]. And welcome back to the forum.

Ashish's fire mod definitely adds a fine touch here too.

Here's my humble contribution to the y-axis movement (up/down arrows):
Code: QB64: [Select]
  1. _TITLE "Space the Final Frontier"
  2.  
  3. CONST true = -1, false = NOT true
  4. DIM Touch AS STRING
  5.  
  6. DIM SHARED frameRate AS INTEGER
  7. DIM SHARED frameCount AS INTEGER
  8.  
  9. DIM SHARED frameTime AS STRING
  10. frameTime = RIGHT$(TIME$, 2)
  11.  
  12. DIM SHARED modFire AS _BYTE
  13. modFire = true
  14.  
  15. DIM SHARED fireSizeX, fireSizeY
  16. fireSizeX = 120
  17. fireSizeY = 19
  18.  
  19. DIM SHARED fireBuffer(fireSizeX, fireSizeY), colorPal(255) AS _UNSIGNED LONG, fuelControl
  20. fuelControl = 0.23
  21.  
  22. 'creating our palette for fire
  23. FOR i = 255 TO 0 STEP -1
  24.     IF i <= 255 AND i >= 200 THEN 'white to yellow
  25.         colorPal(i) = _RGB32(map(i, 255, 200, 255, 255), map(i, 255, 200, 255, 242), map(i, 255, 200, 255, 0))
  26.     ELSEIF i <= 201 AND i >= 79 THEN 'yellow to orange
  27.         colorPal(i) = _RGB32(map(i, 201, 79, 255, 221), map(i, 201, 79, 242, 140), map(i, 201, 79, 0, 0))
  28.     ELSEIF i <= 89 AND i >= 79 THEN 'orange to dark orange red
  29.         colorPal(i) = _RGB32(map(i, 89, 79, 221, 183), map(i, 89, 79, 140, 45), map(i, 89, 79, 0, 0))
  30.     ELSEIF i <= 78 AND i >= 0 THEN 'dark orange red to transparent
  31.         colorPal(i) = _RGBA32(map(i, 78, 0, 183, 0), map(i, 78, 0, 45, 0), map(i, 78, 0, 0, 0), map(i, 78, 0, 255, 0))
  32.     END IF
  33.  
  34. ' \/\/\/\/\/\/\/\/\/\/\/\/
  35. ' Screen Width and Height
  36. ' /\/\/\/\/\/\/\/\/\/\/\/\
  37. sWidth = 800
  38. sHeight = 600
  39.  
  40. SCREEN _NEWIMAGE(sWidth, sHeight, 32)
  41.  
  42. ' \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
  43. ' Stars Background and the Starship
  44. ' /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
  45. DIM SHARED starBack AS LONG
  46. DIM SHARED Starship AS LONG
  47.  
  48. ' Stars Background:
  49. ' https://www.qb64.org/forum/index.php?PHPSESSID=fe200737599194549d14a890bf46be14&topic=250.0
  50. starBack = _LOADIMAGE(".\images\Stars.png")
  51. _PUTIMAGE (0, 0), starBack
  52.  
  53. ' Starship:
  54. ' http://www.clipartlord.com/category/space-clip-art/spaceship-clip-art/
  55. Starship = _LOADIMAGE(".\images\Starship.png")
  56. _CLEARCOLOR _RGB(0, 0, 0), Starship
  57.  
  58. ' \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
  59. ' Used to make sure Starship doesn't go offscreen
  60. ' /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
  61. wShip = sWidth - 400
  62. hShip = sHeight - 170
  63.  
  64. ' \/\/\/\/\/\/\/\/\/\/\/\/\/\/
  65. ' Starship Location (Centered)
  66. ' /\/\/\/\/\/\/\/\/\/\/\/\/\/\
  67. shipX = sWidth \ 2 - 200
  68. shipY = sHeight \ 2 - 85
  69.  
  70. ' \/\/\/\/\/\/\/\/\/\/\/
  71. ' Speed of the Starship
  72. ' /\/\/\/\/\/\/\/\/\/\/\
  73. DIM SHARED warpSpeed AS INTEGER
  74. warpSpeed = 2
  75.  
  76. ' \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
  77. ' Celestial Objects (Stars and Planets)
  78. ' /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
  79. TYPE Celestial
  80.     ' Location
  81.     x AS INTEGER
  82.     y AS INTEGER
  83.  
  84.     ' Size
  85.     w AS INTEGER
  86.     h AS INTEGER
  87.  
  88.     ' Rotation
  89.     c AS INTEGER
  90.     r AS INTEGER
  91.  
  92.     ' Planet used
  93.     used AS INTEGER
  94.  
  95.     ' Planet Spins
  96.     spin AS INTEGER
  97.  
  98.     image AS LONG
  99.  
  100. ' \/\/\/\/\/\/\/\/
  101. ' Stars Background
  102. ' /\/\/\/\/\/\/\/\
  103. DIM SHARED Stars(2) AS Celestial
  104.  
  105. Stars(1).x = 0
  106. Stars(2).x = 800
  107.  
  108. Stars(1).image = _NEWIMAGE(800, 600, 32)
  109. _PUTIMAGE (0, 0), starBack, Stars(1).image
  110.  
  111. Stars(2).image = _NEWIMAGE(800, 600, 32)
  112. Starfield
  113. Frontier
  114.  
  115. ' \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
  116. ' Display text while Planets load
  117. ' /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
  118. Touch = "Loading Planet Data...."
  119.  
  120. y = sHeight \ 2 - 8
  121. x = sWidth \ 2 - (LEN(Touch) * 4)
  122. _PRINTSTRING (x, y), Touch
  123.  
  124. DIM SHARED PlanetView(4) AS INTEGER
  125.  
  126. DIM SHARED Planet(40) AS Celestial
  127.  
  128. ' \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
  129. ' Load all the planets (40 total)
  130. ' /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
  131. FOR p = 1 TO 40
  132.     ' Planets:
  133.     ' http://www.clipartlord.com/category/space-clip-art/planets-clip-art/
  134.     Planet(p).image = _LOADIMAGE(".\images\Planet" + RIGHT$("0" + LTRIM$(STR$(p)), 2) + ".png")
  135.     _CLEARCOLOR _RGB(0, 0, 0), Planet(p).image
  136.  
  137.     ' \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
  138.     ' Get the Width and Height of the planet
  139.     ' /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
  140.     Planet(p).w = _WIDTH(Planet(p).image)
  141.     Planet(p).h = _HEIGHT(Planet(p).image)
  142.  
  143. ' \/\/\/\/\/\/\/\/\/\/\/\/\/
  144. ' Starship enters the scene
  145. ' /\/\/\/\/\/\/\/\/\/\/\/\/\
  146. FOR x = -400 TO shipX STEP 10
  147.     IF modFire THEN
  148.         'fire
  149.         FOR fy = 3 TO fireSizeY - 2
  150.             fireBuffer(fireSizeX - 2, fy) = INT(RND * 128) + 128
  151.         NEXT
  152.         FOR fy = 3 TO fireSizeY - 2
  153.             FOR fx = 0 TO fireSizeX - 2
  154.                 fireBuffer(fx, fy) = (fireBuffer(fx + 1, fy - 1) + fireBuffer(fx + 1, fy) + fireBuffer(fx + 2, fy) + fireBuffer(fx + 1, fy + 1)) * (fuelControl + .018327)
  155.         NEXT fx, fy
  156.     END IF
  157.  
  158.     _PUTIMAGE (0, 0), starBack
  159.  
  160.     IF modFire THEN
  161.         'rendering fire
  162.         FOR fy = 0 TO fireSizeY
  163.             FOR fx = 0 TO fireSizeX
  164.                 'PRINT INT(fireBuffer(fx, fy))
  165.                 PSET (fx + x + 115 - fireSizeX + 2, fy + shipY + 100), colorPal(INT(fireBuffer(fx, fy)))
  166.         NEXT fx, fy
  167.     END IF
  168.  
  169.     _PUTIMAGE (x, shipY), Starship
  170.  
  171.     _DISPLAY
  172.     _LIMIT 30
  173.  
  174. ' \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
  175. ' Show the animations until ESC is pressed
  176. ' /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
  177. WHILE Touch <> CHR$(27)
  178.     Background
  179.  
  180.     ' \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
  181.     ' Checks to see if a key is pressed
  182.     ' /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
  183.     Touch = INKEY$
  184.     IF Touch <> "" THEN
  185.         ' \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
  186.         ' Keys 0-9 changes the warpspeed
  187.         ' /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
  188.         IF ASC(Touch) > 47 AND ASC(Touch) < 58 THEN warpSpeed = VAL(Touch)
  189.  
  190.         ' \/\/\/\/\/\/\/\/\/\/\/\/\/\/
  191.         ' M key will add the fire mod
  192.         ' /\/\/\/\/\/\/\/\/\/\/\/\/\/\
  193.         IF UCASE$(Touch) = "M" THEN
  194.             modFire = NOT modFire
  195.         END IF
  196.  
  197.         ' \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
  198.         ' Home key centers the Starship
  199.         ' /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
  200.         IF Touch = CHR$(0) + CHR$(71) THEN
  201.             shipX = sWidth \ 2 - 200
  202.             shipY = sHeight \ 2 - 85
  203.         END IF
  204.  
  205.         ' \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
  206.         ' Up and Down Arrow Keys moves the Starship
  207.         ' /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
  208.         IF Touch = CHR$(0) + CHR$(72) THEN
  209.             yMovement = -3
  210.         END IF
  211.  
  212.         IF Touch = CHR$(0) + CHR$(80) THEN
  213.             yMovement = 3
  214.         END IF
  215.     END IF
  216.  
  217.     shipY = shipY + yMovement
  218.     IF yMovement > 0.5 THEN yMovement = yMovement - .05
  219.     IF yMovement < -0.5 THEN yMovement = yMovement + .05
  220.  
  221.     'Framed
  222.  
  223.     _DISPLAY
  224.     _LIMIT 60
  225.  
  226. FUNCTION map! (value!, minRange!, maxRange!, newMinRange!, newMaxRange!)
  227.     map! = ((value! - minRange!) / (maxRange! - minRange!)) * (newMaxRange! - newMinRange!) + newMinRange!
  228.  
  229. SUB Background
  230.     ' \/\/\/\/\/\/\/\/\/\/\/\/\/\/
  231.     ' Places the stars Backgrounds
  232.     ' /\/\/\/\/\/\/\/\/\/\/\/\/\/\
  233.     _PUTIMAGE (Stars(1).x, 0), Stars(1).image
  234.     _PUTIMAGE (Stars(2).x, 0), Stars(2).image
  235.  
  236.     ' \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
  237.     ' Show planet(s)  (if available)
  238.     ' /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
  239.     FOR v = 1 TO 2
  240.         IF PlanetView(v) > 0 THEN
  241.             ViewPlanet PlanetView(v), v
  242.         END IF
  243.     NEXT
  244.  
  245.     IF modFire THEN
  246.         acc = (warpSpeed + 1) * .001905#
  247.  
  248.         'fire
  249.         FOR fy = 3 TO fireSizeY - 2
  250.             fireBuffer(fireSizeX - 2, fy) = INT(RND * 128) + 128
  251.         NEXT
  252.  
  253.         FOR fy = 3 TO fireSizeY - 2
  254.             FOR fx = 0 TO fireSizeX - 2
  255.                 fireBuffer(fx, fy) = (fireBuffer(fx + 1, fy - 1) + fireBuffer(fx + 1, fy) + fireBuffer(fx + 2, fy) + fireBuffer(fx + 1, fy + 1)) * (fuelControl + acc)
  256.         NEXT fx, fy
  257.  
  258.         'rendering fire
  259.         FOR fy = 0 TO fireSizeY
  260.             FOR fx = 0 TO fireSizeX
  261.                 'PRINT INT(fireBuffer(fx, fy))
  262.                 PSET (fx + shipX + 115 - fireSizeX + 2, fy + shipY + 100), colorPal(INT(fireBuffer(fx, fy)))
  263.         NEXT fx, fy
  264.     END IF
  265.  
  266.     ' \/\/\/\/\/\/\/\/\/
  267.     ' Show the Starship
  268.     ' /\/\/\/\/\/\/\/\/\
  269.     _PUTIMAGE (shipX, shipY), Starship
  270.  
  271.     ' \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
  272.     ' Have the background shift left by warpspeed
  273.     ' /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
  274.     Stars(1).x = Stars(1).x - warpSpeed
  275.     Stars(2).x = Stars(2).x - warpSpeed
  276.  
  277.     ' \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
  278.     ' When the background reaches the end reset background
  279.     ' /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
  280.     IF Stars(2).x < 0 THEN
  281.         Stars(1).x = 0
  282.         Stars(2).x = 800
  283.  
  284.         ' \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
  285.         ' Put the second image on the first to keep the animation proper
  286.         ' /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
  287.         _PUTIMAGE (0, 0), Stars(2).image, Stars(1).image
  288.  
  289.         Starfield
  290.     END IF
  291.  
  292. SUB Frontier
  293.     ' \/\/\/\/\/\/\/\/\/\/\/\/\/
  294.     ' Choose a Planet to display
  295.     ' /\/\/\/\/\/\/\/\/\/\/\/\/\
  296.     'tag1:
  297.     p1 = INT(40 * RND) + 1
  298.     'IF Planet(p1).used = 1 THEN GOTO tag1
  299.  
  300.     ' \/\/\/\/\/\/\/\/\/\/\/\/
  301.     ' Get the Width and Height
  302.     ' /\/\/\/\/\/\/\/\/\/\/\/\
  303.     w = Planet(p1).w
  304.     h = Planet(p1).h
  305.  
  306.     ' \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
  307.     ' Make sure planet isn't going off the screen
  308.     ' /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
  309.     x1 = INT((sWidth - w) * RND)
  310.     y1 = INT((sHeight - h) * RND)
  311.  
  312.     ' \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
  313.     ' Set the Planet as used and save the location
  314.     ' /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
  315.     PlanetView(1) = p1
  316.  
  317.     Planet(p1).x = 800 + x1
  318.     Planet(p1).y = y1
  319.  
  320.     Planet(p1).used = 1
  321.     IF p1 < 29 THEN Planet(p2).spin = INT(2 * RND)
  322.  
  323.     IF INT(2 * RND) = 1 THEN
  324.         p2 = INT(40 * RND) + 1
  325.  
  326.         w = Planet(p2).w
  327.         h = Planet(p2).h
  328.  
  329.         IF p2 <> p1 THEN
  330.             IF w < Planet(p1).w AND h < Planet(p1).h THEN
  331.                 x2 = INT((sWidth - w) * RND)
  332.                 y2 = INT((sHeight - h) * RND)
  333.             END IF
  334.         END IF
  335.  
  336.         PlanetView(2) = p2
  337.  
  338.         Planet(p2).x = 800 + x2
  339.         Planet(p2).y = y2
  340.  
  341.         Planet(p2).used = 1
  342.  
  343.         IF p2 < 29 THEN Planet(p2).spin = INT(2 * RND)
  344.     END IF
  345.  
  346. SUB Starfield
  347.     ' \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
  348.     ' Reset the background and rotate to make things different
  349.     ' /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
  350.     SELECT CASE INT(4 * RND)
  351.         CASE 0: _PUTIMAGE (0, 0), starBack, Stars(2).image
  352.         CASE 1: _PUTIMAGE (799, 0)-(0, 599), starBack, Stars(2).image
  353.         CASE 2: _PUTIMAGE (0, 599)-(799, 0), starBack, Stars(2).image
  354.         CASE 3: _PUTIMAGE (799, 599)-(0, 0), starBack, Stars(2).image
  355.     END SELECT
  356.  
  357. SUB ViewPlanet (p, v)
  358.     w = Planet(p).w
  359.     h = Planet(p).h
  360.  
  361.     x1 = Planet(p).x
  362.     x2 = Planet(p).x + w
  363.  
  364.     y1 = Planet(p).y
  365.     y2 = Planet(p).y + h
  366.  
  367.     SELECT CASE Planet(p).r
  368.         CASE 0: _PUTIMAGE (x1, y1), Planet(p).image, 0
  369.         CASE 1: _PUTIMAGE (x2, y1)-(x1, y2), Planet(p).image, 0
  370.         CASE 2: _PUTIMAGE (x1, y2)-(x2, y1), Planet(p).image, 0
  371.         CASE 3: _PUTIMAGE (x2, y2)-(x1, y1), Planet(p).image, 0
  372.     END SELECT
  373.  
  374.     IF Planet(p).spin = 1 THEN
  375.         Planet(p).c = Planet(p).c + 1
  376.  
  377.         IF Planet(p).c = 16 THEN
  378.             Planet(p).c = 0
  379.  
  380.             Planet(p).r = Planet(p).r + 1
  381.             IF Planet(p).r > 3 THEN Planet(p).r = 0
  382.         END IF
  383.     END IF
  384.  
  385.     x1 = x1 - warpSpeed
  386.     Planet(p).x = x1
  387.  
  388.     IF x1 + w < 0 THEN
  389.         PlanetView(v) = 0
  390.         Planet(p).used = 0
  391.  
  392.         ' \/\/\/\/\/\/\/\/\/\/\/\/\/\/
  393.         ' Add Planets to the animation
  394.         ' /\/\/\/\/\/\/\/\/\/\/\/\/\/\
  395.         Frontier
  396.     END IF
  397.  
  398. SUB Framed
  399.     IF RIGHT$(TIME$, 1) = frameTime THEN
  400.         frameCount = frameCount + 1
  401.     ELSE
  402.         frameRate = frameCount
  403.  
  404.         frameCount = 0
  405.         frameTime = RIGHT$(TIME$, 1)
  406.     END IF
  407.  
  408.     _PRINTSTRING (4, 8), STR$(frameRate)
  409.  
Title: Re: Star Backgound
Post by: bplus on June 17, 2018, 11:16:03 am
Not suppose to have fire in space but Ashish application is really good!

If you want even more helm control, I have updated RotoZoom:
https://www.qb64.org/forum/index.php?topic=278.0
Title: Re: Star Backgound
Post by: Ashish on June 17, 2018, 11:55:41 am
Thanks Guys! :D
I thought that the fire was not looking good in space. It must be somewhat neon light blue in color to give a nitro booster effect to spaceship.
Title: Re: Star Backgound
Post by: bplus on June 18, 2018, 09:29:40 am
Ha! I thought it was Love that makes the worlds go round.

How does it make you feel with all this planet making and turning? :D
Title: Re: Star Backgound
Post by: bplus on June 18, 2018, 12:34:11 pm
Yeah, they made my head spin but a view at pole of earth would show same spinning (maybe not so fast), actually I was offering RotoZoom2 for helm control to point ship in different directions, but then you'd have to make star background adjust to new direction. You could then draw an infinite space by generating new star systems... extending the universe out to infinity... how do you feel about that? ;D Then the trick would be to repeat the same star pattern if you turn the ship around!
Title: Re: Star Backgound
Post by: bplus on June 18, 2018, 02:47:14 pm
Oh hey a crazy idea, make a rectangular map of the planet, code it to a cylinder (connect the left edge to the right with mod) and then map the upper and lower edges to a single point, the poles, add snow and spin.
Title: Re: Star Backgound
Post by: johnno56 on June 18, 2018, 06:10:32 pm
bplus,

I had that thought as well. A rectangular image converted to an animated sphere. Already done that ages ago... Gimp has the ability to do that and to generate an animated gif. It's easy enough to extract the many 'frames' but would be even easier if QB64 has the ability to display animated gif's.

If I can find my old tutorial I will post it... Hang on... I can't. "attachments' do not cater for files... Is someone going to fix that little issue? Never mind. I create a link. Give me a little while to find my files... lol

J
Title: Re: Star Backgound
Post by: johnno56 on June 18, 2018, 06:37:09 pm
Done.

Here is the link to the tutorial: http://www.paintshopprotutorials.co.uk/html/spinning_globe_animation_gimp.html

Here are the links to the files I used.
https://www.dropbox.com/s/ain0yxptec30i1b/flag.png?dl=0 (image)
https://www.dropbox.com/s/0ofsdv7xnihe2kv/flag.gif?dl=0 (gif - 100 frames)

The whole process took only a few minutes. (NB: I deliberately used a 'square' image. Produced a better globe)

I hope this helps...

J

ps: Just finished "Mars". Enjoy.

https://www.dropbox.com/s/x2puc7x1x315r2a/mars.png?dl=0 (image)
https://www.dropbox.com/s/z1yd3uj57cgfuch/mars.gif?dl=0 (gif - 100 frames)
Title: Re: Star Backgound
Post by: bplus on June 18, 2018, 11:50:55 pm
Hi Johnno,

Where are you getting the rectangle images?

Mars is fantastic except for the unseemly seam. There is probably some way to blend the two ends mainly with colors?

I started looking into converting a rectangle to sphere image and learned word tessellation and triangle strips. Saw some fairly reasonable trig equations for the points. Maybe halfway home?
http://hugi.scene.org/online/hugi27/hugi%2027%20-%20coding%20corner%20polaris%20sphere%20tessellation%20101.htm
Title: Re: Star Backgound
Post by: johnno56 on June 19, 2018, 12:35:04 am
Rectangular images? Google. "flat map mars" etc. Using Gimp's in built Sphere Animator makes a 'traditional' sphere if the image is 'stretched' out to a square. Any image/texture can be used. The more frames used (10 frames per second is the slowest) will give you a smoother rotation at the cost of more memory.... The Mars example works quite well except for, as you rightly pointed out, the 'seam'. Gimp is quite capable in producing 'seamless' images, but for an image as complex as Mars, may be a 'bit of a stretch' - no pun intended... lol

Here is a better one by Nasa:

https://www.dropbox.com/s/jix1n1mhswnp2q2/mars0_src.jpg?dl=0 (image)
https://www.dropbox.com/s/u1p8ueq4dlj6ef2/mars2.gif?dl=0 (gif - 100 frames)
Title: Re: Star Backgound
Post by: SirCrow on June 19, 2018, 01:17:51 am
Very nice.  I'm using a much simpler stars BG in the Asteroids-based game I'm currently making.  I want to upload it as a work in progress, but I'm confused about how the whole Linux thing works.  With Windows, I'd compile it, there would be the .exe file, and it would be super-simple to run it.  In Ubuntu, I don't even see an extension on the filename.  I definitely want the game usable in both Windows and Linux!  Should I just let the user take the source and compile it?  Am I over-complicating this?

I love the way my stars move independently of the separate nebula/cloud BG as the ship flies around.  I hope I'll get to share it here soon.
Title: Re: Star Backgound
Post by: bplus on June 19, 2018, 09:02:47 am
Hi SirCrow,

I sure don't need the exe (Windows) and much prefer the source to compile.
Title: Re: Star Backgound
Post by: bplus on June 19, 2018, 09:35:09 am
Hi [banned user],

Not bad! I like the detail but that seam...
Title: Re: Star Backgound
Post by: Ashish on June 19, 2018, 11:17:09 am
Hi [banned user]!
For more realistic planet, you can render a Sphere with planet texture using OpenGL.
Title: Re: Star Backgound
Post by: bplus on June 19, 2018, 12:02:36 pm
Hi [banned user]!
For more realistic planet, you can render a Sphere with planet texture using OpenGL.

Hi Ashish,

I am pretty sure [banned user] would like help for that, I know I would...


Hi [banned user],

I was thinking drawing different phases of crescent moons in shady and light transparent colors in separate destination and layer them atop the circle planet. Draw circle in transparent light or dark then block out with black circle so only transparent crescent remains. (Thinking like a lazy, crazy coder?)
Title: My Asteroids-like Space Game
Post by: SirCrow on June 19, 2018, 12:19:12 pm
My work-in-progress game is finally ready to share:
http://qb64.thejoyfulprogrammer.com/showthread.php?tid=1349&rndtime=15294166471450489226

As to Linux/Ubuntu and running executable files, I really wish someone would tell me how to run them without involving the Terminal.
Title: Re: Star Backgound
Post by: bplus on June 19, 2018, 12:55:52 pm
OK [banned user] it works a little, not quite what I had in mind (need color that stays transparent for blackout) but I managed this:
https://www.qb64.org/forum/index.php?topic=286.0
Title: Re: Star Backgound
Post by: johnno56 on June 19, 2018, 05:45:16 pm
SirCrow,

To run a compiled executable can be as simple as double-clicking the executable or as involved as creating a script and launcher. Either process will avoid 'The Terminal' (insert dramatic music here... lol)

If memory serves correctly... From within the QB64 IDE select 'Run" then check "Output EXE to source folder". Once that is done, pressing F11, will produce ONLY the executable. From there you can either go to the source folder and double-click or create a Launcher.

I tested the F11 option on my machine and it produced the executable as advertised. I double-clicked the executable... and an image appeared for just a moment... then vanished. Break out 'The Terminal' (insert dramatic music here). Ran the executable, so I can see any errors, and errors there were.

---------------------------------------------------------------------------------------------------------------------------------------------------
john@john-H81M-DS2 ~/basic/qb64/starblast $ ./StarBlast_2018-6-19
[xcb] Unknown request in queue while dequeuing
[xcb] Most likely this is a multi-threaded client and XInitThreads has not been called
[xcb] Aborting, sorry about that.
StarBlast_2018-6-19: ../../src/xcb_io.c:179: dequeue_pending_request: Assertion `!xcb_xlib_unknown_req_in_deq' failed.
Aborted
---------------------------------------------------------------------------------------------------------------------------------------------------

At least it was apologetic... lol

Looks like, for me anyway, I cannot run the compiled executable because I am using a multi-core machine... If your machine is a single core, give it a try, and let me know how you get on?

Sorry I couldn't be of better help...

J
Title: Re: Star Backgound
Post by: odin on June 19, 2018, 08:36:14 pm
This topic started as an off-topic post, as it contained a single image not related to any QB64 code. The best place for that would be the off-topic board, as already explained.

As it progressed and became a collaborative program, it makes sense to have it again in the Programs board (as just moved) so you members can continue improving upon the collective effort.

Rules remain the same.

Love,

Odin.
Title: Re: Star Backgound
Post by: bplus on June 20, 2018, 09:44:34 am
Gremlin?
Code: QB64: [Select]
  1. DIM SHARED texMask AS LONG
  2. texMask = _NEWIMAGE(texWidth + 4, texHeight)  'plus 4 on width
  3.  

Nice demo of mask! Great improvements.
Title: Re: Star Backgound
Post by: bplus on June 20, 2018, 10:14:41 am
Johnno's mars link:
https://www.dropbox.com/s/jix1n1mhswnp2q2/mars0_src.jpg?dl=0

has a much better blended seam, way less obvious! though the detail isn't quite as sharp.

BTW I tried -1 and -2 on image widths to reduce black seam and started getting a gremlin on the right side!
Title: Re: Star Backgound
Post by: SirCrow on June 20, 2018, 06:24:14 pm
. . .
---------------------------------------------------------------------------------------------------------------------------------------------------
john@john-H81M-DS2 ~/basic/qb64/starblast $ ./StarBlast_2018-6-19
[xcb] Unknown request in queue while dequeuing
[xcb] Most likely this is a multi-threaded client and XInitThreads has not been called
[xcb] Aborting, sorry about that.
StarBlast_2018-6-19: ../../src/xcb_io.c:179: dequeue_pending_request: Assertion `!xcb_xlib_unknown_req_in_deq' failed.
Aborted
---------------------------------------------------------------------------------------------------------------------------------------------------

At least it was apologetic... lol

Looks like, for me anyway, I cannot run the compiled executable because I am using a multi-core machine... If your machine is a single core, give it a try, and let me know how you get on?

Sorry I couldn't be of better help...

J

Indeed, mine is also a mult-core machine!  So no simply click-to-run, then, I guess.  What the heck is XInitThreads, anyway?  Where can I get me one of those??  Probably wouldn't solve the issue anyway.  I've had that error msg. before.  Thanks for the attention, Johnno.  [Where are the smileys on this thing?]
Title: Re: Star Backgound
Post by: johnno56 on June 20, 2018, 08:40:50 pm
"What the heck is XInitThreads, anyway?  Where can I get me one of those??"

I went to the x.org/archives and found THIS description... Hold onto your hat.

"The XInitThreads function initializes Xlib support for concurrent threads. This function must be the first Xlib function a multi-threaded program calls, and it must complete before any other Xlib call is made. This function returns a nonzero status if initialization was successful; otherwise, it returns zero. On systems that do not support threads, this function always returns zero.

It is only necessary to call this function if multiple threads might use Xlib concurrently. If all calls to Xlib functions are protected by some other access mechanism (for example, a mutual exclusion lock in a toolkit or through explicit client programming), Xlib thread initialization is not required. It is recommended that single-threaded programs not call this function."

I don't know about you, but as for me, this was WAY over my head. I think I would have difficulty understanding this even if it used simple English... I'm still none the wiser... Do you STILL want one?  lol  :D
Title: Re: XInitThreads (Multi-thread systems)
Post by: SirCrow on June 20, 2018, 08:59:36 pm
Seriously, if there's a way to install something, or whatever, and get good results from it, I'm willing to try.

Lately, I've had some experience trying to get things to work in my Ubuntu installation.  I've had to type, copy, paste commands into that dreaded little Terminal window, and sometimes it actually makes things better!  If there's something I can install, using that method or other, I want to know about it.

"It is recommended that single-threaded programs not call this function"So, naturally, the prog. I want to run insists on calling this function!
Title: Re: Star Backgound
Post by: johnno56 on June 20, 2018, 09:09:02 pm
Johnno's mars link:
https://www.dropbox.com/s/jix1n1mhswnp2q2/mars0_src.jpg?dl=0

has a much better blended seam, way less obvious! though the detail isn't quite as sharp.

BTW I tried -1 and -2 on image widths to reduce black seam and started getting a gremlin on the right side!


"isn't quite as sharp" - Reason being: The original image was over 2000 pixels wide. If the image was stretched to 2000x2000 it would take a huge amount of time to produce a globe of that size. The image was scaled down to 480x480, and as such, detail was sacrificed for time...

"Gremlin"?

I just had a crazy thought. (Stop laughing!) I hope that these animations are not going to be used in the demo... Can you imagine 27 or 28 planets processing 100 images each at a rate of 10 frames per second? That will be some serious lag time! Of course, I can reduce the number of frames, but it would make the planets spin like a top... lol
Title: Re: XInitThreads (Multi-thread systems)
Post by: johnno56 on June 20, 2018, 09:18:16 pm
Seriously, if there's a way to install something, or whatever, and get good results from it, I'm willing to try.

Lately, I've had some experience trying to get things to work in my Ubuntu installation.  I've had to type, copy, paste commands into that dreaded little Terminal window, and sometimes it actually makes things better!  If there's something I can install, using that method or other, I want to know about it.

"It is recommended that single-threaded programs not call this function"So, naturally, the prog. I want to run insists on calling this function!

If I have read the description properly, there is nothing to install, as all Linux OS's have the Xlib already. It is THE first library called when booting. Without it, we would be staring at a blank screen. I think the problem is that a "single-threaded application is calling for this function (multi-threaded Xlib)?".

I have no clue what-so-ever as to know where to even begin to fix this one...
Title: Re: Star Backgound
Post by: johnno56 on June 21, 2018, 09:47:35 am
Very nicely done!

I had to reduce the "limit" to '30'.  The wee beastie was spinning SO fast that I almost went cross-eyed watching it... lol
Title: Re: Star Backgound
Post by: bplus on June 21, 2018, 10:12:59 pm
Sphere Sim.bas

OK finally got this working as I had in mind but the effect is less than impressive. Still there is enough compression of image around edges specially at the equator that it does begin to take on more of a hemisphere look and less flat.

More comments in .bas file, using [banned user]'s latest Mars image:
Title: Re: Star Backgound
Post by: johnno56 on June 29, 2018, 05:34:23 am
To quote Darth Vader, Star Wars: Episode V - The Empire Strikes Back 1980, "Impressive. Most impressive."
Title: Re: Star Backgound
Post by: Petr on June 29, 2018, 10:33:52 am
Very nice work, Bplus!
Title: Re: Star Backgound
Post by: bplus on June 29, 2018, 04:44:33 pm
Thanks guys!

I tried a more dramatic grid to mount the sphere on but it had too many squares less than pixel so failed to look circular.

I didn't think anyone was interested due to lack of response, maybe I will try again with another frame idea.
Title: Re: Star Backgound
Post by: johnno56 on June 30, 2018, 12:19:19 am
Does QB64 have anything similar to sdlbasic's 'blt()' command. Basically, load a 'strip' of images, 'grab' a frame, display it, continue to the end of the strip and return to the start...  If not, maybe some clever clogs, can whip up a function? Just curious...

I need more coffee... There are barely any traces of this mornings cup... lol... Could explain the insane suggestion... lol.

J
Title: Re: Star Backgound
Post by: FellippeHeitor on June 30, 2018, 01:14:43 am
Nothing similar builtin. You guys will have to cook your own.
Title: Re: Star Backgound
Post by: Petr on June 30, 2018, 03:58:44 am
BPlus, less work would you have if you use OpenGL for the sphere and an external help.c file, OpenGL has a direct command for the sphere. Do you remember the program "Planets.bas" from Ashish?

Johnno56: What exactly do you mean by this command? Do I understand that you will have a set of pictures and want to make a video loop? Something like this?
Title: Re: Star Backgound
Post by: johnno56 on June 30, 2018, 05:21:42 am
Petr,

Could not view the video. Youtube jumped on it... But anyway you are pretty much right. Imagine the frames of a film. Each frame is part of the animation process. The "Strip" of images are stored and each frame is captured and displayed in sequence. If the animation is an explosion then the sequence is run just once. A planet, set it up to continuously in a loop.

The command is: blt(slot, sx, sy, sw, sh, dx, dy)
slot: where the image is stored
sx: Source X coordinate
sy: Source Y coordinate
sw: Source image width
sh: Source image height
dx: Destination screen X coordinate
dy: Destination screen Y coordinate

I suppose the 'slot' can be simulated by using QB64's GET command and capture each frame... I think... Not too sure about that...
I know with sdlbasic it more efficient to animate a sprite that way....

Just wondering if QB64 could do something like that...

J
Title: Re: Star Backgound
Post by: Petr on June 30, 2018, 05:56:32 am
Hi Johnno, of course, QB64 know do it. Better as GET is _PUTIMAGE. Try my sources here:
Title: Re: Star Backgound
Post by: Petr on June 30, 2018, 06:18:42 am
TSo imagine someone saying my own video for copyright infringement to Yotube. I have not seen a bigger stupidity in my life. :-D This are "intelligent algorhytms" Youtube.
Title: Re: Star Backgound
Post by: johnno56 on June 30, 2018, 06:53:09 am
I want to thank you for the programs. I am having difficulty following them. I am still learning QB64 and a lot of the coding goes over my head. I think I maybe over stretching my abilities in trying to duplicate an sdlbasic command into a qb64 function. I thought it might be a simple "swap this for that" and it would be finished... Obviously "my" version of simple means extremely hard for me... lol

I think I may have to stick with what I know best... the simple stuff... I'm really sorry for wasting your time on this one. I obviously did not this this one through...

J
Title: Re: Star Backgound
Post by: Petr on June 30, 2018, 07:08:51 am
Johnno56, I can try to rewrite it if you give me your code in SDL. I'm not saying I'll do it, but I can try it after I come back if you want.
Title: Re: Star Backgound
Post by: Petr on June 30, 2018, 07:37:27 am
This maybe help you more:

Code: QB64: [Select]
  1. 'The command is: blt(slot, sx, sy, sw, sh, dx, dy)
  2. 'slot: where the image is stored
  3. 'sx: Source X coordinate
  4. 'sy: Source Y coordinate
  5. 'sw: Source image width
  6. 'sh: Source image height
  7. 'dx: Destination screen X coordinate
  8. 'dy: Destination screen Y coordinate
  9. '-----------------------------------------------
  10.  
  11.  
  12. 'create source image: (165 frames contains number)
  13.  
  14. source& = _NEWIMAGE(800, 600, 256)
  15. _DEST source& 'after this i write to graphic screen source&, but is unvisible!
  16. FOR y = 0 TO 800 STEP 40
  17.     FOR x = 0 TO 600 STEP 60
  18.         frame = frame + 1
  19.         LINE (x, y)-(x + 59, y + 39), , B
  20.         _PRINTSTRING (x + 5, y + 8), STR$(frame)
  21. NEXT x, y
  22.  
  23. 'show source:
  24. SCREEN source&
  25.  
  26. 'as i see, _Putimage can be the same as blt?:
  27. SCREEN _NEWIMAGE(320, 240, 256)
  28.  
  29.  
  30. FOR ShowY = 0 TO 800 STEP 40
  31.     FOR ShowX = 0 TO 600 STEP 60
  32.         _PUTIMAGE (140, 130), source&, 0, (ShowX, ShowY)-(ShowX + 59, ShowY + 39)
  33.         SLEEP
  34.     NEXT ShowX
  35. NEXT ShowY
  36.  
Title: Re: Star Backgound
Post by: Petr on June 30, 2018, 07:39:09 am
        _PUTIMAGE 'full source image to fit full destination area after _SOURCE and _DEST are set
       

        _PUTIMAGE , sourceHandle&, destHandle& 'size full source to fit full destination area
       

        _PUTIMAGE (dx1, dy1), sourceHandle&, destHandle& 'full source to top-left corner destination position
       

        _PUTIMAGE (dx1, dy1)-(dx2, dy2), sourceHandle&, destHandle& 'size full source to destination coordinate area
       

        _PUTIMAGE (dx1, dy1), sourceHandle&, destHandle&, (sx1, sy1)-(sx2, sy2) 'portion of source to the top-left corner of the destination page
       

        _PUTIMAGE , sourceHandle&, destHandle&, (sx1, sy1)-(sx2, sy2) 'portion of source to full destination area
       

        _PUTIMAGE (dx1, dy1)-(dx2, dy2), sourceHandle&, destHandle&,(sx1, sy1) 'right side of source from top-left corner to destination
       
Title: Re: Star Backgound
Post by: johnno56 on June 30, 2018, 08:46:35 am
Petr,

I have attached the program and images. I made this in mid December of 2016. The images are crude but they serve the purpose of demo.

Sdlbasic does have the ability to create an executable, the only problem is, I am using Linux and the executable is OS specific.

J

I hope this helps...
Title: Re: Star Backgound
Post by: bplus on June 30, 2018, 10:02:39 am
I love it when I translate code from one Basic to another without a single error!
Code: QB64: [Select]
  1. _TITLE "Walking Man trans by bplus started 2018-06-30"
  2. 'QB64 version 2017 1106/82 (the day before they switched to version 1.2)
  3. CONST xmax = 800
  4. CONST ymax = 600
  5. SCREEN _NEWIMAGE(xmax, ymax, 32)
  6. _SCREENMOVE 360, 60
  7.  
  8. walk& = _LOADIMAGE("walking720x146.png") ' 8 positions at 90 x 146   walk& is same as slot number
  9. manW = 90 'width of man image
  10. manH = 146 'height of man image
  11. manN = 0 'man number 0 to 7 as walks = nSteps mod 8
  12. nSteps = 0
  13. manY = (ymax - manH) \ 2 'place top man image at manY always as walks across the screen
  14. manX = -manW 'start off screen by 1 manW  manX is x location on screen of man
  15.  
  16. WHILE 0 = 0
  17.     CLS
  18.     ' blt(1, x*90, 0, 90, 146, movex, 45)
  19.     '
  20.     '   blt(sprite number,starting x position, starting y position, image width, image height, destination x, and y)
  21.     '
  22.     '   (I prefer a strip of characters. Others may use a 'grid' of characters.)
  23.     '
  24.     '   Sprite #1 is the 'walking' strip of characters
  25.     '
  26.     '   when x = 0 it will grab the first image locate at x*90 with a width of 90px and a height of 146px
  27.     '   and display it at 'movex'x and 45y. Perform a short delay; increment to the next image; If the
  28.     '   image grabbed is greater than 7 (the last image) then reset the image count to 0 (first image).
  29.     '   move the curent image 5 pixels to the right. If the image moves off screen, make it reappear on
  30.     '   the other side. Continue doing this until the escape key is pressed.
  31.  
  32.  
  33.     '' _PUTIMAGE [STEP] [(dx1, dy1)-[STEP][(dx2, dy2)]][, sourceHandle&][, destHandle&][, ][STEP][(sx1, sy1)[-STEP][(sx2, sy2)]][_SMOOTH]
  34.  
  35.     'THE SKINNY: (notice the unintuitive positions of source handle and destination handle)
  36.     'destination coordinates:  (x, y)-(x2, y2)  <<<< syntax
  37.     'then source (image) handle (walk),
  38.     'then destination handle = 0 for screening, then coordinates of image in
  39.     'finally source coordinates off image of image handle:  (x, y)-(x2, y2)  <<<< syntax
  40.  
  41.     _PUTIMAGE (manX, manY)-STEP(manW, manH), walk&, 0, (manN * 90, 0)-STEP(manW, manH)
  42.     manN = (manN + 1) MOD 8 'increase image index until hit 7 then back to 0
  43.     manX = manX + 10
  44.     IF manX >= xmax THEN manX = -manW 'move man back to left side of screen when hit right side
  45.     _DISPLAY 'like   waitvbl(100) in sdlbas
  46.     _LIMIT 10 'like wait(100) this limits displays to 10 per second
  47.  
  48.  
Title: Re: Star Backgound
Post by: bplus on June 30, 2018, 10:07:41 am
Well didn't need nSteps but can't remove it now. ;(

Too bad I can't make posts without single error! ;D
Title: Re: Star Backgound
Post by: bplus on June 30, 2018, 10:25:31 am
OH hey! Who can have man walk across Mars, first! ?

Or use Mars as a sort of treadmill?
Title: Re: Star Backgound
Post by: Petr on June 30, 2018, 03:12:05 pm
Hi Johnno56. I see that BPlus  tried it too. So here is my version:

Code: QB64: [Select]
  1. '
  2. '   Walking
  3. '
  4.  
  5. 'setDisplay(1024,232,32,1)
  6. SCREEN _NEWIMAGE(1024, 232, 32) ' (this is _DEST 0, or 0 in use with _PUTIMAGE)
  7. movex = -90
  8.  
  9. 'loadImage("assets/walking720x146.png",1)
  10. source& = _LOADIMAGE(".\assets\walking720x146.png", 32)
  11.  
  12.  
  13.  
  14. x = 0
  15. WHILE 0 = 0
  16.     CLS
  17.     '    blt(1,x*90,0,90,146,movex,45)
  18.     _PUTIMAGE (movex, 45), source&, 0, (x * 90, 0)-(x * 90 + 90, 146)
  19.     '
  20.     '   blt(sprite number,starting x position, starting y position, image width, image height, destination x, and y)
  21.     '
  22.     '   (I prefer a strip of characters. Others may use a 'grid' of characters.)
  23.     '
  24.     '   Sprite #1 is the 'walking' strip of characters
  25.     '
  26.     '   when x = 0 it will grab the first image locate at x*90 with a width of 90px and a height of 146px
  27.     '   and display it at 'movex'x and 45y. Perform a short delay; increment to the next image; If the
  28.     '   image grabbed is greater than 7 (the last image) then reset the image count to 0 (first image).
  29.     '   move the curent image 5 pixels to the right. If the image moves off screen, make it reappear on
  30.     '   the other side. Continue doing this until the escape key is pressed.
  31.     '    waitvbl()
  32.     '   wait(100)
  33.     _DELAY .1
  34.  
  35.     x = x + 1
  36.     '    if x > 7 then: x = 0: end if
  37.     IF x > 7 THEN x = 0
  38.     movex = movex + 5
  39.     '    if movex > 1024 then: movex = -90: end if
  40.     IF movex > 1024 THEN movex = -90
  41.  
  42.     'if key(27) then: exit while: end if
  43.     IF _KEYHIT = 27 THEN EXIT WHILE
  44. _FREEIMAGE source&
  45.  
Title: Re: Star Backgound
Post by: Petr on June 30, 2018, 03:56:12 pm
And here  walks to and fro:

Code: QB64: [Select]
  1.  
  2.  
  3. '
  4. '   Walking
  5. '
  6.  
  7. 'setDisplay(1024,232,32,1)
  8. SCREEN _NEWIMAGE(1024, 232, 32) ' (this is _DEST 0, or 0 in use with _PUTIMAGE)
  9. movex = -90
  10.  
  11. 'loadImage("assets/walking720x146.png",1)
  12. source& = _LOADIMAGE(".\assets\walking720x146.png", 32)
  13. source2& = ReverseImage&(source&)
  14.  
  15. movestep = 5
  16. x = 0
  17. WHILE 0 = 0
  18.     CLS
  19.     '    blt(1,x*90,0,90,146,movex,45)
  20.     IF walk = 0 THEN _PUTIMAGE (movex, 45), source&, 0, (x * 90, 0)-(x * 90 + 90, 146)
  21.     IF walk = 1 THEN _PUTIMAGE (movex, 45), source2&, 0, (x * 90, 0)-(x * 90 + 90, 146)
  22.     '
  23.     '   blt(sprite number,starting x position, starting y position, image width, image height, destination x, and y)
  24.     '
  25.     '   (I prefer a strip of characters. Others may use a 'grid' of characters.)
  26.     '
  27.     '   Sprite #1 is the 'walking' strip of characters
  28.     '
  29.     '   when x = 0 it will grab the first image locate at x*90 with a width of 90px and a height of 146px
  30.     '   and display it at 'movex'x and 45y. Perform a short delay; increment to the next image; If the
  31.     '   image grabbed is greater than 7 (the last image) then reset the image count to 0 (first image).
  32.     '   move the curent image 5 pixels to the right. If the image moves off screen, make it reappear on
  33.     '   the other side. Continue doing this until the escape key is pressed.
  34.     '    waitvbl()
  35.     '   wait(100)
  36.     _DELAY .1
  37.  
  38.     ' IF walk = 0 THEN x = x + 1 ELSE x = x - 1
  39.     IF walk = 0 THEN x = x + 1: IF x > 7 THEN x = 0
  40.     IF walk = 1 THEN x = x - 1: IF x < 0 THEN x = 7
  41.     '    if x > 7 then: x = 0: end if
  42.  
  43.     movex = movex + movestep
  44.     '    if movex > 1024 then: movex = -90: end if
  45.     IF movex > 1024 THEN
  46.         IF walk = 0 THEN walk = 1: movestep = -5
  47.     END IF
  48.     IF movex < -90 THEN walk = 0: movestep = 5
  49.     'if key(27) then: exit while: end if
  50.     IF _KEYHIT = 27 THEN EXIT WHILE
  51. _FREEIMAGE source&
  52.  
  53.  
  54.  
  55. FUNCTION ReverseImage& (image AS LONG)
  56.     H = _HEIGHT(image&)
  57.     W = _WIDTH(image&)
  58.     IF _PIXELSIZE(image&) <= 1 THEN D = 256 ELSE D = 32
  59.     ReverseImage& = _NEWIMAGE(W, H, D)
  60.     _MAPTRIANGLE (0, 0)-(W, 0)-(0, H), image& TO(W, 0)-(0, 0)-(W, H), ReverseImage&
  61.     _MAPTRIANGLE (0, H)-(W, H)-(W, 0), image& TO(W, H)-(0, H)-(0, 0), ReverseImage&
  62.  
Title: Re: Star Backgound
Post by: johnno56 on June 30, 2018, 06:00:30 pm
Thanks guys.

I would not have had a snowball's chance of figuring out all that 'source' stuff...

'bplus': Thank you for the comments. Puts my chaotic thoughts into some semblance of order... lol

'petr': Two things. 1. Reverseimage! Cool. and 2. You are the first person that I know of that uses the correct phrase, "to and fro". Cool...

Now. Who wants to make him sing and dance in colour? Nah. Kidding. Forget the singing! Still kidding. Run and dance... lol

Thanks for the help guys. Much appreciated.

J
Title: Re: Star Backgound
Post by: bplus on July 01, 2018, 10:26:08 am
Hi Johnno,

Just for clarification, the translation of Walking Man demo does Run on your system and QB64 version now?

I was reading over an old _PUTIMAGE() thread at TJP and see that your system or QB64 version was failing to load images. That is fixed now, correct?

I had posted another demo using _PUTIMAGE there working with Cyber's font sheet not having read the original posts, now having read those posts, found your loading image problem. That's why I ask if that problem is fixed, I am curious what fixed it?
Title: Re: Star Backgound
Post by: johnno56 on July 01, 2018, 10:57:29 am
Hi bplus,

You are correct. Both yours and Petr's translation run on my machine. As to the images not loading, I'll have to go back an search for it, but at this time I cannot recall why the images were having difficulties. I'll check it out and get back to you.

J
Title: Re: Star Backgound
Post by: johnno56 on July 01, 2018, 11:08:34 am
I just read through the postings on TJP and I'm still as confused as I was then. Chances are it was probably due to a stupid typo on my part. The only thing I can think of was that Steve had mentioned something about a suspect version of qb64 that had messed up line endings. Since then I have downloaded the current version of qb64 and the problem has not returned. But I still suspect a typo....

J
Title: Re: Star Backgound
Post by: bplus on July 01, 2018, 12:24:52 pm
You know after I posted my question, I might have found an answer to the confusion.

It is about saving the exe with the source code, that way it has the same access to additional files as the source without having to fully path the filenames for loading files. You know that little thing you had to tick off in the Run Menu of IDE.
Title: Re: Star Backgound
Post by: bplus on July 01, 2018, 12:33:32 pm
You know after I posted my question, I might have found an answer to the confusion.

It is about saving the exe with the source code, that way it has the same access to additional files as the source without having to fully path the filenames for loading files. You know that little thing you had to tick off in the Run Menu of IDE.

Maybe I should say, tick on, "Save EXE in the source folder". I remember that little thing ticked me off when I was trying out a new download of QB64, code was working but files weren't loading.
Title: Re: Star Backgound
Post by: johnno56 on July 01, 2018, 04:43:18 pm
There ya go. I'm glad at least one of us remembered my typo... lol (by the way... I just checked... it's still ticked... lol)

J
Title: Re: Star Backgound
Post by: bplus on October 31, 2018, 03:18:09 pm
Vastly improved Sphere Sim:
Code: QB64: [Select]
  1. _TITLE "Fake sphere mapping by Paul Dunn, trans from SpecBas to QB64 2018-10-31 B+"
  2. '10  Fake sphere mapping
  3. '20 GRAPHIC NEW t LOAD "demos:3d/lava_strip.png":gw=gfxw t,gh=gfxh t:
  4. '   palette copy t,0,256 to 0:
  5. '   paper rgbn(0):
  6. '   screen lock
  7. '30 r=scrh/2.1,xc=SCRw/2,yc=SCRh/2,xo=0:
  8. '   do:
  9. '      for y=-r+1 to r-1:
  10. '         x1=sqr(r*r-y*y),
  11. '         tv=(asn(y/r)+1.5)/3:
  12. '         for x=-x1 to x1:
  13. '            tu=(asn(x/x1)+1.5)/6:
  14. '            plot ink gpoint(t,(xo+tu*gw) mod gw,tv*gh);x+xc,y+yc:
  15. '         next x:
  16. '      next y:
  17. '      xo+=1,xo%=gw:
  18. '      wait screen:
  19. '      cls:
  20. '   loop
  21.  
  22. SCREEN _NEWIMAGE(800, 600, 32)
  23. surface& = _LOADIMAGE("martian.png")
  24. 'surface& = _LOADIMAGE("mars.png") 'this image has a color change where ends meet
  25. 'surface& = _LOADIMAGE("mars0.jpeg") 'better
  26.  
  27. gw = _WIDTH(surface&)
  28. gh = _HEIGHT(surface&)
  29. map& = _NEWIMAGE(gw, gh, 32)
  30. _DEST map&
  31. _PUTIMAGE , surface&, map&
  32.  
  33. stars& = _LOADIMAGE("stars.png")
  34. _SOURCE stars&
  35.  
  36. r = _HEIGHT / 3
  37. xc = _WIDTH / 2
  38. yc = _HEIGHT / 2
  39. xo = 0
  40.     FOR y = -r TO r
  41.         x1 = SQR(r * r - y * y)
  42.         tv = (_ASIN(y / r) + 1.5) / 3
  43.         FOR x = -x1 + 1 TO x1
  44.             tu = (_ASIN(x / x1) + 1.5) / 6
  45.             _SOURCE map&
  46.             pc~& = POINT((xo + tu * gw) MOD gw, tv * gh)
  47.             _DEST 0
  48.             PSET (x + xc, y + yc), pc~&
  49.             'plot ink gpoint(t,(xo+tu*gw) mod gw,tv*gh);x+xc,y+yc
  50.         NEXT x
  51.     NEXT y
  52.     xo = xo + 1
  53.     xo = xo MOD gw
  54.     _DISPLAY
  55.     _LIMIT 60
  56.     ' wait screen
  57.     'CLS
  58.  
  59.  
Title: Re: Star Backgound
Post by: SierraKen on August 18, 2019, 01:32:33 am
Well, I decided to make my own Solar System. This time with an orbiting Moon. The movement around the Earth wasn't the hard part like I thought. But the relative speed going around the Earth compared to the speed of Earth going around the Sun is where I'm stuck. The main problem is that I don't know this kind of math. It's the same math I used in my Math Graphics program. But I've tried pretty much everything. I know the Earth moves at the same speed as the Moon going around the Sun, but I can't get the speed of the Moon right. Is there any math people out there that could help me with 1 equation? I know the Moon orbits the Earth 13 times a year and I tried that but it keeps staying on around 10 for some reason. Any help is appreciated, thanks. I'm sure a couple of the lines are wrong in the same area, for the Moon. The other planets I think are OK.

Code: QB64: [Select]
  1. SCREEN _NEWIMAGE(800, 600, 32)
  2. one:
  3. _LIMIT 500
  4. mercury = 0.241
  5. venus = 0.6152
  6. mars = 1.8809
  7. moon = 12.368
  8. seconds = seconds + .01
  9. moonseconds = moonseconds + .0013
  10. s = (60 - seconds) * 6 + 180
  11. s1 = (60 - seconds) * 6 + 180 / mercury
  12. s2 = (60 - seconds) * 6 + 180 / venus
  13. s3 = (60 - seconds) * 6 + 180 / mars
  14. s4 = (60 - moonseconds) * 6 + 180
  15.  
  16.  
  17. x1 = INT(SIN(s1 / 45 * 3.141592) * 45) + 400
  18. y1 = INT(COS(s1 / 45 * 3.141592) * 45) + 300
  19.  
  20. x2 = INT(SIN(s2 / 90 * 3.141592) * 90) + 400
  21. y2 = INT(COS(s2 / 90 * 3.141592) * 90) + 300
  22.  
  23. x = INT(SIN(s / 180 * 3.141592) * 180) + 400
  24. y = INT(COS(s / 180 * 3.141592) * 180) + 300
  25.  
  26. x3 = INT(SIN(s3 / 270 * 3.141592) * 270) + 400
  27. y3 = INT(COS(s3 / 270 * 3.141592) * 270) + 300
  28.  
  29. 'Moon
  30. x4 = INT(SIN(s / 18 * 3.141592) * 18) + x
  31. y4 = INT(COS(s / 18 * 3.141592) * 18) + y
  32.  
  33.  
  34.  
  35. CIRCLE (x1, y1), 5, _RGB32(120, 98, 102)
  36. PAINT (x1, y1), _RGB32(120, 98, 102)
  37.  
  38. CIRCLE (x2, y2), 5, _RGB32(161, 67, 39)
  39. PAINT (x2, y2), _RGB32(161, 67, 39)
  40.  
  41. CIRCLE (x, y), 5, _RGB32(0, 0, 255)
  42. PAINT (x, y), _RGB32(0, 0, 255)
  43.  
  44.  
  45. CIRCLE (x3, y3), 5, _RGB32(240, 72, 22)
  46. PAINT (x3, y3), _RGB32(240, 72, 22)
  47.  
  48. 'Moon
  49. CIRCLE (x4, y4), 2.5, _RGB32(179, 179, 181)
  50. PAINT (x4, y4), _RGB32(179, 179, 181)
  51.  
  52.  
  53.  
  54. CIRCLE (400, 300), 10, _RGB32(249, 240, 22)
  55. PAINT (400, 300), _RGB32(249, 240, 22)
  56. IF seconds > 99999 THEN
  57.     CLS
  58.     seconds = 0
  59.     GOTO one:
  60. '_DELAY .001
  61. GOTO one:
  62.  
  63.  
  64.  
Title: Re: Star Backgound
Post by: STxAxTIC on August 18, 2019, 03:08:14 am
Welp, I tried solving this from the ground up and ended up reaching for a full-blown n-layers-deep parent-body simulation, and said "this does NOT help this guy", so I scrapped it entirely and went back to your code.

I'm not sure what inspired some of the mathematical decisions here, but if you want the moon to go around 13 times a year, this got me closer:

Code: QB64: [Select]
  1. SCREEN _NEWIMAGE(800, 600, 32)
  2. one:
  3. _LIMIT 500
  4. mercury = 0.241
  5. venus = 0.6152
  6. mars = 1.8809
  7. moon = 12.368
  8. seconds = seconds + .01
  9. moonseconds = moonseconds + .01
  10. s = (60 - seconds) * 6 + 180
  11. s1 = (60 - seconds) * 6 + 180 / mercury
  12. s2 = (60 - seconds) * 6 + 180 / venus
  13. s3 = (60 - seconds) * 6 + 180 / mars
  14. s4 = (60 - moonseconds) * 6 + 180
  15.  
  16.  
  17. x1 = INT(SIN(s1 / 45 * 3.141592) * 45) + 400
  18. y1 = INT(COS(s1 / 45 * 3.141592) * 45) + 300
  19.  
  20. x2 = INT(SIN(s2 / 90 * 3.141592) * 90) + 400
  21. y2 = INT(COS(s2 / 90 * 3.141592) * 90) + 300
  22.  
  23. x = INT(SIN(s / 180 * 3.141592) * 180) + 400
  24. y = INT(COS(s / 180 * 3.141592) * 180) + 300
  25.  
  26. x3 = INT(SIN(s3 / 270 * 3.141592) * 270) + 400
  27. y3 = INT(COS(s3 / 270 * 3.141592) * 270) + 300
  28.  
  29. 'Moon
  30. x4 = INT(SIN(19 * s3 / 270 * 3.141592) * 18) + x
  31. y4 = INT(COS(19 * s3 / 270 * 3.141592) * 18) + y
  32.  
  33. CIRCLE (x1, y1), 5, _RGB32(120, 98, 102)
  34. PAINT (x1, y1), _RGB32(120, 98, 102)
  35.  
  36. CIRCLE (x2, y2), 5, _RGB32(161, 67, 39)
  37. PAINT (x2, y2), _RGB32(161, 67, 39)
  38.  
  39. CIRCLE (x, y), 5, _RGB32(0, 0, 255)
  40. PAINT (x, y), _RGB32(0, 0, 255)
  41.  
  42.  
  43. CIRCLE (x3, y3), 5, _RGB32(240, 72, 22)
  44. PAINT (x3, y3), _RGB32(240, 72, 22)
  45.  
  46. 'Moon
  47. CIRCLE (x4, y4), 2.5, _RGB32(179, 179, 181)
  48. PAINT (x4, y4), _RGB32(179, 179, 181)
  49.  
  50.  
  51.  
  52. CIRCLE (400, 300), 10, _RGB32(249, 240, 22)
  53. PAINT (400, 300), _RGB32(249, 240, 22)
  54. IF seconds > 99999 THEN
  55.     CLS
  56.     seconds = 0
  57.     GOTO one:
  58. '_DELAY .001
  59. GOTO one:
  60.  
Title: Re: Star Backgound
Post by: OldMoses on August 18, 2019, 07:57:08 am
The planets in my program are moving "on rails" as well. https://www.qb64.org/forum/index.php?topic=1429.0 That is, the program is not using a gravitational equation. Now the first thing that jumps out at me is that you are assigning almost the exact same numbers to the planets that I did, except the Moon is radically different. The planets are done using the orbital period in years per revolution, while the Moon is using revolutions per year. I'd suggest not treating the moon as a special case, with "moonseconds" as opposed to "seconds", require that it conform to one universal equation. I'll see what I can come up with and post when done. I type rather slowly...

Try this...

By changing p and adding appropriate data, you can easily add more moons and planets.
Code: QB64: [Select]
  1. TYPE planet
  2.     nam AS STRING * 10
  3.     parent AS STRING * 10
  4.     x AS INTEGER
  5.     y AS INTEGER
  6.     s AS SINGLE
  7.     orad AS INTEGER
  8.     oprd AS SINGLE
  9.     rad AS SINGLE
  10.     r AS INTEGER
  11.     g AS INTEGER
  12.     b AS INTEGER
  13.  
  14. p = 6 '                                                         change p to equal number of planets/satellites
  15.  
  16. REDIM SHARED exo(p) AS planet
  17.  
  18. FOR a = 1 TO p
  19.     READ exo(a).nam
  20.     READ exo(a).parent
  21.     READ exo(a).x
  22.     READ exo(a).y
  23.     READ exo(a).orad
  24.     READ exo(a).oprd
  25.     READ exo(a).rad
  26.     READ exo(a).r
  27.     READ exo(a).g
  28.     READ exo(a).b
  29.  
  30. DATA "Sol","Sol",400,300,0,0,5,249,240,22
  31. DATA "Mercury","Sol",0,0,45,0.241,5,120,98,102
  32. DATA "Venus","Sol",0,0,90,0.6152,5,161,67,39
  33. DATA "Earth","Sol",0,0,180,1,5,0,0,255
  34. DATA "Mars","Sol",0,0,270,1.8809,5,240,72,22
  35. DATA "Moon","Earth",0,0,18,0.0748,2.5,179,179,181
  36.  
  37. SCREEN _NEWIMAGE(800, 600, 32)
  38. one:
  39. _LIMIT 500
  40. seconds = seconds + .01
  41. b = 1
  42. CIRCLE (exo(b).x, exo(b).y), exo(b).rad, _RGB32(exo(b).r, exo(b).g, exo(b).b)
  43. PAINT (exo(b).x, exo(b).y), _RGB32(exo(b).r, exo(b).g, exo(b).b)
  44.  
  45. FOR b = 2 TO p
  46.     exo(b).s = (60 - seconds) * 6 + 180 / exo(b).oprd
  47.     exo(b).x = INT(SIN(_D2R(exo(b).s / exo(b).oprd)) * exo(b).orad) + exo(FindParent(b)).x
  48.     exo(b).y = INT(COS(_D2R(exo(b).s / exo(b).oprd)) * exo(b).orad) + exo(FindParent(b)).y
  49.     CIRCLE (exo(b).x, exo(b).y), exo(b).rad, _RGB32(exo(b).r, exo(b).g, exo(b).b)
  50.     PAINT (exo(b).x, exo(b).y), _RGB32(exo(b).r, exo(b).g, exo(b).b)
  51. IF seconds > 99999 THEN
  52.     CLS
  53.     seconds = 0
  54.     GOTO one:
  55. '_DELAY .001
  56. GOTO one:
  57.  
  58. FUNCTION FindParent (var AS INTEGER)
  59.  
  60.     'Accepts a planetary body index (var) and finds the index of its parent body
  61.  
  62.     FOR x = 1 TO p
  63.         IF exo(var).parent = exo(x).nam THEN o = x
  64.     NEXT x
  65.     FindParent = o
  66.  
  67. END FUNCTION 'FindParent
  68.  
  69.  
Title: Re: Star Backgound
Post by: SierraKen on August 18, 2019, 11:34:28 am
LOL thanks STxAxTIC! Was easier than I thought. I'm going to stick with your way since it's just about all my code and it will be on my website. Thank you also OldMoses, but the way you program, using TYPE and broken up variables, etc. I just haven't reached that level of expertise yet. STxAxTIC I added your nick to the top of the code. I'll put that on my website probably sometime today, unless I play around with it more. Oh and yes, I used orbital numbers compared to Earth's orbit for other planets. I think I was just thinking too much about this. The Earth and Moon go around the sun in equal time, so just use equal numbers.
Title: Re: Star Backgound
Post by: OldMoses on August 18, 2019, 12:06:35 pm
Thank you also OldMoses, but the way you program, using TYPE and broken up variables, etc. I just haven't reached that level of expertise yet.

If you only knew the power of the Darkside....and we have cookies. ;)

Seriously though, you should try playing around with it some, it's really not as complex as it may seem. You owe it to yourself to push your skills in that direction.

I know you've been doing some fairly sophisticated programming, some of which I can't grasp on a casual reading, so I believe you will not find the concepts difficult. A well designed type array makes adding elements a breeze without a lot of code revision, and is easy to modify if needed. If anything, the variables are less "broken up", and one can keep indexed data ordered easier. You'll be astonished at what you can do with a very small amount of code once the infrastructure is there.

As an illustration, I added the moons of Mars (Phobos & Deimos) to the code. The only thing necessary was to change p from 6 to 8, and to add two data lines for the moons. Since their orbital periods are so fast, I slowed them down by a factor of 100, to make them easier on the eyes.

Code: QB64: [Select]
  1. TYPE planet
  2.     nam AS STRING * 10
  3.     parent AS STRING * 10
  4.     x AS INTEGER
  5.     y AS INTEGER
  6.     s AS SINGLE
  7.     orad AS INTEGER
  8.     oprd AS SINGLE
  9.     rad AS SINGLE
  10.     r AS INTEGER
  11.     g AS INTEGER
  12.     b AS INTEGER
  13.  
  14. p = 8 '                                                         change p to equal number of planets/satellites
  15.  
  16. REDIM SHARED exo(p) AS planet
  17.  
  18. FOR a = 1 TO p
  19.     READ exo(a).nam
  20.     READ exo(a).parent
  21.     READ exo(a).x
  22.     READ exo(a).y
  23.     READ exo(a).orad
  24.     READ exo(a).oprd
  25.     READ exo(a).rad
  26.     READ exo(a).r
  27.     READ exo(a).g
  28.     READ exo(a).b
  29.  
  30. DATA "Sol","Sol",400,300,0,0,5,249,240,22
  31. DATA "Mercury","Sol",0,0,45,0.241,5,120,98,102
  32. DATA "Venus","Sol",0,0,90,0.6152,5,161,67,39
  33. DATA "Earth","Sol",0,0,180,1,5,0,0,255
  34. DATA "Mars","Sol",0,0,270,1.8809,5,240,72,22
  35. DATA "Moon","Earth",0,0,18,0.0748,2.5,179,179,181
  36. DATA "Phobos","Mars",0,0,10,0.0873,1.5,179,179,181
  37. DATA "Deimos","Mars",0,0,30,0.3458,1.5,179,179,181
  38.  
  39. SCREEN _NEWIMAGE(800, 600, 32)
  40. one:
  41. _LIMIT 500
  42. seconds = seconds + .01
  43. b = 1
  44. CIRCLE (exo(b).x, exo(b).y), exo(b).rad, _RGB32(exo(b).r, exo(b).g, exo(b).b)
  45. PAINT (exo(b).x, exo(b).y), _RGB32(exo(b).r, exo(b).g, exo(b).b)
  46.  
  47. FOR b = 2 TO p
  48.     exo(b).s = (60 - seconds) * 6 + 180 / exo(b).oprd
  49.     exo(b).x = INT(SIN(_D2R(exo(b).s / exo(b).oprd)) * exo(b).orad) + exo(FindParent(b)).x
  50.     exo(b).y = INT(COS(_D2R(exo(b).s / exo(b).oprd)) * exo(b).orad) + exo(FindParent(b)).y
  51.     CIRCLE (exo(b).x, exo(b).y), exo(b).rad, _RGB32(exo(b).r, exo(b).g, exo(b).b)
  52.     PAINT (exo(b).x, exo(b).y), _RGB32(exo(b).r, exo(b).g, exo(b).b)
  53. IF seconds > 99999 THEN
  54.     CLS
  55.     seconds = 0
  56.     GOTO one:
  57. '_DELAY .001
  58. GOTO one:
  59.  
  60. FUNCTION FindParent (var AS INTEGER)
  61.  
  62.     'Accepts a planetary body index (var) and finds the index of its parent body
  63.  
  64.     FOR x = 1 TO p
  65.         IF exo(var).parent = exo(x).nam THEN o = x
  66.     NEXT x
  67.     FindParent = o
  68.  
  69. END FUNCTION 'FindParent
  70.  
Title: Re: Star Backgound
Post by: SierraKen on August 18, 2019, 06:24:04 pm
I decided to make my own Solar System Simulator. It has all the planets. It doesn't have Pluto for 2 reasons, one is that Pluto is now a Kupier Belt Object instead of a regular planet, but mostly also because Pluto's orbit is way too hard to calculate. I looked up equations for it online and someone even says it has never been done by anyone and been verified, because it's an elongated orbit going in and out of Neptune's orbit and also it's not the the same vertical plane as the rest of the Solar System. The awesome thing about my little program is that it uses the mouse to zoom in and out to see the rest of the planets (using the mouse wheel) and it also identifies the objects when you put your mouse over them (except The Moon since it's too close to Earth). Check out my funky Saturn. :) By the way, I don't mean to try to be better than anyone else in here with my programming, I just get ideas and go with it. And I think all of us do that. I hope anyway.

(Better version is after this one which has viewing tilt.)

Code: QB64: [Select]
  1. 'Ken G. made thie program on August 18, 2019,
  2. 'Thank you to STxAxTIC on the QB64.org forum for a little bit of help with the Moon orbit!
  3.  
  4. _TITLE "Solar System Simulator by Ken G. - Use Mouse To Identify and Mouse Wheel To Zoom In and Out For More Planets"
  5. SCREEN _NEWIMAGE(800, 600, 32)
  6. mercury = 0.241
  7. venus = 0.6152
  8. mars = 1.8809
  9. jupiter = 11.8618
  10. saturn = 29.457
  11. uranus = 84.0205
  12. neptune = 164.8
  13. pluto = 248
  14. angle = 180
  15. one:
  16. _LIMIT 500
  17. mouseWheel = 0
  18.     mouseX = _MOUSEX
  19.     mouseY = _MOUSEY
  20.     mouseLeftButton = _MOUSEBUTTON(1)
  21.     mouseRightButton = _MOUSEBUTTON(2)
  22.     mouseMiddleButton = _MOUSEBUTTON(3)
  23.     mouseWheel = mouseWheel + _MOUSEWHEEL
  24. IF mouseWheel < 0 THEN angle = angle - 10
  25. IF mouseWheel > 0 THEN angle = angle + 10
  26.  
  27. IF mouseX > 385 AND mouseX < 415 AND mouseY > 285 AND mouseY < 315 THEN LOCATE 2, 49: PRINT "Sun    "
  28. IF mouseX > x1 - 15 AND mouseX < x1 + 15 AND mouseY > y1 - 15 AND mouseY < y1 + 15 THEN LOCATE 2, 49: PRINT "Mercury"
  29. IF mouseX > x2 - 15 AND mouseX < x2 + 15 AND mouseY > y2 - 15 AND mouseY < y2 + 15 THEN LOCATE 2, 49: PRINT "Venus  "
  30. IF mouseX > x - 15 AND mouseX < x + 15 AND mouseY > y - 15 AND mouseY < y + 15 THEN LOCATE 2, 49: PRINT "Earth  "
  31. IF mouseX > x3 - 15 AND mouseX < x3 + 15 AND mouseY > y3 - 15 AND mouseY < y3 + 15 THEN LOCATE 2, 49: PRINT "Mars   "
  32. IF mouseX > x5 - 15 AND mouseX < x5 + 15 AND mouseY > y5 - 15 AND mouseY < y5 + 15 THEN LOCATE 2, 49: PRINT "Jupiter"
  33. IF mouseX > x6 - 15 AND mouseX < x6 + 15 AND mouseY > y6 - 15 AND mouseY < y6 + 15 THEN LOCATE 2, 49: PRINT "Saturn "
  34. IF mouseX > x7 - 15 AND mouseX < x7 + 15 AND mouseY > y7 - 15 AND mouseY < y7 + 15 THEN LOCATE 2, 49: PRINT "Uranus "
  35. IF mouseX > x8 - 15 AND mouseX < x8 + 15 AND mouseY > y8 - 15 AND mouseY < y8 + 15 THEN LOCATE 2, 49: PRINT "Neptune"
  36.  
  37.  
  38. a$ = INKEY$
  39. IF a$ = CHR$(27) THEN END
  40. IF a$ = CHR$(0) + CHR$(72) THEN angle = angle + 10
  41. IF a$ = CHR$(0) + CHR$(80) THEN angle = angle - 10
  42. IF angle > 360 THEN angle = 360
  43. IF angle < 0 THEN angle = 0
  44.  
  45. seconds = seconds + .01
  46.  
  47. s1 = (60 - seconds) * 6 + 180 / mercury
  48. s2 = (60 - seconds) * 6 + 180 / venus
  49. s3 = (60 - seconds) * 6 + 180 'Earth and Moon
  50. s4 = (60 - seconds) * 6 + 180 / mars
  51. s5 = (60 - seconds) * 6 + 180 / jupiter
  52. s6 = (60 - seconds) * 6 + 180 / saturn
  53. s7 = (60 - seconds) * 6 + 180 / uranus
  54. s8 = (60 - seconds) * 6 + 180 / neptune
  55.  
  56. 'Mercury
  57. x1 = INT(SIN(s1 / 45 * 3.141592) * angle / 4) + 400
  58. y1 = INT(COS(s1 / 45 * 3.141592) * angle / 4) + 300
  59.  
  60. 'Venus
  61. x2 = INT(SIN(s2 / 90 * 3.141592) * angle / 2) + 400
  62. y2 = INT(COS(s2 / 90 * 3.141592) * angle / 2) + 300
  63.  
  64. 'Earth
  65. x = INT(SIN(s3 / 180 * 3.141592) * angle) + 400
  66. y = INT(COS(s3 / 180 * 3.141592) * angle) + 300
  67.  
  68. 'Mars
  69. x3 = INT(SIN(s4 / 270 * 3.141592) * angle * 1.5) + 400
  70. y3 = INT(COS(s4 / 270 * 3.141592) * angle * 1.5) + 300
  71.  
  72. 'Moon
  73. x4 = INT(SIN(19 * s3 / 270 * 3.141592) * angle / 10) + x
  74. y4 = INT(COS(19 * s3 / 270 * 3.141592) * angle / 10) + y
  75.  
  76. 'Outer Planets
  77. 'Jupiter
  78. x5 = INT(SIN(s5 / 450 * 3.141592) * angle * 3) + 400
  79. y5 = INT(COS(s5 / 450 * 3.141592) * angle * 3) + 300
  80.  
  81. 'Saturn
  82. x6 = INT(SIN(s6 / 630 * 3.141592) * angle * 4.5) + 400
  83. y6 = INT(COS(s6 / 630 * 3.141592) * angle * 4.5) + 300
  84.  
  85. 'Uranus
  86. x7 = INT(SIN(s7 / 810 * 3.141592) * angle * 6) + 400
  87. y7 = INT(COS(s7 / 810 * 3.141592) * angle * 6) + 300
  88.  
  89. 'Neptune
  90. x8 = INT(SIN(s8 / 990 * 3.141592) * angle * 7.5) + 400
  91. y8 = INT(COS(s8 / 990 * 3.141592) * angle * 7.5) + 300
  92.  
  93. 'Mercury
  94. CIRCLE (x1, y1), 5, _RGB32(120, 98, 102)
  95. PAINT (x1, y1), _RGB32(120, 98, 102)
  96.  
  97. 'Venus
  98. CIRCLE (x2, y2), 5, _RGB32(161, 67, 39)
  99. PAINT (x2, y2), _RGB32(161, 67, 39)
  100.  
  101. 'Earth
  102. CIRCLE (x, y), 5, _RGB32(0, 0, 255)
  103. PAINT (x, y), _RGB32(0, 0, 255)
  104.  
  105. 'Mars
  106. CIRCLE (x3, y3), 5, _RGB32(240, 72, 22)
  107. PAINT (x3, y3), _RGB32(240, 72, 22)
  108.  
  109. 'Moon
  110. CIRCLE (x4, y4), 2.5, _RGB32(179, 179, 181)
  111. PAINT (x4, y4), _RGB32(179, 179, 181)
  112.  
  113. 'Outer Planets
  114. 'Jupiter
  115. CIRCLE (x5, y5), 5, _RGB32(255, 166, 127)
  116. PAINT (x5, y5), _RGB32(255, 166, 127)
  117.  
  118. 'Saturn
  119. CIRCLE (x6, y6), 5, _RGB32(255, 127, 127)
  120. PAINT (x6, y6), _RGB32(255, 127, 127)
  121. FOR rings = 1 TO 2
  122.     CIRCLE (x6, y6), 7 + rings, _RGB32(255, 127, 127)
  123. NEXT rings
  124.  
  125. 'Uranus
  126. CIRCLE (x7, y7), 5, _RGB32(127, 166, 255)
  127. PAINT (x7, y7), _RGB32(127, 166, 255)
  128.  
  129. 'Neptune
  130. CIRCLE (x8, y8), 5, _RGB32(0, 78, 255)
  131. PAINT (x8, y8), _RGB32(0, 78, 255)
  132.  
  133. 'Sun
  134. CIRCLE (400, 300), 5, _RGB32(249, 240, 22)
  135. PAINT (400, 300), _RGB32(249, 240, 22)
  136. IF seconds > 99999 THEN
  137.     CLS
  138.     seconds = 0
  139.     GOTO one:
  140. GOTO one:
  141.  
  142.  
Title: Re: Star Backgound
Post by: SierraKen on August 18, 2019, 08:55:42 pm
Use Mouse over the planets to I.D. them. Use Mouse Wheel to zoom in and out to all of the planets, and use Up and Down Arrow Keys to tilt the view.

Code: QB64: [Select]
  1. 'Ken G. made thie program on August 18, 2019,
  2. 'Thank you to STxAxTIC on the QB64.org forum for a little bit of help with The Moon orbit!
  3.  
  4. _TITLE "Solar System Simulator by Ken G. Use Mouse Over Planets, Mouse Wheel to Zoom, and Up and Down Arrow Keys To Tilt."
  5. SCREEN _NEWIMAGE(800, 600, 32)
  6. mercury = 0.241
  7. venus = 0.6152
  8. mars = 1.8809
  9. jupiter = 11.8618
  10. saturn = 29.457
  11. uranus = 84.0205
  12. neptune = 164.8
  13. angle = 180
  14. tilt = 1
  15. one:
  16. _LIMIT 500
  17. mouseWheel = 0
  18.     mouseX = _MOUSEX
  19.     mouseY = _MOUSEY
  20.     mouseLeftButton = _MOUSEBUTTON(1)
  21.     mouseRightButton = _MOUSEBUTTON(2)
  22.     mouseMiddleButton = _MOUSEBUTTON(3)
  23.     mouseWheel = mouseWheel + _MOUSEWHEEL
  24. IF mouseWheel < 0 THEN angle = angle - 10
  25. IF mouseWheel > 0 THEN angle = angle + 10
  26.  
  27. IF mouseX > 385 AND mouseX < 415 AND mouseY > 285 AND mouseY < 315 THEN LOCATE 2, 49: PRINT "Sun    "
  28. IF mouseX > x1 - 15 AND mouseX < x1 + 15 AND mouseY > y1 - 15 AND mouseY < y1 + 15 THEN LOCATE 2, 49: PRINT "Mercury"
  29. IF mouseX > x2 - 15 AND mouseX < x2 + 15 AND mouseY > y2 - 15 AND mouseY < y2 + 15 THEN LOCATE 2, 49: PRINT "Venus  "
  30. IF mouseX > x - 15 AND mouseX < x + 15 AND mouseY > y - 15 AND mouseY < y + 15 THEN LOCATE 2, 49: PRINT "Earth  "
  31. IF mouseX > x3 - 15 AND mouseX < x3 + 15 AND mouseY > y3 - 15 AND mouseY < y3 + 15 THEN LOCATE 2, 49: PRINT "Mars   "
  32. IF mouseX > x5 - 15 AND mouseX < x5 + 15 AND mouseY > y5 - 15 AND mouseY < y5 + 15 THEN LOCATE 2, 49: PRINT "Jupiter"
  33. IF mouseX > x6 - 15 AND mouseX < x6 + 15 AND mouseY > y6 - 15 AND mouseY < y6 + 15 THEN LOCATE 2, 49: PRINT "Saturn "
  34. IF mouseX > x7 - 15 AND mouseX < x7 + 15 AND mouseY > y7 - 15 AND mouseY < y7 + 15 THEN LOCATE 2, 49: PRINT "Uranus "
  35. IF mouseX > x8 - 15 AND mouseX < x8 + 15 AND mouseY > y8 - 15 AND mouseY < y8 + 15 THEN LOCATE 2, 49: PRINT "Neptune"
  36.  
  37. a$ = INKEY$
  38. IF a$ = CHR$(27) THEN END
  39. IF a$ = CHR$(0) + CHR$(72) THEN tilt = tilt + 1
  40. IF a$ = CHR$(0) + CHR$(80) THEN tilt = tilt - 1
  41. IF angle > 360 THEN angle = 360
  42. IF angle < 10 THEN angle = 10
  43. IF tilt > 90 THEN tilt = 90
  44. IF tilt < 1 THEN tilt = 1
  45. seconds = seconds + .01
  46. s1 = (60 - seconds) * 6 + 180 / mercury
  47. s2 = (60 - seconds) * 6 + 180 / venus
  48. s3 = (60 - seconds) * 6 + 180 'Earth and Moon
  49. s4 = (60 - seconds) * 6 + 180 / mars
  50. s5 = (60 - seconds) * 6 + 180 / jupiter
  51. s6 = (60 - seconds) * 6 + 180 / saturn
  52. s7 = (60 - seconds) * 6 + 180 / uranus
  53. s8 = (60 - seconds) * 6 + 180 / neptune
  54.  
  55. 'Mercury
  56. x1 = INT(SIN(s1 / 45 * 3.141592) * angle / 4) + 400
  57. y1 = INT(COS(s1 / 45 * 3.141592) * (angle / 4) / tilt) + 300
  58.  
  59. 'Venus
  60. x2 = INT(SIN(s2 / 90 * 3.141592) * angle / 2) + 400
  61. y2 = INT(COS(s2 / 90 * 3.141592) * (angle / 2) / tilt) + 300
  62.  
  63. 'Earth
  64. x = INT(SIN(s3 / 180 * 3.141592) * angle) + 400
  65. y = INT(COS(s3 / 180 * 3.141592) * angle / tilt) + 300
  66.  
  67. 'Mars
  68. x3 = INT(SIN(s4 / 270 * 3.141592) * angle * 1.5) + 400
  69. y3 = INT(COS(s4 / 270 * 3.141592) * (angle * 1.5) / tilt) + 300
  70.  
  71. 'Moon
  72. x4 = INT(SIN(19 * s3 / 270 * 3.141592) * angle / 10) + x
  73. y4 = INT(COS(19 * s3 / 270 * 3.141592) * (angle / 10) / tilt) + y
  74.  
  75. 'Outer Planets
  76. 'Jupiter
  77. x5 = INT(SIN(s5 / 450 * 3.141592) * angle * 3) + 400
  78. y5 = INT(COS(s5 / 450 * 3.141592) * (angle * 3) / tilt) + 300
  79.  
  80. 'Saturn
  81. x6 = INT(SIN(s6 / 630 * 3.141592) * angle * 4.5) + 400
  82. y6 = INT(COS(s6 / 630 * 3.141592) * (angle * 4.5) / tilt) + 300
  83.  
  84. 'Uranus
  85. x7 = INT(SIN(s7 / 810 * 3.141592) * angle * 6) + 400
  86. y7 = INT(COS(s7 / 810 * 3.141592) * (angle * 6) / tilt) + 300
  87.  
  88. 'Neptune
  89. x8 = INT(SIN(s8 / 990 * 3.141592) * angle * 7.5) + 400
  90. y8 = INT(COS(s8 / 990 * 3.141592) * (angle * 7.5) / tilt) + 300
  91.  
  92. 'Mercury
  93. CIRCLE (x1, y1), 5, _RGB32(120, 98, 102)
  94. PAINT (x1, y1), _RGB32(120, 98, 102)
  95.  
  96. 'Venus
  97. CIRCLE (x2, y2), 5, _RGB32(161, 67, 39)
  98. PAINT (x2, y2), _RGB32(161, 67, 39)
  99.  
  100. 'Earth
  101. CIRCLE (x, y), 5, _RGB32(0, 0, 255)
  102. PAINT (x, y), _RGB32(0, 0, 255)
  103.  
  104. 'Mars
  105. CIRCLE (x3, y3), 5, _RGB32(240, 72, 22)
  106. PAINT (x3, y3), _RGB32(240, 72, 22)
  107.  
  108. 'Moon
  109. CIRCLE (x4, y4), 2.5, _RGB32(179, 179, 181)
  110. PAINT (x4, y4), _RGB32(179, 179, 181)
  111.  
  112. 'Outer Planets
  113. 'Jupiter
  114. CIRCLE (x5, y5), 5, _RGB32(255, 166, 127)
  115. PAINT (x5, y5), _RGB32(255, 166, 127)
  116.  
  117. 'Saturn
  118. CIRCLE (x6, y6), 5, _RGB32(255, 127, 127)
  119. PAINT (x6, y6), _RGB32(255, 127, 127)
  120. FOR rings = 1 TO 2
  121.     CIRCLE (x6, y6), 7 + rings, _RGB32(255, 127, 127), , , .65
  122. NEXT rings
  123.  
  124. 'Uranus
  125. CIRCLE (x7, y7), 5, _RGB32(127, 166, 255)
  126. PAINT (x7, y7), _RGB32(127, 166, 255)
  127.  
  128. 'Neptune
  129. CIRCLE (x8, y8), 5, _RGB32(0, 78, 255)
  130. PAINT (x8, y8), _RGB32(0, 78, 255)
  131.  
  132. 'Sun
  133. CIRCLE (400, 300), 5, _RGB32(249, 240, 22)
  134. PAINT (400, 300), _RGB32(249, 240, 22)
  135. IF seconds > 99999 THEN
  136.     CLS
  137.     seconds = 0
  138.     GOTO one:
  139. GOTO one:
  140.  

Title: Re: Star Backgound
Post by: SMcNeill on August 18, 2019, 09:20:13 pm
Code: [Select]
DO WHILE _MOUSEINPUT
    mouseX = _MOUSEX
    mouseY = _MOUSEY
    mouseLeftButton = _MOUSEBUTTON(1)
    mouseRightButton = _MOUSEBUTTON(2)
    mouseMiddleButton = _MOUSEBUTTON(3)
    mouseWheel = mouseWheel + _MOUSEWHEEL
LOOP

Warning: The code above is very susceptible to causing lag inside a program, and should generally be avoided at all cost.

Move the mouse quickly back and forth across the screen several times and watch how it lags as it keeps reassigning values over and over to all those variables...  mouse starts in far left, moves to far right, that’s several thousand updates to mousex while the mousebuffer is clearing...

Much better is generally:

Code: [Select]
DO WHILE _MOUSEINPUT
    ‘ mouseX = _MOUSEX
    ‘ mouseY = _MOUSEY
    ‘ mouseLeftButton = _MOUSEBUTTON(1)
    ‘ mouseRightButton = _MOUSEBUTTON(2)
    ‘ mouseMiddleButton = _MOUSEBUTTON(3)
    mouseWheel = mouseWheel + _MOUSEWHEEL
LOOP
mouseX = _MOUSEX
mouseY = _MOUSEY
mouseLeftButton = _MOUSEBUTTON(1)
mouseRightButton = _MOUSEBUTTON(2)
mouseMiddleButton = _MOUSEBUTTON(3)

Who cares how many times the mouse registered an x movement of a fraction of a pixel?  What we need to really know is “where is the mouse once that movement stops”.  After all, we’re not actually doing anything by updating the value a zillion times in the previous loop as it moves across the screen — we just keep overwriting mousex and mousey so we know their value once _MOUSEINPUT = 0.

Get the mouse states after the loop, and not during, and prevent the lag issues before they start.
Title: Re: Star Backgound
Post by: bplus on August 18, 2019, 09:23:39 pm
Hi Ken,

I like the tilting allot! and am curious where the figures:
Quote
mercury = 0.241
venus = 0.6152
mars = 1.8809
jupiter = 11.8618
saturn = 29.457
uranus = 84.0205
neptune = 164.8
come from?
Title: Re: Star Backgound
Post by: SierraKen on August 18, 2019, 09:27:42 pm
Thanks! Those figures are comparing those planets with Earth. With Earth as 1 (rotation speed) and the others are all relative to that. Or something like that. lol For example, Mercury flies around the Sun faster than Earth does, so it's less than 1. When you go past Earth, I think I did times instead of division. Speed in the program isn't exact, but I tried. I may have to adjust them.
Title: Re: Star Backgound
Post by: SierraKen on August 18, 2019, 09:35:56 pm
To be exact, those numbers originally came from the Internet, with the real speeds comparing them to Earth.
Title: Re: Star Backgound
Post by: johnno56 on August 18, 2019, 10:42:03 pm
Well... If we are talking 'exact'... 'Those' figures are the length of time in years (Earth years) for each planet to complete a single orbit around the Sun.

Simply calculating the length of the orbit, 2 * pi * semi-major axis, dividing it by the number of hours it takes to orbit, will give you the planet's orbiting velocity. This method crude at best. The orbit is assumed to be circular.

Mercury: 87.96878448 days at 107,138.4 mph
Venus: 224.6996656 days at 78,367.7 mph
Earth: 365.24 days at 66,661.22 mph

I think I will stop there... my poor little calculator is complaining of keypad stress... lol
Title: Re: Star Backgound
Post by: SierraKen on August 19, 2019, 01:23:46 am
Here is a better version, thanks to B+ for the comments in the other thread. This one hides the planets when they go further away.

Code: QB64: [Select]
  1. 'Ken G. made thie program on August 18, 2019,
  2. 'Thank you to STxAxTIC on the QB64.org forum for a little bit of help with The Moon orbit!
  3.  
  4. _TITLE "Solar System Simulator by Ken G. Use Mouse Over Planets, Mouse Wheel to Zoom, and Up and Down Arrow Keys To Tilt."
  5. SCREEN _NEWIMAGE(800, 600, 32)
  6. DIM z(10)
  7. mercury = 0.241
  8. venus = 0.6152
  9. mars = 1.8809
  10. jupiter = 11.8618
  11. saturn = 29.457
  12. uranus = 84.0205
  13. neptune = 164.8
  14. angle = 180
  15. tilt = 1
  16. one:
  17. _LIMIT 500
  18. mouseWheel = 0
  19.     mouseX = _MOUSEX
  20.     mouseY = _MOUSEY
  21.     mouseLeftButton = _MOUSEBUTTON(1)
  22.     mouseRightButton = _MOUSEBUTTON(2)
  23.     mouseMiddleButton = _MOUSEBUTTON(3)
  24.     mouseWheel = mouseWheel + _MOUSEWHEEL
  25. IF mouseWheel < 0 THEN angle = angle - 10
  26. IF mouseWheel > 0 THEN angle = angle + 10
  27.  
  28. IF mouseX > 385 AND mouseX < 415 AND mouseY > 285 AND mouseY < 315 THEN LOCATE 2, 49: PRINT "Sun    "
  29. IF mouseX > x1 - 15 AND mouseX < x1 + 15 AND mouseY > y1 - 15 AND mouseY < y1 + 15 THEN LOCATE 2, 49: PRINT "Mercury"
  30. IF mouseX > x2 - 15 AND mouseX < x2 + 15 AND mouseY > y2 - 15 AND mouseY < y2 + 15 THEN LOCATE 2, 49: PRINT "Venus  "
  31. IF mouseX > x - 15 AND mouseX < x + 15 AND mouseY > y - 15 AND mouseY < y + 15 THEN LOCATE 2, 49: PRINT "Earth  "
  32. IF mouseX > x3 - 15 AND mouseX < x3 + 15 AND mouseY > y3 - 15 AND mouseY < y3 + 15 THEN LOCATE 2, 49: PRINT "Mars   "
  33. IF mouseX > x5 - 15 AND mouseX < x5 + 15 AND mouseY > y5 - 15 AND mouseY < y5 + 15 THEN LOCATE 2, 49: PRINT "Jupiter"
  34. IF mouseX > x6 - 15 AND mouseX < x6 + 15 AND mouseY > y6 - 15 AND mouseY < y6 + 15 THEN LOCATE 2, 49: PRINT "Saturn "
  35. IF mouseX > x7 - 15 AND mouseX < x7 + 15 AND mouseY > y7 - 15 AND mouseY < y7 + 15 THEN LOCATE 2, 49: PRINT "Uranus "
  36. IF mouseX > x8 - 15 AND mouseX < x8 + 15 AND mouseY > y8 - 15 AND mouseY < y8 + 15 THEN LOCATE 2, 49: PRINT "Neptune"
  37.  
  38. a$ = INKEY$
  39. IF a$ = CHR$(27) THEN END
  40. IF a$ = CHR$(0) + CHR$(72) THEN tilt = tilt + 1
  41. IF a$ = CHR$(0) + CHR$(80) THEN tilt = tilt - 1
  42. IF angle > 360 THEN angle = 360
  43. IF angle < 10 THEN angle = 10
  44. IF tilt > 30 THEN tilt = 30
  45. IF tilt < 1 THEN tilt = 1
  46. seconds = seconds + .01
  47. s1 = (60 - seconds) * 6 + 180 / mercury
  48. s2 = (60 - seconds) * 6 + 180 / venus
  49. s3 = (60 - seconds) * 6 + 180 'Earth and Moon
  50. s4 = (60 - seconds) * 6 + 180 / mars
  51. s5 = (60 - seconds) * 6 + 180 / jupiter
  52. s6 = (60 - seconds) * 6 + 180 / saturn
  53. s7 = (60 - seconds) * 6 + 180 / uranus
  54. s8 = (60 - seconds) * 6 + 180 / neptune
  55.  
  56.  
  57. 'Mercury
  58. oldx1 = x1
  59. x1 = INT(SIN(s1 / 45 * 3.141592) * angle / 4) + 400
  60. y1 = INT(COS(s1 / 45 * 3.141592) * (angle / 4) / tilt) + 300
  61.  
  62. 'Venus
  63. oldx2 = x2
  64. x2 = INT(SIN(s2 / 90 * 3.141592) * angle / 2) + 400
  65. y2 = INT(COS(s2 / 90 * 3.141592) * (angle / 2) / tilt) + 300
  66.  
  67. 'Earth
  68. oldx = x
  69. x = INT(SIN(s3 / 180 * 3.141592) * angle) + 400
  70. y = INT(COS(s3 / 180 * 3.141592) * angle / tilt) + 300
  71.  
  72. 'Mars
  73. oldx3 = x3
  74. x3 = INT(SIN(s4 / 270 * 3.141592) * angle * 1.5) + 400
  75. y3 = INT(COS(s4 / 270 * 3.141592) * (angle * 1.5) / tilt) + 300
  76.  
  77. 'Moon
  78. x4 = INT(SIN(19 * s3 / 270 * 3.141592) * angle / 10) + x
  79. y4 = INT(COS(19 * s3 / 270 * 3.141592) * (angle / 10) / tilt) + y
  80.  
  81. 'Outer Planets
  82. 'Jupiter
  83. oldx5 = x5
  84. x5 = INT(SIN(s5 / 450 * 3.141592) * angle * 3) + 400
  85. y5 = INT(COS(s5 / 450 * 3.141592) * (angle * 3) / tilt) + 300
  86.  
  87. 'Saturn
  88. oldx6 = x6
  89. x6 = INT(SIN(s6 / 630 * 3.141592) * angle * 4.5) + 400
  90. y6 = INT(COS(s6 / 630 * 3.141592) * (angle * 4.5) / tilt) + 300
  91.  
  92. 'Uranus
  93. oldx7 = x7
  94. x7 = INT(SIN(s7 / 810 * 3.141592) * angle * 6) + 400
  95. y7 = INT(COS(s7 / 810 * 3.141592) * (angle * 6) / tilt) + 300
  96.  
  97. 'Neptune
  98. oldx8 = x8
  99. x8 = INT(SIN(s8 / 990 * 3.141592) * angle * 7.5) + 400
  100. y8 = INT(COS(s8 / 990 * 3.141592) * (angle * 7.5) / tilt) + 300
  101.  
  102.  
  103. 'Sun
  104. CIRCLE (400, 300), 2, _RGB32(249, 240, 22)
  105. PAINT (400, 300), _RGB32(249, 240, 22)
  106.  
  107. IF tilt > 6 THEN
  108.     IF x1 > oldx1 THEN z(1) = 1
  109.     IF x2 > oldx2 THEN z(2) = 1
  110.     IF x3 > oldx3 THEN z(3) = 1
  111.     IF x5 > oldx5 THEN z(4) = 1
  112.     IF x6 > oldx6 THEN z(5) = 1
  113.     IF x7 > oldx7 THEN z(6) = 1
  114.     IF x8 > oldx8 THEN z(7) = 1
  115.     IF x > oldx THEN z(8) = 1
  116.     IF x1 < oldx1 THEN z(1) = 0
  117.     IF x2 < oldx2 THEN z(2) = 0
  118.     IF x3 < oldx3 THEN z(3) = 0
  119.     IF x5 < oldx5 THEN z(4) = 0
  120.     IF x6 < oldx6 THEN z(5) = 0
  121.     IF x7 < oldx7 THEN z(6) = 0
  122.     IF x8 < oldx8 THEN z(7) = 0
  123.     IF x < oldx THEN z(8) = 0
  124.  
  125.     IF z(1) = 0 THEN
  126.         'Mercury
  127.         CIRCLE (x1, y1), 5, _RGB32(120, 98, 102)
  128.         PAINT (x1, y1), _RGB32(120, 98, 102)
  129.     END IF
  130.  
  131.     IF z(2) = 0 THEN
  132.         'Venus
  133.         CIRCLE (x2, y2), 5, _RGB32(161, 67, 39)
  134.         PAINT (x2, y2), _RGB32(161, 67, 39)
  135.     END IF
  136.  
  137.     IF z(8) = 0 THEN
  138.         'Earth
  139.         CIRCLE (x, y), 5, _RGB32(0, 0, 255)
  140.         PAINT (x, y), _RGB32(0, 0, 255)
  141.         'Moon
  142.         CIRCLE (x4, y4), 2.5, _RGB32(179, 179, 181)
  143.         PAINT (x4, y4), _RGB32(179, 179, 181)
  144.     END IF
  145.     IF z(3) = 0 THEN
  146.         'Mars
  147.         CIRCLE (x3, y3), 5, _RGB32(240, 72, 22)
  148.         PAINT (x3, y3), _RGB32(240, 72, 22)
  149.     END IF
  150.     IF z(4) = 0 THEN
  151.         'Outer Planets
  152.         'Jupiter
  153.         CIRCLE (x5, y5), 5, _RGB32(255, 166, 127)
  154.         PAINT (x5, y5), _RGB32(255, 166, 127)
  155.     END IF
  156.     IF z(5) = 0 THEN
  157.         'Saturn
  158.         CIRCLE (x6, y6), 5, _RGB32(255, 127, 127)
  159.         PAINT (x6, y6), _RGB32(255, 127, 127)
  160.         FOR rings = 1 TO 2
  161.             CIRCLE (x6, y6), 7 + rings, _RGB32(255, 127, 127), , , .65
  162.         NEXT rings
  163.     END IF
  164.     IF z(6) = 0 THEN
  165.         'Uranus
  166.         CIRCLE (x7, y7), 5, _RGB32(127, 166, 255)
  167.         PAINT (x7, y7), _RGB32(127, 166, 255)
  168.     END IF
  169.     IF z(7) = 0 THEN
  170.         'Neptune
  171.         CIRCLE (x8, y8), 5, _RGB32(0, 78, 255)
  172.         PAINT (x8, y8), _RGB32(0, 78, 255)
  173.     END IF
  174.  
  175.  
  176.     'Mercury
  177.     CIRCLE (x1, y1), 5, _RGB32(120, 98, 102)
  178.     PAINT (x1, y1), _RGB32(120, 98, 102)
  179.  
  180.     'Venus
  181.     CIRCLE (x2, y2), 5, _RGB32(161, 67, 39)
  182.     PAINT (x2, y2), _RGB32(161, 67, 39)
  183.  
  184.     'Earth
  185.     CIRCLE (x, y), 5, _RGB32(0, 0, 255)
  186.     PAINT (x, y), _RGB32(0, 0, 255)
  187.     'Moon
  188.     CIRCLE (x4, y4), 2.5, _RGB32(179, 179, 181)
  189.     PAINT (x4, y4), _RGB32(179, 179, 181)
  190.  
  191.     'Mars
  192.     CIRCLE (x3, y3), 5, _RGB32(240, 72, 22)
  193.     PAINT (x3, y3), _RGB32(240, 72, 22)
  194.  
  195.     'Outer Planets
  196.     'Jupiter
  197.     CIRCLE (x5, y5), 5, _RGB32(255, 166, 127)
  198.     PAINT (x5, y5), _RGB32(255, 166, 127)
  199.  
  200.     'Saturn
  201.     CIRCLE (x6, y6), 5, _RGB32(255, 127, 127)
  202.     PAINT (x6, y6), _RGB32(255, 127, 127)
  203.     FOR rings = 1 TO 2
  204.         CIRCLE (x6, y6), 7 + rings, _RGB32(255, 127, 127), , , .65
  205.     NEXT rings
  206.  
  207.     'Uranus
  208.     CIRCLE (x7, y7), 5, _RGB32(127, 166, 255)
  209.     PAINT (x7, y7), _RGB32(127, 166, 255)
  210.  
  211.     'Neptune
  212.     CIRCLE (x8, y8), 5, _RGB32(0, 78, 255)
  213.     PAINT (x8, y8), _RGB32(0, 78, 255)
  214.  
  215. IF seconds > 99999 THEN
  216.     CLS
  217.     seconds = 0
  218.     GOTO one:
  219. GOTO one:
  220.  
  221.  
Title: Re: Star Backgound
Post by: SierraKen on August 19, 2019, 02:53:48 am
Here is a much nicer version. The planets stay appeared until right before they go behind the Sun. I also made Saturn look better.

Code: QB64: [Select]
  1. 'Ken G. made thie program on August 18, 2019,
  2. 'Thank you to STxAxTIC on the QB64.org forum for a little bit of help with The Moon orbit!
  3.  
  4. _TITLE "Solar System Simulator by Ken G. Use Mouse Over Planets, Mouse Wheel to Zoom, and Up and Down Arrow Keys To Tilt."
  5. SCREEN _NEWIMAGE(800, 600, 32)
  6. DIM z(10)
  7. mercury = 0.241
  8. venus = 0.6152
  9. mars = 1.8809
  10. jupiter = 11.8618
  11. saturn = 29.457
  12. uranus = 84.0205
  13. neptune = 164.8
  14. angle = 180
  15. tilt = 1
  16. one:
  17. _LIMIT 500
  18. mouseWheel = 0
  19.     mouseX = _MOUSEX
  20.     mouseY = _MOUSEY
  21.     mouseLeftButton = _MOUSEBUTTON(1)
  22.     mouseRightButton = _MOUSEBUTTON(2)
  23.     mouseMiddleButton = _MOUSEBUTTON(3)
  24.     mouseWheel = mouseWheel + _MOUSEWHEEL
  25. IF mouseWheel < 0 THEN angle = angle - 10
  26. IF mouseWheel > 0 THEN angle = angle + 10
  27.  
  28. IF mouseX > 385 AND mouseX < 415 AND mouseY > 285 AND mouseY < 315 THEN LOCATE 2, 49: PRINT "Sun    "
  29. IF mouseX > x1 - 15 AND mouseX < x1 + 15 AND mouseY > y1 - 15 AND mouseY < y1 + 15 THEN LOCATE 2, 49: PRINT "Mercury"
  30. IF mouseX > x2 - 15 AND mouseX < x2 + 15 AND mouseY > y2 - 15 AND mouseY < y2 + 15 THEN LOCATE 2, 49: PRINT "Venus  "
  31. IF mouseX > x - 15 AND mouseX < x + 15 AND mouseY > y - 15 AND mouseY < y + 15 THEN LOCATE 2, 49: PRINT "Earth  "
  32. IF mouseX > x3 - 15 AND mouseX < x3 + 15 AND mouseY > y3 - 15 AND mouseY < y3 + 15 THEN LOCATE 2, 49: PRINT "Mars   "
  33. IF mouseX > x5 - 15 AND mouseX < x5 + 15 AND mouseY > y5 - 15 AND mouseY < y5 + 15 THEN LOCATE 2, 49: PRINT "Jupiter"
  34. IF mouseX > x6 - 15 AND mouseX < x6 + 15 AND mouseY > y6 - 15 AND mouseY < y6 + 15 THEN LOCATE 2, 49: PRINT "Saturn "
  35. IF mouseX > x7 - 15 AND mouseX < x7 + 15 AND mouseY > y7 - 15 AND mouseY < y7 + 15 THEN LOCATE 2, 49: PRINT "Uranus "
  36. IF mouseX > x8 - 15 AND mouseX < x8 + 15 AND mouseY > y8 - 15 AND mouseY < y8 + 15 THEN LOCATE 2, 49: PRINT "Neptune"
  37.  
  38. a$ = INKEY$
  39. IF a$ = CHR$(27) THEN END
  40. IF a$ = CHR$(0) + CHR$(72) THEN tilt = tilt + 1
  41. IF a$ = CHR$(0) + CHR$(80) THEN tilt = tilt - 1
  42. IF angle > 360 THEN angle = 360
  43. IF angle < 10 THEN angle = 10
  44. IF tilt > 50 THEN tilt = 50
  45. IF tilt < 1 THEN tilt = 1
  46. seconds = seconds + .01
  47. s1 = (60 - seconds) * 6 + 180 / mercury
  48. s2 = (60 - seconds) * 6 + 180 / venus
  49. s3 = (60 - seconds) * 6 + 180 'Earth and Moon
  50. s4 = (60 - seconds) * 6 + 180 / mars
  51. s5 = (60 - seconds) * 6 + 180 / jupiter
  52. s6 = (60 - seconds) * 6 + 180 / saturn
  53. s7 = (60 - seconds) * 6 + 180 / uranus
  54. s8 = (60 - seconds) * 6 + 180 / neptune
  55.  
  56.  
  57. 'Mercury
  58. oldx1 = x1
  59. x1 = INT(SIN(s1 / 45 * 3.141592) * angle / 4) + 400
  60. y1 = INT(COS(s1 / 45 * 3.141592) * (angle / 4) / tilt) + 300
  61.  
  62. 'Venus
  63. oldx2 = x2
  64. x2 = INT(SIN(s2 / 90 * 3.141592) * angle / 2) + 400
  65. y2 = INT(COS(s2 / 90 * 3.141592) * (angle / 2) / tilt) + 300
  66.  
  67. 'Earth
  68. oldx = x
  69. x = INT(SIN(s3 / 180 * 3.141592) * angle) + 400
  70. y = INT(COS(s3 / 180 * 3.141592) * angle / tilt) + 300
  71.  
  72. 'Mars
  73. oldx3 = x3
  74. x3 = INT(SIN(s4 / 270 * 3.141592) * angle * 1.5) + 400
  75. y3 = INT(COS(s4 / 270 * 3.141592) * (angle * 1.5) / tilt) + 300
  76.  
  77. 'Moon
  78. x4 = INT(SIN(19 * s3 / 270 * 3.141592) * angle / 10) + x
  79. y4 = INT(COS(19 * s3 / 270 * 3.141592) * (angle / 10) / tilt) + y
  80.  
  81. 'Outer Planets
  82. 'Jupiter
  83. oldx5 = x5
  84. x5 = INT(SIN(s5 / 450 * 3.141592) * angle * 3) + 400
  85. y5 = INT(COS(s5 / 450 * 3.141592) * (angle * 3) / tilt) + 300
  86.  
  87. 'Saturn
  88. oldx6 = x6
  89. x6 = INT(SIN(s6 / 630 * 3.141592) * angle * 4.5) + 400
  90. y6 = INT(COS(s6 / 630 * 3.141592) * (angle * 4.5) / tilt) + 300
  91.  
  92. 'Uranus
  93. oldx7 = x7
  94. x7 = INT(SIN(s7 / 810 * 3.141592) * angle * 6) + 400
  95. y7 = INT(COS(s7 / 810 * 3.141592) * (angle * 6) / tilt) + 300
  96.  
  97. 'Neptune
  98. oldx8 = x8
  99. x8 = INT(SIN(s8 / 990 * 3.141592) * angle * 7.5) + 400
  100. y8 = INT(COS(s8 / 990 * 3.141592) * (angle * 7.5) / tilt) + 300
  101.  
  102.  
  103. 'Sun
  104. CIRCLE (400, 300), 5, _RGB32(249, 240, 22)
  105. PAINT (400, 300), _RGB32(249, 240, 22)
  106.  
  107. IF tilt > 6 THEN
  108.     IF x1 > oldx1 AND x1 > 375 AND x1 < 425 THEN z(1) = 1
  109.     IF x2 > oldx2 AND x2 > 375 AND x2 < 425 THEN z(2) = 1
  110.     IF x3 > oldx3 AND x3 > 375 AND x3 < 425 THEN z(3) = 1
  111.     IF x5 > oldx5 AND x5 > 375 AND x5 < 425 THEN z(4) = 1
  112.     IF x6 > oldx6 AND x6 > 375 AND x6 < 425 THEN z(5) = 1
  113.     IF x7 > oldx7 AND x7 > 375 AND x7 < 425 THEN z(6) = 1
  114.     IF x8 > oldx8 AND x8 > 375 AND x8 < 425 THEN z(7) = 1
  115.     IF x > oldx AND x > 375 AND x < 425 THEN z(8) = 1
  116.  
  117.     IF x1 > oldx1 AND x1 > 424 THEN z(1) = 0
  118.     IF x2 > oldx2 AND x2 > 424 THEN z(2) = 0
  119.     IF x3 > oldx3 AND x3 > 424 THEN z(3) = 0
  120.     IF x5 > oldx5 AND x5 > 424 THEN z(4) = 0
  121.     IF x6 > oldx6 AND x6 > 424 THEN z(5) = 0
  122.     IF x7 > oldx7 AND x7 > 424 THEN z(6) = 0
  123.     IF x8 > oldx8 AND x8 > 424 THEN z(7) = 0
  124.     IF x > oldx AND x > 424 THEN z(8) = 0
  125.  
  126.  
  127.     IF x1 < oldx1 THEN z(1) = 0
  128.     IF x2 < oldx2 THEN z(2) = 0
  129.     IF x3 < oldx3 THEN z(3) = 0
  130.     IF x5 < oldx5 THEN z(4) = 0
  131.     IF x6 < oldx6 THEN z(5) = 0
  132.     IF x7 < oldx7 THEN z(6) = 0
  133.     IF x8 < oldx8 THEN z(7) = 0
  134.     IF x < oldx THEN z(8) = 0
  135.  
  136.     IF z(1) = 0 THEN
  137.         'Mercury
  138.         CIRCLE (x1, y1), 5, _RGB32(120, 98, 102)
  139.         PAINT (x1, y1), _RGB32(120, 98, 102)
  140.     END IF
  141.  
  142.     IF z(2) = 0 THEN
  143.         'Venus
  144.         CIRCLE (x2, y2), 5, _RGB32(161, 67, 39)
  145.         PAINT (x2, y2), _RGB32(161, 67, 39)
  146.     END IF
  147.  
  148.     IF z(8) = 0 THEN
  149.         'Earth
  150.         CIRCLE (x, y), 5, _RGB32(0, 0, 255)
  151.         PAINT (x, y), _RGB32(0, 0, 255)
  152.         'Moon
  153.         CIRCLE (x4, y4), 2.5, _RGB32(179, 179, 181)
  154.         PAINT (x4, y4), _RGB32(179, 179, 181)
  155.     END IF
  156.     IF z(3) = 0 THEN
  157.         'Mars
  158.         CIRCLE (x3, y3), 5, _RGB32(240, 72, 22)
  159.         PAINT (x3, y3), _RGB32(240, 72, 22)
  160.     END IF
  161.     IF z(4) = 0 THEN
  162.         'Outer Planets
  163.         'Jupiter
  164.         CIRCLE (x5, y5), 5, _RGB32(255, 166, 127)
  165.         PAINT (x5, y5), _RGB32(255, 166, 127)
  166.     END IF
  167.     IF z(5) = 0 THEN
  168.         'Saturn
  169.         CIRCLE (x6, y6), 5, _RGB32(255, 127, 127)
  170.         PAINT (x6, y6), _RGB32(255, 127, 127)
  171.         FOR rings = 4 TO 5
  172.             CIRCLE (x6, y6), 7 + rings, _RGB32(255, 127, 127), , , .2
  173.         NEXT rings
  174.     END IF
  175.     IF z(6) = 0 THEN
  176.         'Uranus
  177.         CIRCLE (x7, y7), 5, _RGB32(127, 166, 255)
  178.         PAINT (x7, y7), _RGB32(127, 166, 255)
  179.     END IF
  180.     IF z(7) = 0 THEN
  181.         'Neptune
  182.         CIRCLE (x8, y8), 5, _RGB32(0, 78, 255)
  183.         PAINT (x8, y8), _RGB32(0, 78, 255)
  184.     END IF
  185.  
  186.  
  187.     'Mercury
  188.     CIRCLE (x1, y1), 5, _RGB32(120, 98, 102)
  189.     PAINT (x1, y1), _RGB32(120, 98, 102)
  190.  
  191.     'Venus
  192.     CIRCLE (x2, y2), 5, _RGB32(161, 67, 39)
  193.     PAINT (x2, y2), _RGB32(161, 67, 39)
  194.  
  195.     'Earth
  196.     CIRCLE (x, y), 5, _RGB32(0, 0, 255)
  197.     PAINT (x, y), _RGB32(0, 0, 255)
  198.     'Moon
  199.     CIRCLE (x4, y4), 2.5, _RGB32(179, 179, 181)
  200.     PAINT (x4, y4), _RGB32(179, 179, 181)
  201.  
  202.     'Mars
  203.     CIRCLE (x3, y3), 5, _RGB32(240, 72, 22)
  204.     PAINT (x3, y3), _RGB32(240, 72, 22)
  205.  
  206.     'Outer Planets
  207.     'Jupiter
  208.     CIRCLE (x5, y5), 5, _RGB32(255, 166, 127)
  209.     PAINT (x5, y5), _RGB32(255, 166, 127)
  210.  
  211.     'Saturn
  212.     CIRCLE (x6, y6), 5, _RGB32(255, 127, 127)
  213.     PAINT (x6, y6), _RGB32(255, 127, 127)
  214.     FOR rings = 1 TO 2
  215.         CIRCLE (x6, y6), 7 + rings, _RGB32(255, 127, 127), , , .65
  216.     NEXT rings
  217.  
  218.     'Uranus
  219.     CIRCLE (x7, y7), 5, _RGB32(127, 166, 255)
  220.     PAINT (x7, y7), _RGB32(127, 166, 255)
  221.  
  222.     'Neptune
  223.     CIRCLE (x8, y8), 5, _RGB32(0, 78, 255)
  224.     PAINT (x8, y8), _RGB32(0, 78, 255)
  225.  
  226. IF seconds > 99999 THEN
  227.     CLS
  228.     seconds = 0
  229.     GOTO one:
  230. GOTO one:
  231.  
  232.  
Title: Re: Star Backgound
Post by: SierraKen on August 19, 2019, 02:56:41 am
Here is a better version, thanks to B+ for the comments in the other thread. This one hides the planets when they go further away.

(Note: Please go to my next one, thanks.)

Code: QB64: [Select]
  1. 'Ken G. made thie program on August 18, 2019,
  2. 'Thank you to STxAxTIC on the QB64.org forum for a little bit of help with The Moon orbit!
  3.  
  4. _TITLE "Solar System Simulator by Ken G. Use Mouse Over Planets, Mouse Wheel to Zoom, and Up and Down Arrow Keys To Tilt."
  5. SCREEN _NEWIMAGE(800, 600, 32)
  6. DIM z(10)
  7. mercury = 0.241
  8. venus = 0.6152
  9. mars = 1.8809
  10. jupiter = 11.8618
  11. saturn = 29.457
  12. uranus = 84.0205
  13. neptune = 164.8
  14. angle = 180
  15. tilt = 1
  16. one:
  17. _LIMIT 500
  18. mouseWheel = 0
  19.     mouseX = _MOUSEX
  20.     mouseY = _MOUSEY
  21.     mouseLeftButton = _MOUSEBUTTON(1)
  22.     mouseRightButton = _MOUSEBUTTON(2)
  23.     mouseMiddleButton = _MOUSEBUTTON(3)
  24.     mouseWheel = mouseWheel + _MOUSEWHEEL
  25. IF mouseWheel < 0 THEN angle = angle - 10
  26. IF mouseWheel > 0 THEN angle = angle + 10
  27.  
  28. IF mouseX > 385 AND mouseX < 415 AND mouseY > 285 AND mouseY < 315 THEN LOCATE 2, 49: PRINT "Sun    "
  29. IF mouseX > x1 - 15 AND mouseX < x1 + 15 AND mouseY > y1 - 15 AND mouseY < y1 + 15 THEN LOCATE 2, 49: PRINT "Mercury"
  30. IF mouseX > x2 - 15 AND mouseX < x2 + 15 AND mouseY > y2 - 15 AND mouseY < y2 + 15 THEN LOCATE 2, 49: PRINT "Venus  "
  31. IF mouseX > x - 15 AND mouseX < x + 15 AND mouseY > y - 15 AND mouseY < y + 15 THEN LOCATE 2, 49: PRINT "Earth  "
  32. IF mouseX > x3 - 15 AND mouseX < x3 + 15 AND mouseY > y3 - 15 AND mouseY < y3 + 15 THEN LOCATE 2, 49: PRINT "Mars   "
  33. IF mouseX > x5 - 15 AND mouseX < x5 + 15 AND mouseY > y5 - 15 AND mouseY < y5 + 15 THEN LOCATE 2, 49: PRINT "Jupiter"
  34. IF mouseX > x6 - 15 AND mouseX < x6 + 15 AND mouseY > y6 - 15 AND mouseY < y6 + 15 THEN LOCATE 2, 49: PRINT "Saturn "
  35. IF mouseX > x7 - 15 AND mouseX < x7 + 15 AND mouseY > y7 - 15 AND mouseY < y7 + 15 THEN LOCATE 2, 49: PRINT "Uranus "
  36. IF mouseX > x8 - 15 AND mouseX < x8 + 15 AND mouseY > y8 - 15 AND mouseY < y8 + 15 THEN LOCATE 2, 49: PRINT "Neptune"
  37.  
  38. a$ = INKEY$
  39. IF a$ = CHR$(27) THEN END
  40. IF a$ = CHR$(0) + CHR$(72) THEN tilt = tilt + 1
  41. IF a$ = CHR$(0) + CHR$(80) THEN tilt = tilt - 1
  42. IF angle > 360 THEN angle = 360
  43. IF angle < 10 THEN angle = 10
  44. IF tilt > 30 THEN tilt = 30
  45. IF tilt < 1 THEN tilt = 1
  46. seconds = seconds + .01
  47. s1 = (60 - seconds) * 6 + 180 / mercury
  48. s2 = (60 - seconds) * 6 + 180 / venus
  49. s3 = (60 - seconds) * 6 + 180 'Earth and Moon
  50. s4 = (60 - seconds) * 6 + 180 / mars
  51. s5 = (60 - seconds) * 6 + 180 / jupiter
  52. s6 = (60 - seconds) * 6 + 180 / saturn
  53. s7 = (60 - seconds) * 6 + 180 / uranus
  54. s8 = (60 - seconds) * 6 + 180 / neptune
  55.  
  56.  
  57. 'Mercury
  58. oldx1 = x1
  59. x1 = INT(SIN(s1 / 45 * 3.141592) * angle / 4) + 400
  60. y1 = INT(COS(s1 / 45 * 3.141592) * (angle / 4) / tilt) + 300
  61.  
  62. 'Venus
  63. oldx2 = x2
  64. x2 = INT(SIN(s2 / 90 * 3.141592) * angle / 2) + 400
  65. y2 = INT(COS(s2 / 90 * 3.141592) * (angle / 2) / tilt) + 300
  66.  
  67. 'Earth
  68. oldx = x
  69. x = INT(SIN(s3 / 180 * 3.141592) * angle) + 400
  70. y = INT(COS(s3 / 180 * 3.141592) * angle / tilt) + 300
  71.  
  72. 'Mars
  73. oldx3 = x3
  74. x3 = INT(SIN(s4 / 270 * 3.141592) * angle * 1.5) + 400
  75. y3 = INT(COS(s4 / 270 * 3.141592) * (angle * 1.5) / tilt) + 300
  76.  
  77. 'Moon
  78. x4 = INT(SIN(19 * s3 / 270 * 3.141592) * angle / 10) + x
  79. y4 = INT(COS(19 * s3 / 270 * 3.141592) * (angle / 10) / tilt) + y
  80.  
  81. 'Outer Planets
  82. 'Jupiter
  83. oldx5 = x5
  84. x5 = INT(SIN(s5 / 450 * 3.141592) * angle * 3) + 400
  85. y5 = INT(COS(s5 / 450 * 3.141592) * (angle * 3) / tilt) + 300
  86.  
  87. 'Saturn
  88. oldx6 = x6
  89. x6 = INT(SIN(s6 / 630 * 3.141592) * angle * 4.5) + 400
  90. y6 = INT(COS(s6 / 630 * 3.141592) * (angle * 4.5) / tilt) + 300
  91.  
  92. 'Uranus
  93. oldx7 = x7
  94. x7 = INT(SIN(s7 / 810 * 3.141592) * angle * 6) + 400
  95. y7 = INT(COS(s7 / 810 * 3.141592) * (angle * 6) / tilt) + 300
  96.  
  97. 'Neptune
  98. oldx8 = x8
  99. x8 = INT(SIN(s8 / 990 * 3.141592) * angle * 7.5) + 400
  100. y8 = INT(COS(s8 / 990 * 3.141592) * (angle * 7.5) / tilt) + 300
  101.  
  102.  
  103. 'Sun
  104. CIRCLE (400, 300), 2, _RGB32(249, 240, 22)
  105. PAINT (400, 300), _RGB32(249, 240, 22)
  106.  
  107. IF tilt > 6 THEN
  108.     IF x1 > oldx1 THEN z(1) = 1
  109.     IF x2 > oldx2 THEN z(2) = 1
  110.     IF x3 > oldx3 THEN z(3) = 1
  111.     IF x5 > oldx5 THEN z(4) = 1
  112.     IF x6 > oldx6 THEN z(5) = 1
  113.     IF x7 > oldx7 THEN z(6) = 1
  114.     IF x8 > oldx8 THEN z(7) = 1
  115.     IF x > oldx THEN z(8) = 1
  116.     IF x1 < oldx1 THEN z(1) = 0
  117.     IF x2 < oldx2 THEN z(2) = 0
  118.     IF x3 < oldx3 THEN z(3) = 0
  119.     IF x5 < oldx5 THEN z(4) = 0
  120.     IF x6 < oldx6 THEN z(5) = 0
  121.     IF x7 < oldx7 THEN z(6) = 0
  122.     IF x8 < oldx8 THEN z(7) = 0
  123.     IF x < oldx THEN z(8) = 0
  124.  
  125.     IF z(1) = 0 THEN
  126.         'Mercury
  127.         CIRCLE (x1, y1), 5, _RGB32(120, 98, 102)
  128.         PAINT (x1, y1), _RGB32(120, 98, 102)
  129.     END IF
  130.  
  131.     IF z(2) = 0 THEN
  132.         'Venus
  133.         CIRCLE (x2, y2), 5, _RGB32(161, 67, 39)
  134.         PAINT (x2, y2), _RGB32(161, 67, 39)
  135.     END IF
  136.  
  137.     IF z(8) = 0 THEN
  138.         'Earth
  139.         CIRCLE (x, y), 5, _RGB32(0, 0, 255)
  140.         PAINT (x, y), _RGB32(0, 0, 255)
  141.         'Moon
  142.         CIRCLE (x4, y4), 2.5, _RGB32(179, 179, 181)
  143.         PAINT (x4, y4), _RGB32(179, 179, 181)
  144.     END IF
  145.     IF z(3) = 0 THEN
  146.         'Mars
  147.         CIRCLE (x3, y3), 5, _RGB32(240, 72, 22)
  148.         PAINT (x3, y3), _RGB32(240, 72, 22)
  149.     END IF
  150.     IF z(4) = 0 THEN
  151.         'Outer Planets
  152.         'Jupiter
  153.         CIRCLE (x5, y5), 5, _RGB32(255, 166, 127)
  154.         PAINT (x5, y5), _RGB32(255, 166, 127)
  155.     END IF
  156.     IF z(5) = 0 THEN
  157.         'Saturn
  158.         CIRCLE (x6, y6), 5, _RGB32(255, 127, 127)
  159.         PAINT (x6, y6), _RGB32(255, 127, 127)
  160.         FOR rings = 1 TO 2
  161.             CIRCLE (x6, y6), 7 + rings, _RGB32(255, 127, 127), , , .65
  162.         NEXT rings
  163.     END IF
  164.     IF z(6) = 0 THEN
  165.         'Uranus
  166.         CIRCLE (x7, y7), 5, _RGB32(127, 166, 255)
  167.         PAINT (x7, y7), _RGB32(127, 166, 255)
  168.     END IF
  169.     IF z(7) = 0 THEN
  170.         'Neptune
  171.         CIRCLE (x8, y8), 5, _RGB32(0, 78, 255)
  172.         PAINT (x8, y8), _RGB32(0, 78, 255)
  173.     END IF
  174.  
  175.  
  176.     'Mercury
  177.     CIRCLE (x1, y1), 5, _RGB32(120, 98, 102)
  178.     PAINT (x1, y1), _RGB32(120, 98, 102)
  179.  
  180.     'Venus
  181.     CIRCLE (x2, y2), 5, _RGB32(161, 67, 39)
  182.     PAINT (x2, y2), _RGB32(161, 67, 39)
  183.  
  184.     'Earth
  185.     CIRCLE (x, y), 5, _RGB32(0, 0, 255)
  186.     PAINT (x, y), _RGB32(0, 0, 255)
  187.     'Moon
  188.     CIRCLE (x4, y4), 2.5, _RGB32(179, 179, 181)
  189.     PAINT (x4, y4), _RGB32(179, 179, 181)
  190.  
  191.     'Mars
  192.     CIRCLE (x3, y3), 5, _RGB32(240, 72, 22)
  193.     PAINT (x3, y3), _RGB32(240, 72, 22)
  194.  
  195.     'Outer Planets
  196.     'Jupiter
  197.     CIRCLE (x5, y5), 5, _RGB32(255, 166, 127)
  198.     PAINT (x5, y5), _RGB32(255, 166, 127)
  199.  
  200.     'Saturn
  201.     CIRCLE (x6, y6), 5, _RGB32(255, 127, 127)
  202.     PAINT (x6, y6), _RGB32(255, 127, 127)
  203.     FOR rings = 1 TO 2
  204.         CIRCLE (x6, y6), 7 + rings, _RGB32(255, 127, 127), , , .65
  205.     NEXT rings
  206.  
  207.     'Uranus
  208.     CIRCLE (x7, y7), 5, _RGB32(127, 166, 255)
  209.     PAINT (x7, y7), _RGB32(127, 166, 255)
  210.  
  211.     'Neptune
  212.     CIRCLE (x8, y8), 5, _RGB32(0, 78, 255)
  213.     PAINT (x8, y8), _RGB32(0, 78, 255)
  214.  
  215. IF seconds > 99999 THEN
  216.     CLS
  217.     seconds = 0
  218.     GOTO one:
  219. GOTO one:
  220.  
  221.  
Title: Re: Star Backgound
Post by: OldMoses on August 19, 2019, 07:32:06 am
Your tilting function is pretty cool, that's something I've not tried to do with 3D simulations. I'm going to be studying that one. Thanks.
Title: Re: Star Backgound
Post by: SierraKen on August 19, 2019, 01:05:49 pm
Welcome OldMoses, you can also thank B+ for this thread, which gave me the idea to switch views from 2D to 3D. :)