Re: Programming question

From: Andrew Wilson <atwilson_at_home.com>
Date: Wed Oct 27 1999 - 17:53:32 EDT

>I have everything figured out except how to get the square root of
>lengthsqr.

        Well, you could probably look up a Taylor sequence for it, but complex
polynomials aren't gonna be fun to do in 6502 asm. You are just looking for
good gameplay and not anything absolutely precise, so you might just try
adjusting the gravity linearly, based on the distance. So rather than
calculating the square root, just get the distance, and do something like:

        if (distanceX < 10)
                scaleX = 1;
        if (distanceX < 20)
                scaleX = 2;
        if (distanceX < 30)
                scaleX = 4;

                ...etc...

        I just made up the numbers there, but you get the idea. Then you can
do this:

        speed.x += gravity_constant/scaleX;

All you want is the gravity to be stronger as you approach the star, and I'll
bet it doesn't effect game play if you cheat a little bit. Alternatively,
if you've got some RAM/ROM to burn, you could table drive the X/Y gravity
values (which is essentially what the if clause is doing above).

                        Drew

        
Received on Wed Oct 27 16:53:33 1999

This archive was generated by hypermail 2.1.8 : Fri Aug 01 2003 - 00:32:47 EDT