Subject: O R B I T

From: "roundf" <[email-masked]>
Date: Sat, 03 Sep 2011 21:32:54 -0000

I have a sprite planet orbiting a stationary "sun". It orbits in a diamond shape
by using call motion. Is there a way to produce a circular or even elliptical
orbit? Maybe by using SINE somehow?

James

100 !SAVE DSK1.ORBIT
110 CALL CLEAR :: CALL SCREEN(2)
120 R=INT(RND*24)+1 :: C=INT(RND*32)+1
130 CALL CHAR(96,"183C7EFF7E3C1800")!CHARSET 9
140 CALL CHAR(88,"FFFFFFFFFFFFFFFF")
150 CALL CHAR(89,"FFFEFCF8F0E0C080")
160 CALL CHAR(90,"FF7F3F1F0F070301")
170 CALL CHAR(91,"80C0E0F0F8FCFEFF")
180 CALL CHAR(92,"0103070F1F3F7FFF")
190 CALL CHAR(104,"0000001818000000")
200 CALL COLOR(8,12,2,10,16,2)
210 RV=0 :: CV=5
220 CALL HCHAR(11,16,88,2)
230 CALL HCHAR(12,15,88,4)
240 CALL HCHAR(13,16,88,2)
250 CALL HCHAR(11,15,92)
260 CALL HCHAR(13,15,90)
270 CALL HCHAR(11,18,91)
280 CALL HCHAR(13,18,89)
285 FOR I=1 TO 30
287 R=INT(RND*24)+1 :: C=INT(RND*32)+1
290 CALL HCHAR(R,C,104)
291 NEXT I
300 CALL SPRITE(#1,96,10,89,121,RV,CV)
310 RV=0 :: CV=5
320 FOR I=1 TO 700 :: NEXT I
330 CALL MOTION(#1,5,-5)
340 FOR I=1 TO 700 :: NEXT I
350 CALL MOTION(#1,-5,-5)
360 FOR I=1 TO 700 :: NEXT I
370 CALL MOTION(#1,-5,5)
380 FOR I=1 TO 700 :: NEXT I
390 CALL MOTION(#1,5,5)
400 GOTO 320

---

From: "Michael Zapf" <[email-masked]>
Date: Sun, 04 Sep 2011 12:46:01 -0000

Hi,

> orbit? Maybe by using SINE somehow?

I remember I once wrote a program in C to simulate a multibody problem scenario where you have several masses being attracted to each other.

In your case I'd also suggest to simulate physics. That is, have the "planet" be accelerated by the sun. In a loop you continuously calculate the distance between the planet and the sun in x/y coordinates. Use some variables for the x and y motion of the planet. This is the motion vector of the planet. Within the loop, you add a motion offset vector which you calculate from the distance vector.

The physical background of this is the following: The motion of the planet is a result of its own current motion (vector) and the acceleration by the sun. The acceleration (g) results in a instantaneous change of motion in reality, but in this case we need to use a discrete time scale, as the BASIC program has a limited speed. So for this delta t between two iterations you have an approximation of the motion offset by this acceleration multiplied by the time step length (g * delta t). What you need to do is to properly calculate this acceleration g. It depends on the distance between the sun and the planet and the mass of the sun. The mass of the planet must be multiplied to the g*delta t. 

Needs some experimenting, and remember that your motion vector must not be (0,0) at the start, or the planet will hit the sun very quickly.

Michael