Log In  

I'm trying to port to PICO-8 a version of the classic old-school plasma effect I have done in javascript.

This is the code so far

I have the major problem that due to pico limitations, all those sin, cos and sqrt just freeze it. If you don't try to fill up the whole screen (for example,

for y=1,10

instead of

for y=1,127

it mostly works.

Any idea on how to improve in this?

P#14489 2015-09-22 14:49 ( Edited 2015-09-22 23:21)

It is depending on magic_num_2. 30 crashes pico. 0.3 does not but doesn't look right.
It's weird because those numbers have no influence on cpu load ... so I guess there's a division by zero or an endless loop somewhere in the pico-8 internals.

No need for "plasma = {}" on line 6 btw.
Maybe zep can help.

P#14494 2015-09-22 16:13 ( Edited 2015-09-22 20:58)

Try alternative (fixed) sqrt until 1.1.2 is out


With this change your code does not freeze in my test

P#14501 2015-09-22 17:57 ( Edited 2015-09-22 21:59)

Thanks, using that sqrt function helped. Also, I think I'm hitting a problem with sin() and co(). For example, the output of




sin(10) should be -0.544

Am I missing something about sin() and cos()? They seem broken.

P#14503 2015-09-22 18:05 ( Edited 2015-09-22 22:05)

The trig functions are weird. From the manual:

cos x
sin x

    Returns the cosine of x, where 1.0 indicates a full circle
    sin is inverted to suit screenspace
    e.g. sin(0.25) returns -1

The input units sort of make sense since pico-8 uses 16.16 bit fixed point. It makes math a little weird though. I rarely use sin() directly in screenspace, so having it be inverted is super arbitrary to me.

P#14504 2015-09-22 18:26 ( Edited 2015-09-22 22:26)

So, yeah, thanks for pointing that out. Since sin() and cos() are 1-based and not 2PI, and I applied them to a variable (gc) that gets incremented by 1 each frame, I was always getting 0 anche hence had no animation.
Thanks you.

P#14506 2015-09-22 19:21 ( Edited 2015-09-22 23:21)

[Please log in to post a comment]