snap space program
so the problem is the draw prediction realllly lags
how to make it less laggy(while still drawing 120 frames of prediction)
snap space program
@bh this is very emergency
No it's not.
You're really being annoying. Just stop. If I have to say it again you'll be suspended for a while.
buuut i really dk how this lags
its just 120 calculations per frame,whyyy should it lag
plus this is the second thing im saying laggy(Lags)
i would certainly expect it laggy at 172800 calculations but 120 is not that huge and whyyyy does it lag
snap is not optimized enough to do that. I suggest you optimize your code, so that it's not doing 120 calculations per frame. That will make it not lag.
It lags even when it's not doing 120 things, so the problem must be the for loop.
It's probably not just that you're doing the 120 things, you're doing a lot of stuff. I suggest you find a way to do less with more.
Also when you use a boolean with an equation, it's turns itself into a number, so no need to multiply it by one.
It isn't, and also snap can't really do 120 calculations per frame without it lagging.
why does everyone here keep saying "120 calculations", you can't count "calculations" like that
every block is going to have all sorts of different steps to it, how many calculations is an addition? is it one because it adds? more because it needs to get the numbers first? what about something like drawing a line with the pen? is every pixel drawn on a calculation?
the thing being called a "calculation" here isn't just a massive block of math, it's looping over an entire array and drawing with the pen, and it's already doing other things than what's being called the cause of the lag. on my computer, the entire project lags even without running any of that, and it's not anywhere close to a weak computer
different things have different performance and there's no reasonable way to test performance in snap other than comparing time between different things
on my computer it runs fine without prediction and with circle optimization
but the fps halves when try to run the optimized prediction
guys on top:this thing is already doing 10 things not 120 now and it still gets a lag(5 loops*2 planets is 10 things,the prediction can only function at O(n^2))
i looked at the project
first thing i'd reccomend for figuring out where lag comes from is creating a framerate counter
set [FPS v] to ((1000) / ((current [time in milliseconds v]) - (last time)))
set [last time v] to (current [time in milliseconds v])
this goes at the top of the game loop
after that take out the game code and put in
warp repeat (rc) ((stuff area))
rc isn't a variable, just put a high number that doesn't put the fps counter below 60
put it in turbo mode
then start putting stuff in there until you figure out which bit of code is causing the most lag
if it's a custom block you might need to take parts out of that and figure out what's causing the issues there
you can adjust rc as neccecary to detect lag easier or to speed it up
lag is usually from massive loops, operating on massive lists (generating costumes and sound). and pen.
on your project almost ALL of the lag i get is from the planet drawing code, and it's not only massive but completely unneccecary
all you need to do to draw a circle is
set pen size to ((r) x (2))
move 0 steps
there is a doubley nested loop in draw prediction
already done that,hence the orange block left top
yeah it was
on new version of this project i get 60/30 compared to 15/4
if you want help with the new version of the project why didn't you link it?
i can't even find any version of your project with an fps counter
oh ohh uh Snap! Build Your Own Blocks
forgot to share
this is a faster distance squared function
the sum block is from putting a value in the variadic part of a + (the right arrow)
it can get even faster if instead of reshaping in the block you do it beforehand and reuse it
hyperblocks are fast and look better, try to use more of them
Sounds like your approach to optimization is wrong.
Without getting into the details of your program, parallelization is typically helpful when N is large, like say a million. For small N, the overhead of setting it up defeats the benefit of doing things in parallel. (Your multicore computer is rarely used to parallelize within one program, but more often to run multiple programs at once, I think.)
i don't think anything in the project is really being done in parallel, the prediction mentioned here is a cumulative loop for showing where the spaceship will likely go by running the physics on it a few steps
Oh, well, in that case, it's all a bad idea to software-parallelize, which just simulates parallelism. I thought he was talking about programming the GPU or something.
i worked on it quite a bit, not just performance improvements but also cleaning up the code, and all the physics had to be redone
lag isn't just reduced but also less visible if there is any because movement calculations now use the time to adjust how far to move