Traveling Without Movement ...

Published 2023-06-12


(v00 11-23-22)
TO LOAD THIS PICO-8 CART, in immediate mode, type: load #travwomoving2

Run this cart. Now before you view the source-code, THINK of what it might be. Do you think it's using an array to keep track of the stars ? OK. Perhaps the acceleration speed is being recorded from another floating point array. Fine. How about the color of each star to make sure they stay the same for each row in the display. That would be the regular way to do it, yes.

So that's 3-arrays we need to keep track of, right ? Let's list them out:

Now let's consider something else.

. . .

Here is a scene inside the movie, "DUNE" where Paul, son of Duke Leto of the House Atreides is commenting to himself about what is to follow. They must travel a great distance, farther than any conventional starship can reach, and it is done by the Navigators, fantastic beings with vast powers who have ingested the gas of the spice Melange for many years.

Leto speaks to his son, "Soon they will begin to fold space."

Paul thinks to himself, "Far off in the control rooms of spice gas. Traveling without moving."

. . .

That is much what is happening here. Traveling without moving ...

Like being able to enter any universe at any given time. Like being able to travel through time in the past.

"As long as we know what the results have BEEN, we know what the results will be NOW."

Now let's get back to the code. Do you still think it is 3-arrays controlling the stars ?

No, would you be surprised if I told you NO arrays are controlling the stars ? None whatsoever.

Instead the stars' position, acceleration, and color are all being controlled by one very powerful and often underestimated ability.

That ability is called SEED RANDOM. NOW look at the source-code to see how it was done. I'll wait for you here ...

So in definition, just what does is happening ?

First off the program does not rely on RND() or SRAND() from Pico-8, instead it has my own random number generator based upon a true random number from the beginning that is within the range of -32768.9999 to 32767.9999.

In this in calling the RNND() function, a 'random' number is generated based upon 'shuffling' these values and returning one that matches what we need.

This can be quite useful if you want to have a random set of events occur yet you want those random items to be the same every time. For instance, try this code:

Well even before you run it you know there will be 12-random numbers each a value of 1-6 that will be printed. Yet if you run this program OVER and OVER again, you will get the exact same results every time.

NOW you can see how powerful seeding is ! Not just for saving you from arrays but being able to build procedurally generated maps and worlds that can be repeated and reproduced on the fly with a chosen seed value leading the first random value and that follows to it all.

And using zero variable space in the process. Being able and capable to build whole planets and galaxies of definition and not being forced to use any arrays besides.

Or as above I am repeating the seeded value so the stars will appear in their correct position and are all only being adjusted by a single variable.

Try including my function within your code. See if it doesn't inspire you in your cart and game design and open your mind to new ways of programming and coding ...

HOPE THIS HELPS !

If you are looking for the earlier version which uses true RND() and true SRAND(), that can be found HERE: