Pages: 1
Topic closed
I have done it!
I have invented a way to turn a 1s1s into a multiple script project which acts exactly the same as the original! This allows the game to be edited more easily.
The first project to use this is here:
http://scratch.mit.edu/projects/rubiks_ … 38/1436719
The project divides the script into 'processes' in order to make the script easier to edit.
Here's how it works:
[blocks]
<when green flag clicked>
[do stuff here]
<set{ process }to( draw
<broadcast[ draw
<broadcast[ handle input
<broadcast[ handle collisions
<broadcast[ move
<when I receive[ draw
<if><( <{ process }> <=> draw )>
[do stuff here]
<set{ process }to( handle input
<end>
<broadcast[ draw
<when I receive[ handle input
<if><( <{ process }> <=> handle input )>
[do stuff here]
<set{ process }to( handle collisions
<end>
<broadcast[ handle input
<when I receive[ handle collisions
<if><( <{ process }> <=> handle collisions )>
[do stuff here]
<set{ process }to( move
<end>
<broadcast[ handle collisions
<when I receive[ move
<if><( <{ process }> <=> move )>
[do stuff here]
<set{ process }to( draw
<end>
<broadcast[ move
[/blocks]
If you use this system, please give me credit!
Last edited by rubiks_cube_guy238 (2010-11-26 17:30:25)
Offline
Couldn't you just break the script up into broadcasts an easier way?
When green flag clicked scripts broadcast 1 When I receive 1 scripts broadcast 2 When I receive 2 scripts broadcast 3 etc.
Or is there some advantage to your method?
Offline
Harakou wrote:
Couldn't you just break the script up into broadcasts an easier way?
Code:
When green flag clicked scripts broadcast 1 When I receive 1 scripts broadcast 2 When I receive 2 scripts broadcast 3 etc.Or is there some advantage to your method?
Yes, there is. Normally, a Scratch broadcast actually takes a small amount of time to be received, which would result in, by using your method, extreme lag. The same goes for repeat blocks; it takes a small amount of time to cycle back to the top.
Last edited by rubiks_cube_guy238 (2010-11-24 17:07:20)
Offline
Yes, I've known this for a while, but I've always thought people would think of it as a multi script project. But this is just like normal programming. Broadcasts are basically definitions. Besides, I really don't think this is the first project to use this method. It could have been used when broadcasts and receiving were first made. But anyway, I think the idea of specific receivers are used for specific things, like input and collisions. It's pretty cool.
Offline
I've experimented with things like this while I was making my raycaster, and found that for projects with huge complex math operations and scripts like that one, the speed difference is pretty much negligible. But for smaller projects or platformers I'd imagine it could give a pretty nice speed boost.
Magnie wrote:
(snip)
Wow now here's someone I hadn't seen in a while. o_O
Offline
kayybee wrote:
Actually, the whole point to make a 1s1s is that there is only 1s1s, because or else it would not be a 1s1s, but a 1s#s. People strive to make 1s1s, not 1s#s...
Yes, but this is a 1 sprite 1 virtual script project. My project is easier to edit, which is difficult to do with a 1 sprite 1 script. It also helps organize the script. Anyways, if you want to see a 1 sprite 1 script project so badly, download the project and join the scripts together.
BTW, I can use this method to make LINE Tenis (possible the longest-script game on Scratch) editable.
Last edited by rubiks_cube_guy238 (2010-11-25 07:46:38)
Offline
Bump
I edited the script (I didn't type it in correctly.)
Magnie wrote:
It could have been used when broadcasts and receiving were first made.
Yes, now I understand why you said that. Before, when I typed it in, it was just a bunch of linked broadcasts, which wouldn't really take a lot of brainpower to figure out how to do.
Last edited by rubiks_cube_guy238 (2010-11-26 17:35:03)
Offline
Topic closed
Pages: 1