Costumes#
You can add costumes to a sprite by specifying their file paths relative to the project directory.
costumes "path/to/costume.svg";
Listing Multiple Costumes#
To add multiple costumes, separate their file paths with commas. Costumes will appear in the order you list them in the costumes statement.
costumes "path/to/costume1.svg", "path/to/costume2.svg";
Each costume's name is taken from the file name without its extension.
Renaming Costumes#
You can rename a costume using the as keyword.
costumes "path/to/costume.svg" as "new name";
Using Wildcards (Globs)#
You can use wildcards to include multiple costumes, such as all .svg files in a directory. Use the * wildcard for this.
costumes "path/to/costumes/*.svg";
Costumes added this way are sorted alphabetically.
@ascii/ Prefix#
If a costume name starts with @ascii/, goboscript will generate one costume per printable
ASCII character. Any text after the prefix is prepended to each generated name.
costumes "blank.svg" as "@ascii/";
Scratch compares strings case-insensitively. Switching costumes is, however, case-sensitive. This can be utilized to detect the case of a character by first switching to the costume named by the character, then using the costume number to detect the case.
For example, if you have a costume named "A" at position 1, and a costume named "a" at position 2, you can use the following code to detect the case of a character:
switch_costume char;
if costume_number() == 1 {
say "upper case A";
} else {
say "lower case a";
}
Given that these are placed at the beginning of the costumes list, you can get the
ASCII value of a character by adding 31 to the costume number.
func ord(c) {
switch_costume $c;
return 31+costume_number();
}
You can convert a byte to a character by subtracting 31, then switching costumes.
func chr(c) {
switch_costume $c-31;
return costume_name();
}
Importing higher-quality bitmap costumes (larger than 480x360)#
You can import high-quality bitmap images by converting them to SVGs using this Python script.
./hq.py background.png --scale 4 # scale-down by a factor of 4, ex: 960x640 -> 480x360
Use Makefiles to automate this process, see the default Makefile generated by
goboscript new -m for reference.