QB64 Phoenix Edition
Resizeable Spinning Globe - Printable Version

+- QB64 Phoenix Edition (https://qb64phoenix.com/forum)
+-- Forum: QB64 Rising (https://qb64phoenix.com/forum/forumdisplay.php?fid=1)
+--- Forum: Code and Stuff (https://qb64phoenix.com/forum/forumdisplay.php?fid=3)
+---- Forum: Programs (https://qb64phoenix.com/forum/forumdisplay.php?fid=7)
+---- Thread: Resizeable Spinning Globe (/showthread.php?tid=3687)



Resizeable Spinning Globe - SierraKen - 05-13-2025

I got most of this math from a BASIC Programming FB group I belong to and some from ChatGPT.... because I'm horrible at math. lol

Select the X,Y,Z size of your globe and the speed then watch it spin. Press Space Bar to make another one or Esc to quit.
This could be used in some kind of space game or model. 


Code: (Select All)

_Title "Globe Spin - Space Bar For Another One - Esc To End"

Screen _NewImage(800, 600, 32)
Do
    start:
    Cls
    Input "XRADIUS (10-500)="; XRADIUS
    If XRADIUS < 10 Or XRADIUS > 500 Then GoTo start
    Input "YRADIUS (10-500)="; YRADIUS
    If YRADIUS < 10 Or YRADIUS > 500 Then GoTo start
    Input "ZRADIUS (10-500)="; ZRADIUS
    If ZRADIUS < 10 Or ZRADIUS > 500 Then GoTo start
    Input "SPEED (-20 to 20)"; speed
    If speed < -20 Or speed > 20 Then GoTo start
    II = 0
    speed2 = speed / 100
    Do
        For I = 0 To _Pi Step .2 ' Latitude angle (from pole to pole)
            For K = II To 2 * _Pi + II Step .2 ' Longitude angle (rotation)
                X = XRADIUS * Sin(I) * Cos(K)
                Y = YRADIUS * Cos(I)
                Z = ZRADIUS * Sin(I) * Sin(K)
                XPLOT = X + Z / 5 + 400
                YPLOT = Y + Z / 5 + 300
                Line -(XPLOT, YPLOT)
            Next K
        Next I

        ' Draw longitudinal lines (pole to pole)
        For LON = 0 To 2 * _Pi Step .4
            For LAT = 0 To _Pi Step .2
                X = XRADIUS * Sin(LAT) * Cos(LON + II)
                Y = YRADIUS * Cos(LAT)
                Z = ZRADIUS * Sin(LAT) * Sin(LON + II)
                XPLOT = X + Z / 5 + 400
                YPLOT = Y + Z / 5 + 300
                Line -(XPLOT, YPLOT)
            Next LAT
        Next LON

        II = II + speed2
        Locate 1, 1: Print "XRADIUS: "; XRADIUS
        Locate 2, 1: Print "YRADIUS: "; YRADIUS
        Locate 3, 1: Print "ZRADIUS: "; ZRADIUS
        Locate 4, 1: Print "SPEED: "; speed
        _Delay .1
        If a$ = Chr$(27) Then End
        _Display
        Cls
        a$ = InKey$
    Loop Until a$ = " "
Loop



RE: Resizeable Spinning Globe - NakedApe - 05-13-2025

@SierraKen  Soon I’ll be posting a space game using a modded version of your first AI globe program from a few months ago. It’s almost done - I think. I’ll put it in the WIP zone so people can make suggestions. Thanks for that code. Smile


RE: Resizeable Spinning Globe - SierraKen - 05-13-2025

@NakedApe That's fantastic!!! I can't wait to play. Smile