First of all, Danmakufu doesn't have any bitwise operators. Gonna have to work with modulo for that. Also, I did mean just writing the values out in the script itself if you want. Calculating them just once on-run isn't a waste though, and you can change the values if you ever need to without calculating yourself, so I suggest doing that.
Ok, so the figure-8 pattern is somewhat important, because essentially all you're doing is using a single incrementing variable to plug into sin() and cos(), and then multiplying it by some amplitude. I imagine it's like
t = (t + 360/32) % 360;
h_pos = cx + sin(t) * 50;
v_pos = y + sin(t*2) * 10;
for one slice or something, where y and t increase for each slice.
This means you can either:
- Have two tables where one maps 32 hardcoded values of
sin(t)*50 and the other maps 16 of
sin(t*2)*10; or
- Have one table that just maps 32 hardcoded values of
sin(t), but use two different indices (
i and
i*2) and multiply by 50 and 10 afterwards
These would look like
h_offsets = [sin(0*360/32)*50, sin(1*360/32)*50, sin(2*360/32)*50, (29 more...)]; // Or use a loop to populate these lol
v_offsets = [sin(0*360/16)*10, sin(1*360/16)*10, sin(2*360/16)*10, (13 more...)];
// ...
h_pos = cx + h_offsets[(frame_roll + slice_offset) % 32];
v_pos = slice_offset*slice_size + v_offsets[(frame_roll + slice_offset) % 16];
or
offsets = [sin(0*360/32), sin(1*360/32), sin(2*360/32), (29 more...)];
// ...
h_pos = cx + offsets[(frame_roll + slice_offset) % 32] * 50;
v_pos = slice_offset*slice_size + offsets[(frame_roll + slice_offset) * 2 % 32] * 10;
The first looks a bit nicer, but comes at the disadvantage of not being able to change parameters without rewriting the table every time. The second you can freely change the amplitudes and whatnot.
Wait, does PH3 still have the same performance problem with arrays as 0.12m?
I'm not sure what you mean by performance problems. I haven't used 0.12m in eons so I don't even know if it has array issues (and I don't really care tbh), but could you elaborate? The main issue with ph3 arrays is that you can't just allocate a given size.