So my game http://scratch.mit.edu/projects/gamesman12/2421546 is what i think quiet a big game with 630 something scripts. When I play it it goes very slowly. Is this because of the size of the game because when it had only two levels it worked fine?
Also when I play the game on my computer its fine with few bugs and glitches (that I can see) but when I upload it onto the website there is allot more problems? Could something have happened when i uploaded it or something because I never have those problems when playing the version saved to my computer?
If this is correct then should I make the next few levels on i completely different file so that it goes quicker?
Offline
It's probably because you have a lot of unnecessary scripts.
The more useless scripts you have, the slower it goes. I checked your game and MAN is the coding inefficient! But then again, so were we all when we started.
My advice? Combine scripts to make it run faster.
Offline
Thanks.
Well thats what i figured the answere would be. This is my first game i have ever made on scratch so yes my game has alot of unneccasery scripts. the problem is that if i deleate some scripts that might seem useless at one specific point in the game something bad will happen like an enemy wont hide or something. I will try to clean it up but to be honest i might just end up making another glitch xD. Thanks for answereing. now i got too look through all 70!! of my sprites and check if all 632 of my scripts are needed.
Offline
Since you hace downloaded my game could you look at something? You see the attacks? lightning/fire/water. well if i combine all of the ( when q/w/r pressed, blah blah blah ) scripts together would this help at all?
Offline
I think what Luke121 meant by "combining scripts" is that if you have two scripts like this...
when gf clicked forever do (something) end when gf clicked forever do (something else) end...you can combine them to make this:
when gf clicked forever do (something) do (something else) endThe second example is more efficient. As you know (you said your project had 630 scripts) Scratch supports what is called "multi-tasking," where a project can run multiple scripts "at the same time" (they don't actually run at the same time, but here's not the place for explaining that). This is great, because you can have two independent actions going on. However, it takes more time for Scratch to go once through 100 forever loops containing one block each than it does to go once through one forever loop containing 100 blocks.
Last edited by amcerbu (2012-04-04 19:01:18)
Offline
amcerbu wrote:
I think what Luke121 meant by "combining scripts" is that if you have two scripts like this...
when gf clicked forever do (something) end when gf clicked forever do (something else) end...you can combine them to make this:when gf clicked forever do (something) do (something else) endThe second example is more efficient. As you know (you said your project had 630 scripts) Scratch supports what is called "multi-tasking," where a project can run multiple scripts "at the same time" (they don't actually run at the same time, but here's not the place for explaining that). This is great, because you can have two independent actions going on. However, it takes more time for Scratch to go once through 100 forever loops containing one block each than it does to go once through one forever loop containing 100 blocks.
It's also considered good programming practice to combine similar sections of code to make the code easier to read.
Exactly. If you can, it's a good idea to combine scripts that start with the same signal; for example, you can combine all of your green-flag scripts for one sprite into one to neaten things up and improve performance as amcerbu did. When you're starting out you're still learning the basics and so your scripts won't be perfect, but the more you practice the better you'll get.
Offline
Yeah, you'll need to clean up that mess.
Offline
well i have started combining all of the scripts for the attacks into one. I dont actually have any ''when flag pressed'' scripts. Hopefully when i have done it will be quicker thanks for the help.
Offline
Harakou wrote:
amcerbu wrote:
I think what Luke121 meant by "combining scripts" is that if you have two scripts like this...
when gf clicked forever do (something) end when gf clicked forever do (something else) end...you can combine them to make this:when gf clicked forever do (something) do (something else) endThe second example is more efficient. As you know (you said your project had 630 scripts) Scratch supports what is called "multi-tasking," where a project can run multiple scripts "at the same time" (they don't actually run at the same time, but here's not the place for explaining that). This is great, because you can have two independent actions going on. However, it takes more time for Scratch to go once through 100 forever loops containing one block each than it does to go once through one forever loop containing 100 blocks.
It's also considered good programming practice to combine similar sections of code to make the code easier to read.Exactly. If you can, it's a good idea to combine scripts that start with the same signal; for example, you can combine all of your green-flag scripts for one sprite into one to neaten things up and improve performance as amcerbu did. When you're starting out you're still learning the basics and so your scripts won't be perfect, but the more you practice the better you'll get.
If you have a bunch of scripts that you want to have running at the same time, put ones with wait blocks each in their own script (unlike what they both said).
Offline
Well I don't know if it made much of a difference but I combines allot of the scripts that I could see that could be combined without problems and I hope it made the game better.
Offline