I'm a, shall we say, "older" user of Scratch, so keep that in mind with this discussion.
I just started messing with Scratch, and am curious about a few things:
First, one thing I'd really like to be able to do is manually edit the scripts outside of the Scratch API. Is that possible at all? The only file I found so far is the project .sb file, which has a bunch of binary non-human-readable characters in it. No good.
Basically, I'm trying to avoid the tedium of manually entering x-y coordinates for the animation I'm building which is using 30 individual sprites which will move independently. If I could hand-edit scripts, I could programatically generate the code I want much more easily.
Next, I noticed in my project after working for quite a while, that I need to shift my starting position for the first set of sprites I'm working with (there are 5). Without having to manually change ALL the x-y coordinates that I entered, is there any way to, say, globally add or subtract from every x-y position entry I've created?
Ideally I wouldn't have used coordinates to position the sprites, but since there was no way that I'd found to have sprites follow a path (I'm using lots of diagonals and arcs), I had to use coordinates.
Also, I noticed that with only 5 sprites, and rather simple motion, much of my prescribed motion is supposed to be in sync, i.e. the sprites follow similar paths in parallel, I find the final product to be jumpy - they don't all move at precisely the same time, which will eventually be in sync with music. When I get up to the 30 I need, I can see it's going to be a mess. Does it have anything to do with the complexity of the sprite itself? Or is it just a global issue with the software?
Thanks in advance to anyone who can offer advice.
~Fyffer
Offline
I'm not an 'older' Scratch user but I will try to help you
A Scratch user named Jens developped Chirp (chirp.scratchr.org) - a rip-off of Scratch which contains many extensions to Scratch, including importing/exporting scripts. There is a lot of info on the chirp site. I think it's compatible with the original Scratch.
But that is a complicated way to go and if I were you, I'd rather opt for the following solution. As you probably already noticed, you can use lists in Scratch. When you show these lists on the screen using the checkbox, and right click the grey 'window', you'll see 'export' and 'import...' 'Export' will save all list items to a text file in the Scratch installation folder, one item at each line, and 'import' opens up a browse dialog. Select a text file and it will import a text file of the same layout to the list. You can probably use that - others have imported output of external programs with this import feature.
If your code can be generated automatically, it should also be possible to generate the lists contents automatically or just position the sprites to a position relative to the time past (timer variable in sensing)
The synch problem is well known, this is usually solved by broadcasting a message at a certain time interval. In order to make things synchronised on a song, I recommend using some sort of timeline list, containing messages you want to broadcast. It might sound weird or complicated (or badly expressed) but I can upload an example of what I mean if you want.
--JSO
Offline
Fyffer wrote:
Without having to manually change ALL the x-y coordinates that I entered, is there any way to, say, globally add or subtract from every x-y position entry I've created?
I'm not sure if it's possible to do in any other way other than manually editing it, but next time you do something like that, use a variable for the starting position coordinates:
[blocks]<go to x
<{ starting position x }> )y
<{ starting position y }>[/blocks]
Fyffer wrote:
Also, I noticed that with only 5 sprites, and rather simple motion, much of my prescribed motion is supposed to be in sync, i.e. the sprites follow similar paths in parallel, I find the final product to be jumpy - they don't all move at precisely the same time, which will eventually be in sync with music. When I get up to the 30 I need, I can see it's going to be a mess. Does it have anything to do with the complexity of the sprite itself? Or is it just a global issue with the software?
Scratch is quite slow in the default speed mode, so no, it's not a problem with your sprites. You can activate the Turbo Speed mode by going to Edit/Set single stepping/Turbo Speed. However, that feature is not available onine, so JSO's suggestion would be a better choice (that's how I synchronize my MIDI projects).
If you're looking for more advanced ways of synchronizing your MIDI project (assuming that it's MIDI), you might want to check out Jens' stuff: http://scratch.mit.edu/users/jens He has been known for creating synchronized MIDI projects especially adapted for the online player. (although, I'm not quite sure how they work, since I'm not a programming expert)
Offline
Fyffer wrote:
Basically, I'm trying to avoid the tedium of manually entering x-y coordinates for the animation I'm building which is using 30 individual sprites which will move independently. If I could hand-edit scripts, I could programatically generate the code I want much more easily.
You could programmaticly generate a series of coordinates to a text file, then load that text file into a list variable (right click on the list and choose "import..." to load data from a file). Use the list in your program.
This is how I build the word list for my Hangman game.
Last edited by BoltBait (2010-01-06 14:22:17)
Offline
First of, this is not Scratch API. This is Scratch IDE. With huge accent on I(ntegrated). You can't edit proper Scratch scripts outside it. That's why there is a spin-off with big chance of success, called M3OW (or Emerald).
There's a specification on .sb file somewhere.
Syncing is a problem for projects with many sprites and scripts. Broadcasts are quick enough to fix it in a way.
To modify all the coords, use global-x and global-y variables and then formulae to convert them to individual sprite coords.
If you came here for an advanced things to make a ballet on screen, I recommend you to use Flash - easier with lots of sprites. If you're still here, though, and want to upload the project to the site, get ready for pain, because it's painstaking.
Also, online player is bad at timing and rendering.
Offline
@filo5: Ya know, for the project I'm working on I was originally considering using flash, but then heard about Scratch, and I thought I could kill two birds with one stone: I'd be able to create my little animation, AND learn something I could use to teach my kids some programming concepts.
Thanks, all for the info. It will definitely help in the future.
Offline
You can possibly edit the scripts programmatically using macros. Scratch provides no native support for them, but there are general system ones.
Jens' Chirp has an XML script export feature...
As far as changing all of the sprites at the same time, I would do this:
1. Make an X and Y variable.
2. Make a broadcast script that runs as follows:
<when I receive[ MoveSprites ]>
<change x by( X )>
<change y by( Y )>
<stop script>
Now, just place above script in all 5 sprites.
If you need to move them, just set X and Y to the values that the sprites
should move (can also be negative), and run this:
<broadcast[ MoveSprites ]>
If you plan to do this in a loop, it is best to use
<repeat( n )>
|<broadcast[ MoveSprites ]and wait c>
<end>
Hope this helps!
Offline
See the thread on my "Scratch Softdev SDK', it has file read/write ability.
Offline