SLUDGE

The Background Image


There are two types of graphics used in SLUDGE - those which are drawn every frame (such as speech, status bars and so on) and those which make up the background image. The benefits of graphics which are drawn every frame are that elements can be moved, removed or changed without the risk of leaving remnants behind. Characters are the most obvious example of graphics which are drawn in this way - therefore it is simple to reposition or hide a character without having to reload any other elements of a scene which was previously obscured.

The benefit of drawing graphics onto the background image is that there is no need to remember individually all the elements which make up a scene. This means that the engine can run as quickly as possible, because it need not draw (for example) a blank wall, then a door on top of the wall, then a handle on top of the door. Changing the background image is a one way process but, once done, no extra memory is taken up even if a large number of elements have been drawn onto it.

Commands which change the background image:

addOverlay - loads a file and positions it on the screen. This can be used to load an entirely new backdrop, or to animate part of a scene (for example, by loading a number of frames of animation for a blinking light which are drawn one after another in a loop).

blankArea - draws a solid rectangle onto the background in the current blank colour, as specified by the setBlankColour function.

blankArea - fills the entire background image with the current blank colour.

burnString - "burns" text into the backdrop image (using the brightness of the greys in the current font to achieve a high-speed anti-aliased look on any background).

hardScroll - moves the entire background image up or down any number of pixels, filling the area uncovered with the current blank colour. (Don't try and use this to create a scrolling room; it's something else entirely!)

mixOverlay - identical to addOverlay but using 50% transparency.

pasteCharacter - fixes the current image for a particular character onto the background, scaled. Not all that useful, but handy for special effects such as character trails.

pasteImage - adds a sprite to the backdrop image. Normally, sprites are used for characters and the mouse cursor, but for an inventory actually drawing onto the background is a useful way of showing a large number of sprite bank images on-screen at once.

pasteString - writes text onto the backdrop image. This is useful for menus, messages, credits and close-ups of books or computer screens, for example.

setBackgroundEffect and doBackgroundEffect - define and then perform an effect on the background image (eg. blur or emboss).

showBoxes and showFloor - useful for debugging. These commands draw lines onto the background image showing the location of interactive screen regions (created by the addScreenRegion function) and walkable areas (created by the setFloor function) respectively.

Commands for reading the background image:

getPixelColour - returns the colour of the pixel at a certain position on the background image.

Freezing the background image:

It is also possible to freeze the entire scene, which pastes all visible characters onto the background image (as well as removing all screen regions and pausing any running functions). Again, this is useful for messages and menus, as well as full-screen inventories, in which interaction with the objects on the screen may not be desirable. The unfreeze command can then be used to bring back the previously frozen scene, putting back any characters and screen regions as well as restarting any paused functions.

When you call the freeze command, the width and height of the new background image will be set to the width and height of the window or screen, even when the frozen layer underneath has been resized using the setSceneDimensions function.

See also:

Scrolling Scenes