Hi,

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

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?

Thanks

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.

Try alternative (fixed) sqrt until 1.1.2 is out

https://www.lexaloffle.com/bbs/?pid=11339#p11339

With this change your code does not freeze in my test

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

print(sin(10.0))

print(sin(10))

print(sin(10.1))

is

0

0

-05877

sin(10) should be -0.544

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

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.

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.

[Please log in to post a comment]