Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » Scratch project is very laggy and I can't find a way to optimize it.
- 31undtim
-
Scratcher
5 posts
Scratch project is very laggy and I can't find a way to optimize it.
Hello. I'm working on a Great Lakes shipping simulator, but in development, I faced a major lag issue. I tried different ways to optimize the code, but I'm not too experienced at optimizing code. If anyone can help fix the lag issue, I would appreciate it. Thanks.
Project:
https://scratch.mit.edu/projects/1268717795/
Project:
https://scratch.mit.edu/projects/1268717795/
- TeoProot
-
Scratcher
62 posts
Scratch project is very laggy and I can't find a way to optimize it.
its not that laggy for me…
- Xcvfdd
-
Scratcher
500+ posts
Scratch project is very laggy and I can't find a way to optimize it.
It might be worth creating a “blank” sprite that contains nothing and running your project with that sprite selected.
The yellow glow that outlines code blocks during runtime might be slowing down your PC.
The yellow glow that outlines code blocks during runtime might be slowing down your PC.
- dem_bot
-
Scratcher
500+ posts
Scratch project is very laggy and I can't find a way to optimize it.
I see a lot of
(item # of [] in [list v])blocks, both of which are really laggy, especially on longer lists, because they go through the whole list searching for an item. Often it's better to have slightly longer lists where you can use a simple mathematical formula to get the right item number without needing to do a ton of pointless checks.
<[ v] contains [thing] ?>
<touching color [#1b37da] ?>Is also very heavy, as it checks a bunch of colours on every pixel the sprite touches and can be avoided with some maths or with
<touching [ v] ?>
- 31undtim
-
Scratcher
5 posts
Scratch project is very laggy and I can't find a way to optimize it.
How would i find an alternative for
if the zones are all in real player sprite?
(this project is my first attempt at using lists, and one of those open/scrolling maps)
<touching color [#1b37da] ?>
if the zones are all in real player sprite?
(this project is my first attempt at using lists, and one of those open/scrolling maps)
- dem_bot
-
Scratcher
500+ posts
Scratch project is very laggy and I can't find a way to optimize it.
How would i find an alternative forwith maths is probably your best bet then. There's plenty of articles on the internet discussing the ways to calculate hitboxes,<touching color [#1b37da] ?>
if the zones are all in real player sprite?
(this project is my first attempt at using lists, and one of those open/scrolling maps)
- kansea
-
Scratcher
100+ posts
Scratch project is very laggy and I can't find a way to optimize it.
I see a lot ofWait, really? The underlying code doesn't optimize at all?(item # of [] in [list v])blocks, both of which are really laggy, especially on longer lists, because they go through the whole list searching for an item. Often it's better to have slightly longer lists where you can use a simple mathematical formula to get the right item number without needing to do a ton of pointless checks.
<[ v] contains [thing] ?>
- 31undtim
-
Scratcher
5 posts
Scratch project is very laggy and I can't find a way to optimize it.
I see a lot of(item # of [] in [list v])blocks, both of which are really laggy, especially on longer lists, because they go through the whole list searching for an item. Often it's better to have slightly longer lists where you can use a simple mathematical formula to get the right item number without needing to do a ton of pointless checks.
<[ v] contains [thing] ?>
I couldn't find
(item # of [] in [list v])in my code, because I might have replaced them before posting the topic. I'm assuming you meant
(item ( v) of [list v] :: list)If so, should I replace
if <[ v] contains (item ( (answer)) of [list v] :: list) ?> thenlines with
end
if <(answer) = [1]> theninstead?
end
- 31undtim
-
Scratcher
5 posts
Scratch project is very laggy and I can't find a way to optimize it.
Also, sorry for forgetting to say that the lag in the project happens outside the editor too. I'm not sure if it's a device issue or an issue with my code in general. I've made a copy where I removed every list, which slightly reduced the lag, but the problem was still there. I believe the underlined issue is maybe how I coded the lists and a few other stuff
- ericyoel
-
Scratcher
11 posts
Scratch project is very laggy and I can't find a way to optimize it.
Use Turbowarp
- 31undtim
-
Scratcher
5 posts
Scratch project is very laggy and I can't find a way to optimize it.
Use TurbowarpTurbowarp is blocked in almost every school, and not really helpful when i want to find a way to optimize my project better
- Discussion Forums
- » Help with Scripts
- » Scratch project is very laggy and I can't find a way to optimize it.
