In my new game (still in-dev) CodinCraft, I added a few things to the inventory and when I looked at it, IT WAS SOOOO LAGGY. Why? If anyone might be able to fix this bug then please go to this link and make a remix showing me how to fix the lag!
It’s almost definitely due to the clones
Snap isn’t able to handle large amounts of clones like scratch can
Try minimizing the amount of clones you use
Snap actually can handle clones very well, it’s just it can’t handle creating so many clones and deleting so many clones that fade for something like a bar graph that uses clones for each segment and updates on each frame, in scratch this works fine as it’s very optimized. But in snap it causes a ton of lag
I'm not using clones, it's a pen project.
Yea I realized that, the reason why got confused is because stamps are really low quality in scratch so I thought it was clones
I’ll give you a fix in a little bit
So instead of updating the inventory on every frame, you need to instead get a list of things that could cause the inventory to change and then only update it when one of those happen
Picking up an item, dropping an item, placing an item, ect.
yes, but 1. I'll add movement in BETA.0.2, and 2. if I only update when I need to update then save an image to a variable (pen trails var prolly) of that and make it load that image every frame, it'll still prolly be laggy bc the mouse moving
hmmmm imma try #2 rq
turbo mode helps a little bit tho
Rending that on every frame is really making it slow down
well im doing a few optimizations rn, so lets hope they work!
Snap! isn't very good at running complex games unfortunately. i've had lag problems in games myself.
Half of that time is wasted just to determine the costume name for a given tile
The second half is (4 x stamp, 4 x costume change) / tile.
i've released BETA.0.1.3 (still kinda laggy tho)
Id be glad to rewrite some of the code for you tbh
Here you go! The way this new system works is, whenever you need to change the inventory you just set the variable to true and it updates
This is much more efficient than doing it on every frame
yes, but it also needs to update whenever the mouse moves /: (so basically every frame)
hmmm i have an idea: so, it updates the image then saves the pen trails into a variable and draws that variable every frame, BUT what if that variable was a list of variables
Invimg = [ [ // inventory "the background", "the items", "and the item count?" ], [ // hotbar "the background", "the items", "and the item count?" ] ]
and then it only updated a specific one when it needed to?
(but still drew the images in the list every frame due to other things like tiles, time, and other stuff)
btw where'd you get that duration block?