Help optimising my project

What's problem you are encountering?
after switching "scenes" (not snap scenes. it is just a set of objects) the game lags... hard
What have you tried that didn't work?
I allready did a simple optimisation by instead of using broadcast and wait to just use normal broadcast
Post a project example, link, or screenshot:
https://snap.berkeley.edu/snap/snap.html#present:Username=walksanator&ProjectName=Platformer

Why don't you save the rectangles as costumes instead of drawing it every time? In the "my" block there is an option for your current costume, and you can actually drag that into the costume tab to save it. Or you can drag a second "my" block, set it to "costumes", and add your costume to it using the block and then it should appear.

But i only change costume once. That should not explain the constant framerate loss upon heading into the 2nd stage

I'd try simplfying it to try and see where the delays are coming from

This bit looks like it might just be endlessly looping for maybe no reason?
image

Also, this clone tick mechanism looks worth investigating - maybe try slowing down the ticks (I couldn't find out what was generating them)
image

With "Turbo mode" = false it works like a charm for me (on the first stage).
The second stage is slow.
You sometimes duplicate clones. Your "floor", "ceiling", and "wall" are added twice or more to the "logic_objects".

BTW: Your code looks quite nice, but Snap is greedy for idle. A moment of inattention and it goes into idle mode, and 17ms delay appeared.

Broadcasting should be a modern and lightweight way to create apps, but it seems to impose lag. Launching forever loops is not a good idea, but it works much better in this case.

It will be fine if Brian or Team will give us some performance advice based on this project. I see nothing inherently wrong with this project, but with two "broadcast &wait" in a row, there was a 70-90ms delay between every iteration of the forever loop.

Ive added "frame 2 frame" delay and player main loop execution time: Snap! Build Your Own Blocks

collision tick is called in the players "physics loop" just before applying velocitites to player.
I guess I could make a framerule like system for collision ticks

I dont think i duplicate clones. the only two times that I make two clones of one object are the diffrently configured bouncepads. and the "default" floor/ceiling/wall otherwise I use my custom constructor blocks. as stated slightly above. I am going to add framerules to collision ticks

okay so adding the framerule I am now able to phase through walls/ceilings. due to it only being EveryOtherFrame it kinda does not like to work (I can phase through walls/ceilings)

so by making it execute physics Every Other frame. it works alot better.

Try avoiding broadcasts, in my experience those are incredibly slow if broadcast every single frame.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.