Discuss Scratch

Collin_The_Newmaker
Scratcher
100+ posts

Please help me to optimise the code.

I'm trying to do the pin system that Griffpatch has mentioned in his rpg devlog #2.
I have done the pin display code, but when I turn on the pin mode (they are not drawn if you
don't turn it on) the FPS drops from good 30 to 10. This is terrible. Is there any way for me to optimise the code?
It is drawn without screen refresh (if you turn screen refresh on then it's not drawn because loops).
The project: scratch.mit.edu/projects/736464750/
Here is the code, if you have any questions about code, ask:

Last edited by Collin_The_Newmaker (Sept. 30, 2022 16:43:31)

blablablahello
Scratcher
1000+ posts

Please help me to optimise the code.

I suggest sending a formatted pice of code
when green flag clicked
say [like this]
or a link to the project, as it is pretty hard to help someone with a script when its a image
Collin_The_Newmaker
Scratcher
100+ posts

Please help me to optimise the code.

blablablahello wrote:

I suggest sending a formatted pice of code
when green flag clicked
say [like this]
or a link to the project, as it is pretty hard to help someone with a script when its a image
Understandable. Here's the link scratch.mit.edu/projects/736464750/

Last edited by Collin_The_Newmaker (Sept. 30, 2022 16:44:00)

Collin_The_Newmaker
Scratcher
100+ posts

Please help me to optimise the code.

bump
blablablahello
Scratcher
1000+ posts

Please help me to optimise the code.

tbh this probably is just because you are drawing the pins lol.

I cant find what is calling draw pins, but if its drawing pins EVERY frame, then you can probably use if statement to reduce that to only the frames where you move the camera or change the pins somehow
Collin_The_Newmaker
Scratcher
100+ posts

Please help me to optimise the code.

blablablahello wrote:

tbh this probably is just because you are drawing the pins lol.

I cant find what is calling draw pins, but if its drawing pins EVERY frame, then you can probably use if statement to reduce that to only the frames where you move the camera or change the pins somehow
Well I can already tell that this won't help. idk if you did notice but i as well also stamp all the map tiles as well as palette tiles every frame at 30 FPS rate, so pins shouldn't be that laggy as well.
iGPR3
Scratcher
3 posts

Please help me to optimise the code.

blablablahello wrote:

tbh this probably is just because you are drawing the pins lol.

I cant find what is calling draw pins, but if its drawing pins EVERY frame, then you can probably use if statement to reduce that to only the frames where you move the camera or change the pins somehow

You could always use turbowarp - dropping fps isnt an issue, you can definitely run your game on turbowarp at a steady speed. If you want to optimise it further to make it simpler then i'm not your guy, but you should definitely try turbowarp.

If you could give me a hand with my code aswell that'd be great, i'm pretty stuck rn!
Collin_The_Newmaker
Scratcher
100+ posts

Please help me to optimise the code.

iGPR3 wrote:

blablablahello wrote:

tbh this probably is just because you are drawing the pins lol.

I cant find what is calling draw pins, but if its drawing pins EVERY frame, then you can probably use if statement to reduce that to only the frames where you move the camera or change the pins somehow

You could always use turbowarp - dropping fps isnt an issue, you can definitely run your game on turbowarp at a steady speed. If you want to optimise it further to make it simpler then i'm not your guy, but you should definitely try turbowarp.

If you could give me a hand with my code aswell that'd be great, i'm pretty stuck rn!
Well, I'm familiar with turbowarp. In fact, there's already a great game in my signature that is recommended to be played at turbowarp.
But the catch is that you actually can optimize this to run smoothly, as Griffpatch has made this system and showed it - it worked with very high FPS.
If I can optimize this without using turbowarp, I sure want to!
iGPR3
Scratcher
3 posts

Please help me to optimise the code.

Collin_The_Newmaker wrote:

iGPR3 wrote:

blablablahello wrote:

tbh this probably is just because you are drawing the pins lol.

I cant find what is calling draw pins, but if its drawing pins EVERY frame, then you can probably use if statement to reduce that to only the frames where you move the camera or change the pins somehow

You could always use turbowarp - dropping fps isnt an issue, you can definitely run your game on turbowarp at a steady speed. If you want to optimise it further to make it simpler then i'm not your guy, but you should definitely try turbowarp.

If you could give me a hand with my code aswell that'd be great, i'm pretty stuck rn!
Well, I'm familiar with turbowarp. In fact, there's already a great game in my signature that is recommended to be played at turbowarp.
But the catch is that you actually can optimize this to run smoothly, as Griffpatch has made this system and showed it - it worked with very high FPS.
If I can optimize this without using turbowarp, I sure want to!

Oh ok! Did Griffpatch show the code anywhere? I would have thought that he would post the code somewhere, whether it be on scratch or somewhere else.

In fact, I need a hand with some code myself if I could ask that of you, here's a link to my post and game.

Game: https://turbowarp.org/739117021
Post: https://scratch.mit.edu/discuss/topic/632490/

Powered by DjangoBB