Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Resizeable Spinning Globe
#1
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
Reply
#2
@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
Reply
#3
@NakedApe That's fantastic!!! I can't wait to play. Smile
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Happy New Year Globe! SierraKen 2 817 01-01-2025, 08:57 PM
Last Post: SierraKen
  Lightning Globe SMcNeill 4 1,189 09-16-2024, 04:49 AM
Last Post: SierraKen
  Are These Dots Spinning? bplus 6 1,402 02-18-2023, 04:14 PM
Last Post: bplus
  My Best Globe So Far SierraKen 6 1,398 08-22-2022, 12:18 AM
Last Post: bplus

Forum Jump:


Users browsing this thread: 1 Guest(s)