im making a really basic 2d sandbox(literally sand in a box) game. currently I only added sand and its gravity movement.
but project is so slow... I know I use if else blocks but I dont know any better way to compare datas to execute correct code on pixel(sand) shrug
do you have any tips to make the project faster? what blocks usually uses alot of performance other than trigonometry stuff?
Long press space to place sand
as a solution way, Im also noting @cymplecy 's way here since I think it will help maybe not for simulation games but other rendering stuff for me:
Another idea - create a costume of 50x40 (if I remember you matrix size correctly) and use the pixels of that costume as your matrix instead of canvas
Then update those pixels instead of your canvas matrix and just stretch the costume to make it fill the stage
Might be too blurry for you but that could be overcome by using a point resizer
Here is a demo of my idea
unfortunately - the point resizer isn't fast enough
well yeah it would be faster but ofc my idea is improving it in future to make it fun to play (pain).
I tried adding a "will be updated?" info to block data but it make things worse because I had to access around blocks and make them "it also gotta update" when main block updates itself. otherwise when block goes to "no need to update" phase there is no going back.
so it creates a deadly droplet wave of 8x updates on screen.
now I tried some small thing like this for future updates:
so I could have bunch of sand like particles with different colors in one go. but ofcourse it made things even slower
"num 1,2,3" different blocks. "space press" place
I dont wanna be that guy but I have done some Project like this in scratch and its s m o o t h. what might be causing this? lists in lists is a bad idea for this specific situation? am I using warp blocks in a way that they mess up somehow idk? snap is slightly worse than scratch when it comes to rendering and it stacked up here?
this is clearly the way I should move on I guess. performance is amazing. Thanks for the idea and example alot!
how do you think I can implement a deleting block system? since it has to update all pixels around it (there might be water ans stuff) and if those blocks also moves, they gotta update all blocks around them. and chain reaction again. whats a good handling of these re-updating system?
@cymplecy what do you mean by point resizer? you mean manually increasing the square(pixel) sizes? do you have an example project or know some project that uses something like that?
The OP projects perform 2000 iterations per frame. It takes hundreds of milliseconds to render (200-400).
pumpkinhead projects use incremental rendering. For every frame, it performs only a few operations (3-50). Speedup is amazing.
But... without any sand placed on stage, doing literally nothing, the frame rendering takes 5 ms or more (fps 150-200).
After removing "for each (pos) in [queue]" it's less than 1ms. So executing "for each" for an empty list takes 5ms depending on the length of the body.
It really needs attention from Snap! developers.
I do test on Chrome@Win10@i7 laptop with energy savings enabled. I'm curious, how it performs on other computers.