Discuss Scratch

kiddynamo
Scratcher
1 post

Help with Speeding Up Code

I have developed some basic code for simple movement (i.e., left, right, jumping, falling) that relies on only background color and code inside just one sprite. It seems to work fairly well, when run in turbo mode. However, it is WAY slow in normal mode. I would appreciate any suggestions to speed it up without loss of functionality. As an additional note, I am noticing a small bug that could lead one to “teleport” across the blocks, but I can't seem to replicate the problem consistently. I would appreciate help in fixing this issue as well. Thank you very much!

http://scratch.mit.edu/projects/25317448/
AM-5573
Scratcher
100+ posts

Help with Speeding Up Code

kiddynamo wrote:

I have developed some basic code for simple movement (i.e., left, right, jumping, falling) that relies on only background color and code inside just one sprite. It seems to work fairly well, when run in turbo mode. However, it is WAY slow in normal mode. I would appreciate any suggestions to speed it up without loss of functionality. As an additional note, I am noticing a small bug that could lead one to “teleport” across the blocks, but I can't seem to replicate the problem consistently. I would appreciate help in fixing this issue as well. Thank you very much!

http://scratch.mit.edu/projects/25317448/

Hi kiddynamo,
I looked at your project, and it looks really good! I like your use of binary numbers in the variables, and the coding is really good for a new scratcher (you must have experience coding!)
My only suggestion is that you make it move more for each button press. I'm not being very clear, so look below:

Instead of something like
when green flag clicked
forever
if <key [left arrow v] pressed?> then
point in direction (90 v)
change x by (-1)
end

Maybe you should do
change x by (-3)

And also apply that to the right arrow key. Good luck!

Last edited by AM-5573 (Aug. 9, 2014 05:00:20)


Evil kumquats? Ha! My signature was eaten by a pineapple.
AM-5573
Scratcher
100+ posts

Help with Speeding Up Code

Sorry, I didn't put the scratch blocks in properly. I'll fix that

Evil kumquats? Ha! My signature was eaten by a pineapple.
AM-5573
Scratcher
100+ posts

Help with Speeding Up Code

Ok, I fixed it ^

Evil kumquats? Ha! My signature was eaten by a pineapple.
vidarfw02
Scratcher
100+ posts

Help with Speeding Up Code

Another way to speed up the code is to try and reduce the number of repeat forever loop.

Instead of
forever


if <key [ v] pressed?> then

end

end

try:
when [ v] key pressed

Last edited by vidarfw02 (Aug. 9, 2014 11:09:19)



TimothyLawyer
Scratcher
1000+ posts

Help with Speeding Up Code

This project may help.

BeetleBlocks, WatercolorBot, and Turtle Art
Hover over a name or label to translate into current language
When Earth was… Purple?

☂️




Powered by DjangoBB