This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2010-05-30 10:03:24

markyparky56
Scratcher
Registered: 2008-03-20
Posts: 1000+

Making a script quicker. (Quite advanced)

Ok, im working on a game, and I want a mouse to follow a set path. Iv made the path and stored it in a list.
But when I have the mouse seperate the two values its very slow.
http://img404.imageshack.us/img404/7702/mousescripts.gif
http://img404.imageshack.us/img404/7702/mousescripts.gif
Is there anyway to speed this script up?
The bottom script is something i made to make path. Its not that important.
The obvious one would be to have the values in two seperate items, but is there a way to do this without using two items?.


http://j.mp/jgVnTq
Check out my game engine development site: NewDawn I'm a Level 171 Scratcher.I am http://bit.ly/nkvLNT

Offline

 

#2 2010-05-30 10:52:20

Kingdaro
Scratcher
Registered: 2008-06-08
Posts: 100+

Re: Making a script quicker. (Quite advanced)

Trust me, I've been searching the forums for ages on how to "Speed up scripts" in your case, and I'd have to say the only way to do it is to use multiple scripts.

Offline

 

#3 2010-05-30 13:53:44

markyparky56
Scratcher
Registered: 2008-03-20
Posts: 1000+

Re: Making a script quicker. (Quite advanced)

Kingdaro wrote:

Trust me, I've been searching the forums for ages on how to "Speed up scripts" in your case, and I'd have to say the only way to do it is to use multiple scripts.

I was meaning to streamline it, metaphoricaly.


http://j.mp/jgVnTq
Check out my game engine development site: NewDawn I'm a Level 171 Scratcher.I am http://bit.ly/nkvLNT

Offline

 

#4 2010-05-30 16:07:59

ScratchReallyROCKS
Scratcher
Registered: 2009-04-22
Posts: 1000+

Re: Making a script quicker. (Quite advanced)

Go into Turbo mode.


http://imageshack.us/a/img694/3806/sigmad.png

Offline

 

#5 2010-05-30 16:09:32

fullmoon
Retired Community Moderator
Registered: 2007-06-04
Posts: 1000+

Re: Making a script quicker. (Quite advanced)

Well, since you know that the x and y positions are going to be at max 4 characters long, couldn't you store all positions in a list like this:

Code:

[XXXX|YYYY]
[XXXX|YYYY]
[XXXX|YYYY]

So the position (-23,167) would be stored as this:

Code:

[-023|0167]

That way you could just use a couple of join(|) blocks to read each index like so:

Code:

set x_read_from_index to (join items 1,2,3,4) of list
set y_read_from_index to (join items 6,7,8,9) of list
//Using string 'join' blocks here but I don't want to write them out...you know what I mean

Scratch would read "-007" as "-7" I believe so there is no further coercion needed.

Also I think it would be faster if the variable ":level" wasn't being checked against long strings...I've never verified this but it seems like a test against an integer would be much faster.

Last edited by fullmoon (2010-05-30 16:19:44)


http://i302.photobucket.com/albums/nn100/fullmoon32/wow.jpg

Offline

 

#6 2010-05-31 00:27:54

fullmoon
Retired Community Moderator
Registered: 2007-06-04
Posts: 1000+

Re: Making a script quicker. (Quite advanced)

Here's an example of what I'm talking about:
http://scratch.mit.edu/projects/halfbaked_fullmoon/1087656
It's actually quite speedy. I removed the bar in between the x/y coordinates because the online player was having a problem with it.


http://i302.photobucket.com/albums/nn100/fullmoon32/wow.jpg

Offline

 

Board footer