Log In  
Log In  

Cart [#44826#] | Code | 2017-10-01 | License: CC4-BY-NC-SA | Embed
1

Cart [#44108#] | Code | 2017-09-12 | License: CC4-BY-NC-SA | Embed
1
I wasn't sure what forum this would apply to as it's an asset for others to learn from or use/Repurpose so I put it in the collab forum. Code is pretty compact and verbosely commented so even the very basic user of Pico-8 can get a grasp of what I did and how.

UPDATE: Updated to 2.0! Includes McBoffin's suggestions, And includes simple "Warp" effect as well now! Everything's broken up into functions for ease of copying the functions to your own program, And commented up the wazoo for ease of tinkering!

P#44109 2017-09-11 21:27 ( Edited 2017-10-02 00:28)

I like it! Super simple and super effective!

I noticed that on the first loop, the colors of the stars are matched to their speed (speed 1 to color 13, speed 2 to color 6, and speed 3 to color 7), but after that first loop, a new speed is chosen, but the color remains the same. So after a few loops, the colors and speeds are all mixed, instead of in strict layers. (Also, I noticed when a star was given a new speed, it wasn't being given an integer speed like the first time.)

You could keep that strict layering, and even lose an entire item of stored data by using the following code (my comments in ALL CAPS):

function _init()
 stars={}
 cols={13,6,7} --ADDED THIS TABLE TO ASSIGN COLORS TO SPEEDS

 local totstars=125 

 for i=1,totstars do

  local tc=flr(rnd(3)+1) --PICK A RANDOM SPEED AS BEFORE

  --BUT NOW SKIP THE WHOLE ASSIGNING COLOR BASED ON SPEED THING

  add(stars,{
   x=rnd(128),-- random "x" pos.
   y=rnd(128),-- random "y" pos.
   sp=tc     -- speed from 1-3.
             -- DON'T STORE THE COLOR!
  })

 end
end

function _draw()
 cls()
 for st in all(stars) do
  pset(st.x, st.y, cols[st.sp]) --GRAB THE COLOR BASED ON THE SPEED
 end
end

function _update()
 for st in all(stars) do
  st.y+=st.sp
  if (st.y>=128) then
   st.y=0
   st.sp=flr(rnd(3)+1) --CHANGED THIS TO GET A NEW *INTEGER* SPEED
  end
 end
end
P#44112 2017-09-11 23:59 ( Edited 2017-09-12 06:55)
:: DR4IG

Thanks! I'll update it a lil' when I get the chance tomorrow. Still learning my way around how this all works. For instance I didn't know about that bit you did above with cols[st.spd]. Learn something new every day, That's the goal!

Forgetting that FLR statement was the usual sort of oversight you run into when staying up too late for "Just one more routine!" thanks for catching that for me!

P#44114 2017-09-12 02:18 ( Edited 2017-09-12 06:22)

Thanks! always nice to see new takes on classics.

P#44827 2017-10-01 14:57 ( Edited 2017-10-01 18:57)
:: DR4IG

@penthouse_guy:

Every time I learn the nuances of a new language/scripting system the first thing I always try to do is a parallaxing routine because they're easy enough to do on most hardwares. Good way to test draw limits by dumping a ton of stars too.

P#44835 2017-10-01 20:28 ( Edited 2017-10-02 00:28)

[Please log in to post a comment]

X
About | Contact | Updates | Terms of Use
Follow Lexaloffle:        
Generated 2019-03-20 07:39 | 0.030s | 4194k | Q:34