Slow Glass Animation System
Return to the slow glass main page
Format
New lines are significant, each item must be on a separate line but initial whitespace is ignored.
Comment lines start with hash or are enclosed by /* */.
Directives
- scene <name> - starts a new scene (and ends previous one)
- end scene - ends current scene
- finish - stop processing commands (everything else ignored)
- end file - same as above
- include <file> - read file as if inserted at this point
- display height/width <value> - sets window dimensions
- display fullscreen - full screen window
Triggers
- begin - runs on scene load (or file load if at top level)
- after <duration> - runs after duration has elapsed from scene start
- on key <key> -runs when key is pressed
- on click - runs when any mouse key is pressed
- at time <timecode> - runs when time of day matches the timecode
- each time <timecode> - runs when time of day matches timecode (including wild cards)
- every <duration> - runs after duration has elapsed from scene start and repeats
- when (expression) - Evaluated once per second, runs once when the Python expression becomes truthy
- while (expression) - Evaluated once per second, runs every time the Python expression is truthy
Commands
In most cases unnecessary words can be omitted, the minimum phrasing is shown in bold
Resource Management
- from <folder> - take all resources from the named folder
- load <file> named <r-tag> [split <cols> by <rows>] - load resource of any type
- unload <r-tag…> - remove resources from memory
Scene Management
- start <scene> - start scene operating
- stop [<scene>] - stop current scene or named scene (removes all images)
Sprite Placement
-
place <r-tag> [named <s-tag>] at <x>,<y> depth <z> [size scale <w>,<h>] - place an image on to the screen -
put <r-tag> [named <s-tag>] as background top bottom left right ground sky [depth <z>] - place an image on to the screen in a fixed location - raise/lower <s-tag> to <value> - set depth of image on screen to value
- raise/lower <s-tag> by <value> - change depth of image on screen up or down the set of images
- show/hide <s-tag> - reveal or remove images from screens, but still update changes
- show/hide <s-tag> for <duration>- reveal or remove images from screens just for a set length of time
- remove <s-tag…> - remove images from the screen
Animated Sprite Management
- window <s-tag> at <ix>,<iy>,<iw>,<ih> - define a window on the source image centered at ix,iy of size iw,ih
- zoom window <s-tag> to <iw>,<ih> [in <duration>]- set new window size on source image
- move window of <s-tag> to <ix>,<iy> [in <duration>]- set new window centre on source image
-
scroll window of <s-tag> up down left right [at <speed>] - move window centre continuously at speed pixels per minute - set animation rate of <s-tag> to <value> - if image is sprite, update the frame every <value> seconds
- advance <s-tag> to <number> - switch sprite to the given frame (set rate to zero to use)
- advance/reverse <s-tag> by <number> - advance or reverse sprite by the given number of frames
(Movie image sources can only advance)
Sprite Movement
- move <s-tag> to <x>,<y> [in <duration>] - Move image to a new location on screen in a given time
- move <s-tag> to <x>,<y> [at <speed>] - Move image to a new location on screen at a given speed
- move <s-tag> by <x>,<y> [in <duration>] - Move image relative to current position a given time
- move <s-tag> by <x>,<y> [at <speed>] - Move image relative to current position at a given speed
- set speed of <s-tag> to <speed> [in <duration>] - set the speed of image (acclerate/slow if duration given)
- rotate <s-tag> to <value> - turn image on screen to the given angle (degrees clockwise, 0 at top)
- rotate <s-tag> by <value> - turn image on screen by given angle (degrees clockwise)
- pause/resume <s-tag> - pause or resume all current changes to an image (does not change visibility)
Sprite Sizing
- resize <s-tag> to <w>,<h> [in <duration>] - change size of image on screen to given dimensions
- scale <s-tag> to <x%>,<y%> [in <duration>] - change size of image on screen by given proportions of the original image size
- scale <s-tag> by <x%>,<y%> [in <duration>] - change size of image on screen by given proportions of the current image size
Sprite Appearance
- set transparency of <s-tag> to <value> [in <duration>] - set image transparency (0 = solid, 100 = transparent)
- darken <s-tag> to <value> [in <duration>] - make image darker (0 = no change, 100 = solid black)
- lighten <s-tag> to <value> [in <duration>] - make image lighter (0 = no change, 100 = solid white)
- blur <s-tag> to <value> [in <duration>] - make blurry (0 = unchanged, 100 = very blurry)
Text Commands
- create text <t-name:> - create a named text item
- set content of <t-name> to text…. - sets the text to display
-
set style of <t-name> to bold italic underline - sets text style - set color of <t-name> to [named web color] - sets text foreground color
- set background of <t-name> to [named web color] - sets text background color
- set size of <t-name> to number - sets the point size of the text
Once created a text item be used as a source image for a sprite to which all the comands above can be applied.
Sounds
- play <r-tag> - play a sound resource
- set volume of <r-tag> to <value> - set volume of sound resource (0-100)
Group Management
- create group <name> - create a named group of sprites.
- add to group <name> <s-tags…> - add named sprites to the group (removes them from scene)
The named group can now be used as an image source for sprites, e.g. “place named-group at x,y,z” and all sprite commands operate on the whole image, however individual sprites within the group can still be operated on by name.
System Commands
- log <args…> - write arguments to the console
- let <var> be (expression) - set the value of a variable
- exit - ends program
Conditionals
Any command may be prefixed with a conditional, of the form:
if (expression) command...
Depending on system configuration, expression can be any valid python code, or a limited arithmetic expression. In either case the command is executed if the expression evaluates to a truthy value. Slow-glass variables are expanded each time the expression is evaluated.
Variables
All variables start with $. Unset variables evaluate to “???”.
Variables are local to scenes, to access variables in other scenes use $<scene-name>:variable.
Create / update variables with the make command, e.g.
make COUNT be 1
make COUNT be ($COUNT + 1)
Variables in commands are evaluated every time the command is invoked, variables in triggers are expanded when the trigger is created (i.e. when the scene is started).
Built-in Variables
- $SECOND - current second (0 - 59)
- $MINUTE - current minute (0 - 59)
- $HOUR - current hour (0 - 23)
- $DAY - day of month (1-31)
- $DAYNAME - name of day as a string
- $MONTH - month of year (1-12)
- $MONTHNAME - name of the month as a string
- $YEAR - year as a 4 digit number
- $SEASON - season as lower case string (needs $HEMISPHERE set correctly)
- $WIDTH - width of the display in pixels
- $HEIGHT - height of the display in pixels
- $FRAMERATE - update rate of display (for Pygame, not the physical device)
- $CENTREX, CENTREY - x, y coordinates of the centre of the display
- $MOUSEX, $MOUSEY - current x & y coordinates of mouse
- $PERCENT - random value from 0 to 100, set on use
- $CHANCE - random value from 0.0 to 1.0, set on use
- $RANDOMX, $RANDOMY - random values somewhere within the current window
- $KEY - key currently being pressed (None if none pressed)
- $LASTKEY - last key that was pressed
- $CLICKX, $CLICKY - x & y coordinates of the last time the mouse was clicked
Sprite properties
Some sprite properties are available as variables, using the sprite tag as the variable name, followed by a ‘.’ and one of the following:
- x - current x coordinate
- y - current y coordinate
- w - current width
- h - current height
- s - current speed (pixels per second)