Discuss Scratch

BlueBionicWhale
Scratcher
61 posts

How to reduce lag in my project?

Link to project: https://scratch.mit.edu/projects/544717742/

This project is very laggy, for example some of the frames repeat. And you have to press up and down multiple times just to switch between the two buttons, and sometimes it doesn't work. Are there any tips to fix or reduce the lag?
BatteRaquette58
Scratcher
100+ posts

How to reduce lag in my project?

You can force them to go on turbowarp, a website which reduces lag by compiling projects in JavaScript.
Put this code in a new sprite with a costume that tells them to go on turbowarp.
whenclickedhideifisTurboWarp?thenbroadcastrun projectelseshowgotox:0y:0stopallFind a is turbowarp detector on GarboMuffin's account!
Hope this helped!

Last edited by BatteRaquette58 (June 16, 2021 17:08:19)

BlueBionicWhale
Scratcher
61 posts

How to reduce lag in my project?

BatteRaquette58 wrote:

You can force them to go on turbowarp, a website which reduces lag by compiling projects in JavaScript.
Put this code in a new sprite with a costume that tells them to go on turbowarp.
whenclickedhideifisTurboWarp?thenbroadcastrun projectelseshowgotox:0y:0stopallFind a is turbowarp detector on GarboMuffin's account!
Hope this helped!

My project is still pretty laggy, but I appreciate the help, thank you!
Yusei-Fudo
Scratcher
1000+ posts

How to reduce lag in my project?

BlueBionicWhale wrote:

BatteRaquette58 wrote:

You can force them to go on turbowarp, a website which reduces lag by compiling projects in JavaScript.
Put this code in a new sprite with a costume that tells them to go on turbowarp.
whenclickedhideifisTurboWarp?thenbroadcastrun projectelseshowgotox:0y:0stopallFind a is turbowarp detector on GarboMuffin's account!
Hope this helped!

My project is still pretty laggy, but I appreciate the help, thank you!

It might have a little bit to do with your project, but most of the time, it's the computer that isn't running fast enough. It runs pretty fast for me.


Also, the block for sensing TurboWarp is this!:

Last edited by Yusei-Fudo (June 16, 2021 19:04:54)

BlueBionicWhale
Scratcher
61 posts

How to reduce lag in my project?

Yusei-Fudo wrote:

BlueBionicWhale wrote:

BatteRaquette58 wrote:

You can force them to go on turbowarp, a website which reduces lag by compiling projects in JavaScript.
Put this code in a new sprite with a costume that tells them to go on turbowarp.
whenclickedhideifisTurboWarp?thenbroadcastrun projectelseshowgotox:0y:0stopallFind a is turbowarp detector on GarboMuffin's account!
Hope this helped!

My project is still pretty laggy, but I appreciate the help, thank you!

It might have a little bit to do with your project, but most of the time, it's the computer that isn't running fast enough. It runs pretty fast for me.


Also, the block for sensing TurboWarp is this!:

Oh I see, thank you! It might actually be my computer since it's not that powerful compared to most computers.
Yusei-Fudo
Scratcher
1000+ posts

How to reduce lag in my project?

BlueBionicWhale wrote:

Yusei-Fudo wrote:

BlueBionicWhale wrote:

BatteRaquette58 wrote:

You can force them to go on turbowarp, a website which reduces lag by compiling projects in JavaScript.
Put this code in a new sprite with a costume that tells them to go on turbowarp.
whenclickedhideifisTurboWarp?thenbroadcastrun projectelseshowgotox:0y:0stopallFind a is turbowarp detector on GarboMuffin's account!
Hope this helped!

My project is still pretty laggy, but I appreciate the help, thank you!

It might have a little bit to do with your project, but most of the time, it's the computer that isn't running fast enough. It runs pretty fast for me.


Also, the block for sensing TurboWarp is this!:
- snip -

Oh I see, thank you! It might actually be my computer since it's not that powerful compared to most computers.

No problem!
M_M_J_
Scratcher
32 posts

How to reduce lag in my project?

Griffpatch once said keeping the first sprite blank reduces the lag in game. (It was written in his project's comment) So maybe paint a new sprite and keep it first in the order. (I don't know if that will work, I have never tried it myself.)
Awyzza
Scratcher
50 posts

How to reduce lag in my project?

In your continue button code you have a forever loop which:
1. Runs an animation of 10 frames with 0.1 seconds each. i.e. a 1 second animation
2. Checks if the arrow key is being pressed.
3. Repeats from 1 as soon as the next screen refresh hits.

If you press the up or down arrow, your odds of the script actually checking that are 1 in 30 because the rest of the time it is waiting for the next animation frame.

That is why your buttons don't seem to work unless you spam the arrow keys.
BlueBionicWhale
Scratcher
61 posts

How to reduce lag in my project?

M_M_J_ wrote:

Griffpatch once said keeping the first sprite blank reduces the lag in game. (It was written in his project's comment) So maybe paint a new sprite and keep it first in the order. (I don't know if that will work, I have never tried it myself.)

Ok, I'll try that, thank you!
BlueBionicWhale
Scratcher
61 posts

How to reduce lag in my project?

Awyzza wrote:

In your continue button code you have a forever loop which:
1. Runs an animation of 10 frames with 0.1 seconds each. i.e. a 1 second animation
2. Checks if the arrow key is being pressed.
3. Repeats from 1 as soon as the next screen refresh hits.

If you press the up or down arrow, your odds of the script actually checking that are 1 in 30 because the rest of the time it is waiting for the next animation frame.

That is why your buttons don't seem to work unless you spam the arrow keys.

Oh Ok, so I guess if I get rid of the forever block the buttons will work better. Thank you for the help!
Awyzza
Scratcher
50 posts

How to reduce lag in my project?

BlueBionicWhale wrote:

Awyzza wrote:

In your continue button code you have a forever loop which:
1. Runs an animation of 10 frames with 0.1 seconds each. i.e. a 1 second animation
2. Checks if the arrow key is being pressed.
3. Repeats from 1 as soon as the next screen refresh hits.

If you press the up or down arrow, your odds of the script actually checking that are 1 in 30 because the rest of the time it is waiting for the next animation frame.

That is why your buttons don't seem to work unless you spam the arrow keys.

Oh Ok, so I guess if I get rid of the forever block the buttons will work better. Thank you for the help!
Er no, just move the animations into their own loops so the key press checks don't have to wait for them.

The other thing is which is a little strange is the use of Broadcast and then wait. I don't see immediate problems that arise from it but I also don't see why they've been used instead of simply Broadcast.

Last edited by Awyzza (June 17, 2021 06:15:20)

-Navaneet1234-
Scratcher
31 posts

How to reduce lag in my project?

BlueBionicWhale wrote:

Link to project: https://scratch.mit.edu/projects/544717742/

This project is very laggy, for example some of the frames repeat. And you have to press up and down multiple times just to switch between the two buttons, and sometimes it doesn't work. Are there any tips to fix or reduce the lag?
Make A Sprite Called “ ” Without Any Scripts And Your Done
REMIX_EVERYTHING143
Scratcher
1 post

How to reduce lag in my project?

BlueBionicWhale wrote:

BatteRaquette58 wrote:

You can force them to go on turbowarp, a website which reduces lag by compiling projects in JavaScript.
Put this code in a new sprite with a costume that tells them to go on turbowarp.
whenclickedhideifisTurboWarp?thenbroadcastrun projectelseshowgotox:0y:0stopallFind a is turbowarp detector on GarboMuffin's account!
Hope this helped!

My project is still pretty laggy, but I appreciate the help, thank you!

Powered by DjangoBB