Subscribe to our YouTube channel.Tutorials and more athttps://www.youtube.com/c/QB64Team.
0 Members and 1 Guest are viewing this topic.
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]'Ken G. made thie program on August 18, 2019,'Thank you to STxAxTIC on the QB64.org forum for a little bit of help with The Moon orbit! _TITLE "Solar System Simulator by Ken G. Use Mouse Over Planets, Mouse Wheel to Zoom, and Up and Down Arrow Keys To Tilt."SCREEN _NEWIMAGE(800, 600, 32)DIM z(10)mercury = 0.241venus = 0.6152mars = 1.8809jupiter = 11.8618saturn = 29.457uranus = 84.0205neptune = 164.8angle = 180tilt = 1one:_LIMIT 500mouseWheel = 0DO WHILE _MOUSEINPUT mouseX = _MOUSEX mouseY = _MOUSEY mouseLeftButton = _MOUSEBUTTON(1) mouseRightButton = _MOUSEBUTTON(2) mouseMiddleButton = _MOUSEBUTTON(3) mouseWheel = mouseWheel + _MOUSEWHEELLOOPIF mouseWheel < 0 THEN angle = angle - 10IF mouseWheel > 0 THEN angle = angle + 10 IF mouseX > 385 AND mouseX < 415 AND mouseY > 285 AND mouseY < 315 THEN LOCATE 2, 49: PRINT "Sun "IF mouseX > x1 - 15 AND mouseX < x1 + 15 AND mouseY > y1 - 15 AND mouseY < y1 + 15 THEN LOCATE 2, 49: PRINT "Mercury"IF mouseX > x2 - 15 AND mouseX < x2 + 15 AND mouseY > y2 - 15 AND mouseY < y2 + 15 THEN LOCATE 2, 49: PRINT "Venus "IF mouseX > x - 15 AND mouseX < x + 15 AND mouseY > y - 15 AND mouseY < y + 15 THEN LOCATE 2, 49: PRINT "Earth "IF mouseX > x3 - 15 AND mouseX < x3 + 15 AND mouseY > y3 - 15 AND mouseY < y3 + 15 THEN LOCATE 2, 49: PRINT "Mars "IF mouseX > x5 - 15 AND mouseX < x5 + 15 AND mouseY > y5 - 15 AND mouseY < y5 + 15 THEN LOCATE 2, 49: PRINT "Jupiter"IF mouseX > x6 - 15 AND mouseX < x6 + 15 AND mouseY > y6 - 15 AND mouseY < y6 + 15 THEN LOCATE 2, 49: PRINT "Saturn "IF mouseX > x7 - 15 AND mouseX < x7 + 15 AND mouseY > y7 - 15 AND mouseY < y7 + 15 THEN LOCATE 2, 49: PRINT "Uranus "IF mouseX > x8 - 15 AND mouseX < x8 + 15 AND mouseY > y8 - 15 AND mouseY < y8 + 15 THEN LOCATE 2, 49: PRINT "Neptune" a$ = INKEY$IF a$ = CHR$(27) THEN ENDIF a$ = CHR$(0) + CHR$(72) THEN tilt = tilt + 1IF a$ = CHR$(0) + CHR$(80) THEN tilt = tilt - 1IF angle > 360 THEN angle = 360IF angle < 10 THEN angle = 10IF tilt > 30 THEN tilt = 30IF tilt < 1 THEN tilt = 1seconds = seconds + .01s1 = (60 - seconds) * 6 + 180 / mercurys2 = (60 - seconds) * 6 + 180 / venuss3 = (60 - seconds) * 6 + 180 'Earth and Moons4 = (60 - seconds) * 6 + 180 / marss5 = (60 - seconds) * 6 + 180 / jupiters6 = (60 - seconds) * 6 + 180 / saturns7 = (60 - seconds) * 6 + 180 / uranuss8 = (60 - seconds) * 6 + 180 / neptune 'Mercuryoldx1 = x1x1 = INT(SIN(s1 / 45 * 3.141592) * angle / 4) + 400y1 = INT(COS(s1 / 45 * 3.141592) * (angle / 4) / tilt) + 300 'Venusoldx2 = x2x2 = INT(SIN(s2 / 90 * 3.141592) * angle / 2) + 400y2 = INT(COS(s2 / 90 * 3.141592) * (angle / 2) / tilt) + 300 'Eartholdx = xx = INT(SIN(s3 / 180 * 3.141592) * angle) + 400y = INT(COS(s3 / 180 * 3.141592) * angle / tilt) + 300 'Marsoldx3 = x3x3 = INT(SIN(s4 / 270 * 3.141592) * angle * 1.5) + 400y3 = INT(COS(s4 / 270 * 3.141592) * (angle * 1.5) / tilt) + 300 'Moonx4 = INT(SIN(19 * s3 / 270 * 3.141592) * angle / 10) + xy4 = INT(COS(19 * s3 / 270 * 3.141592) * (angle / 10) / tilt) + y 'Outer Planets'Jupiteroldx5 = x5x5 = INT(SIN(s5 / 450 * 3.141592) * angle * 3) + 400y5 = INT(COS(s5 / 450 * 3.141592) * (angle * 3) / tilt) + 300 'Saturnoldx6 = x6x6 = INT(SIN(s6 / 630 * 3.141592) * angle * 4.5) + 400y6 = INT(COS(s6 / 630 * 3.141592) * (angle * 4.5) / tilt) + 300 'Uranusoldx7 = x7x7 = INT(SIN(s7 / 810 * 3.141592) * angle * 6) + 400y7 = INT(COS(s7 / 810 * 3.141592) * (angle * 6) / tilt) + 300 'Neptuneoldx8 = x8x8 = INT(SIN(s8 / 990 * 3.141592) * angle * 7.5) + 400y8 = INT(COS(s8 / 990 * 3.141592) * (angle * 7.5) / tilt) + 300 'SunCIRCLE (400, 300), 2, _RGB32(249, 240, 22)PAINT (400, 300), _RGB32(249, 240, 22) IF tilt > 6 THEN IF x1 > oldx1 THEN z(1) = 1 IF x2 > oldx2 THEN z(2) = 1 IF x3 > oldx3 THEN z(3) = 1 IF x5 > oldx5 THEN z(4) = 1 IF x6 > oldx6 THEN z(5) = 1 IF x7 > oldx7 THEN z(6) = 1 IF x8 > oldx8 THEN z(7) = 1 IF x > oldx THEN z(8) = 1 IF x1 < oldx1 THEN z(1) = 0 IF x2 < oldx2 THEN z(2) = 0 IF x3 < oldx3 THEN z(3) = 0 IF x5 < oldx5 THEN z(4) = 0 IF x6 < oldx6 THEN z(5) = 0 IF x7 < oldx7 THEN z(6) = 0 IF x8 < oldx8 THEN z(7) = 0 IF x < oldx THEN z(8) = 0 IF z(1) = 0 THEN 'Mercury CIRCLE (x1, y1), 5, _RGB32(120, 98, 102) PAINT (x1, y1), _RGB32(120, 98, 102) END IF IF z(2) = 0 THEN 'Venus CIRCLE (x2, y2), 5, _RGB32(161, 67, 39) PAINT (x2, y2), _RGB32(161, 67, 39) END IF IF z(8) = 0 THEN 'Earth CIRCLE (x, y), 5, _RGB32(0, 0, 255) PAINT (x, y), _RGB32(0, 0, 255) 'Moon CIRCLE (x4, y4), 2.5, _RGB32(179, 179, 181) PAINT (x4, y4), _RGB32(179, 179, 181) END IF IF z(3) = 0 THEN 'Mars CIRCLE (x3, y3), 5, _RGB32(240, 72, 22) PAINT (x3, y3), _RGB32(240, 72, 22) END IF IF z(4) = 0 THEN 'Outer Planets 'Jupiter CIRCLE (x5, y5), 5, _RGB32(255, 166, 127) PAINT (x5, y5), _RGB32(255, 166, 127) END IF IF z(5) = 0 THEN 'Saturn CIRCLE (x6, y6), 5, _RGB32(255, 127, 127) PAINT (x6, y6), _RGB32(255, 127, 127) FOR rings = 1 TO 2 CIRCLE (x6, y6), 7 + rings, _RGB32(255, 127, 127), , , .65 NEXT rings END IF IF z(6) = 0 THEN 'Uranus CIRCLE (x7, y7), 5, _RGB32(127, 166, 255) PAINT (x7, y7), _RGB32(127, 166, 255) END IF IF z(7) = 0 THEN 'Neptune CIRCLE (x8, y8), 5, _RGB32(0, 78, 255) PAINT (x8, y8), _RGB32(0, 78, 255) END IF ELSE 'Mercury CIRCLE (x1, y1), 5, _RGB32(120, 98, 102) PAINT (x1, y1), _RGB32(120, 98, 102) 'Venus CIRCLE (x2, y2), 5, _RGB32(161, 67, 39) PAINT (x2, y2), _RGB32(161, 67, 39) 'Earth CIRCLE (x, y), 5, _RGB32(0, 0, 255) PAINT (x, y), _RGB32(0, 0, 255) 'Moon CIRCLE (x4, y4), 2.5, _RGB32(179, 179, 181) PAINT (x4, y4), _RGB32(179, 179, 181) 'Mars CIRCLE (x3, y3), 5, _RGB32(240, 72, 22) PAINT (x3, y3), _RGB32(240, 72, 22) 'Outer Planets 'Jupiter CIRCLE (x5, y5), 5, _RGB32(255, 166, 127) PAINT (x5, y5), _RGB32(255, 166, 127) 'Saturn CIRCLE (x6, y6), 5, _RGB32(255, 127, 127) PAINT (x6, y6), _RGB32(255, 127, 127) FOR rings = 1 TO 2 CIRCLE (x6, y6), 7 + rings, _RGB32(255, 127, 127), , , .65 NEXT rings 'Uranus CIRCLE (x7, y7), 5, _RGB32(127, 166, 255) PAINT (x7, y7), _RGB32(127, 166, 255) 'Neptune CIRCLE (x8, y8), 5, _RGB32(0, 78, 255) PAINT (x8, y8), _RGB32(0, 78, 255) END IF_DISPLAYIF seconds > 99999 THEN CLS seconds = 0 GOTO one:END IFCLSGOTO one: