Here's an interesting idea for Scratch 2.0: XML-Based project files. This would make projects much, much easier for other programs to read. I've got some examples and suggestions for how things might work.
Here's an example of a possible structure for the file:
<?xml version="1.0"?> <scratch xmlns=... (insert schema declaration stuff here) ...> <info> <version>2.0</version> <platform>Mac OS X</platform> <creator>ahawesome</creator> (more info like upload history, etc.) </info> <variables> <variable type="regular"> <name>Sprite X</name> <content>54</content> </variable> <variable type="list"> <name>My List</name> <content id="1">First list item...</content> <content id="2">Second list item...</content> </variable> </variables> <stage> <background id="1"> <name>background1</name> <image> (base64 encoded data would work well) </image> <text> (whatever text the user puts in, font, location, etc.) </text> </background> </stage> <sprite id="1"> <name>Sprite1</name> <location> (x/y location) </location> <script> <location> (x/y location) </location> <block type="control" id="1" /> <block type="looks" id="4"> <argument id="1">Hello, world!</argument> <argument id="2">5</argument> </block> </script> (more scripts could be inserted using the same sort of method) <costume id="1"> <name>costume1</name> <image> (base64) </image> </costume> (same thing - more costumes with the same method) </sprite> <sprite id="2"> (more sprites inserted like this) </sprite> </scratch>
Also, here's some ideas for file extensions:
.sb - Regular binary file
.sx - XML file
And, in case the files end up being very large:
.sxg - Gzipped XML file
Hopefully, some of these suggestions will be useful if Scratch developers decide to implement such a system. Of course, it could be improved greatly and possibly changed based on what can be done in Smalltalk (I don't know the language).
Finally, in case anyone was wondering, here's what the script in Sprite1 corresponds to:
[blocks]
<when green flag clicked>
<say[ Hello, world! ]for( 5 )secs>
[/blocks]
It sort of makes sense when you look at the blocks in Scratch (green flag clicked is the first one in the control category, say x for y seconds is fourth in the looks, etc.).
Offline
Hey, that's a pretty good idea, but I fear it might be a little bit too complicated for most users to understand. If there were a way to make this simpler, I would definitely support. Ideas, anyone?
Offline
Great!
coolstuff wrote:
Hey, that's a pretty good idea, but I fear it might be a little bit too complicated for most users to understand. If there were a way to make this simpler, I would definitely support. Ideas, anyone?
This would not make it more complicated. Most scratchers would never notice a difference.
XML scratch files (or something else like this) would make it easier to write other programs that can read and write scratch files. And you could read a scratch file in a text or xml editor. This would be very handy!
(I would recommend linking images and sound files instead of embed with base64...
All media could have a unique id on the scratch web server. That way there would only need to be one scratch cat (and other duplicated media) on the scratch server. also it would make it easier to moderate media, track credit and remixes for media... Although that are cons to this too-- more http requests...)
Last edited by JTxt (2010-06-11 00:03:40)
Offline
JTxt wrote:
I would recommend linking images and sound files instead of embed with base64...
All media could have a unique id on the scratch web server. That way there would only need to be one scratch cat (and other duplicated media) on the scratch server. also it would make it easier to moderate media, track credit and remixes for media... Although that are cons to this too-- more http requests...
That is an interesting idea, and would probably save space in files. However, like you said, there would be a lot more HTTP requests. Plus, users would be required to have an internet connection to load and save files, and projects may take a bit longer to load (especially on connections like dial-up).
Also, I've been thinking about how sound might be stored. It's just binary data, so I'm thinking that a system like base64 (or external linking, as JTxt suggested) would work there too. If the sound was encoded as Ogg (or a similar open format, although I don't know of one that exists), that would be an additional plus.
Again, though, I don't know anything about Smalltalk and what's possible in the language. Looking on Google, though, both base64 and XML appear to have been done, and Scratch itself proves that some sort of linking would work (the project upload feature).
EDIT: Just wanted to verify/clarify that base64 will work for *any* binary data, including sound. I've tested it.
Last edited by ahawesome (2010-06-11 19:33:36)
Offline
I just found a new piece of information which looks like good news. According to the Scratch wiki, the program is going to be rewritten in Flash instead of Java/Squeak. So, hopefully some of the features described here will be easier to implement.
http://wiki.scratch.mit.edu/wiki/Scratch_2.0
Offline
Great idea! I love it. Again, it might be too complicated for some to understand, but oh well.
BTW, we have a Project summary thing too.
Project: Aperture Science Author: Scratch: 1.4 of 30-Jun-09 History: 2010-6-10 10:18:39 save Aperture Science 2010-6-10 12:08:12 save Aperture Science 2010-6-10 17:08:45 save Aperture Science 2010-6-11 14:44:01 save Aperture Science Totals: Sprites: 6 Stacks: 8 Unique costumes: 11 Unique sounds: 2 -------- Sprite: Stage Costumes (1): background1 (480x360) Sounds (1): pop (0:00:00) No stacks. -------- Sprite: Sprite1 Costumes (2): costume1 (54x54) costume2 (54x54) Sounds (1): meow (0:00:01) Stacks (3): when I receive "Set Level" go to x: -162 y: -104 end when green flag clicked go to x: -162 y: -104 set "X Vel" to "0" set "Scroll X" to "50" set "Y Vel" to "0" forever go to front set size to 100% switch to costume "costume1" if (key "d" pressed?) change "X Vel" by -0.3 point in direction 90 if (key "a" pressed?) change "X Vel" by 0.3 point in direction -90 switch to costume "costume2" set "Save Direction" to (direction) point in direction 90 if (color c[00CECE] is touching c[848484]?) set "X Vel" to "1" point in direction 90 if (color c[00CE42] is touching c[848484]?) set "X Vel" to "-1" point in direction -90 if (not (color c[630000] is touching c[848484]?)) change "Y Vel" by -0.3 change y by (Y Vel) if (color c[630000] is touching c[848484]?) set "Y Vel" to "0" if (key "space" pressed?) set "Y Vel" to "5" if (color c[310063] is touching c[848484]?) set "Y Vel" to "-1" change y by (Y Vel) if (color c[001863] is touching c[848484]?) set "Y Vel" to "1" change y by (Y Vel) if (touching color c[CC7700]?) set "Scroll X" to "50" set "X Vel" to "0" set "Y Vel" to "0" change "Level" by 1 broadcast "Set Level" wait 0.5 secs if (touching color c[FF0000]?) set "Scroll X" to "50" set "X Vel" to "0" set "Y Vel" to "0" broadcast "Set Level" wait 0.5 secs switch to costume "costume1" point in direction (Save Direction) set "X Vel" to ((X Vel) * 0.95) change "Scroll X" by (X Vel) change y by (Y Vel) end change x by (X Vel) -------- Sprite: Sprite2 Costumes (1): costume1 (480x360) Sounds (0): Stacks (1): when green flag clicked go to x: 0 y: 0 go to front end -------- Sprite: terrain 1 Costumes (2): background1 (480x360) background2 (480x360) Sounds (0): Stacks (1): when green flag clicked set "Level" to "1" forever switch to costume (Level) set x to ((Scroll X) + (480 * 1)) set y to 0 end -------- Sprite: terrain 0 Costumes (2): background1 (480x360) background2 (480x360) Sounds (0): Stacks (1): when green flag clicked set "Level" to "1" forever switch to costume (Level) set x to ((Scroll X) + (480 * 0)) set y to 0 end -------- Sprite: terrain 3 Costumes (2): background1 (480x360) background2 (480x360) Sounds (0): Stacks (1): when green flag clicked set "Level" to "1" forever switch to costume (Level) set x to ((Scroll X) + (480 * 3)) set y to 0 end -------- Sprite: terrain 2 Costumes (2): background1 (480x360) background2 (480x360) Sounds (0): Stacks (1): when green flag clicked set "Level" to "1" forever switch to costume (Level) set x to ((Scroll X) + (480 * 2)) set y to 0 end --------
Offline