Return to the main SameGame help page
A layout for SameGame consists of a layout definition file and one or more resource files. They are placed either in a subfolder of the layout folder, or zipped together in a ZIP file, with the ZIP file being put in the layout folder. The layout definition file is a plain ascii text file and must have the extension ".txt".
Consider, for example, the SameGame application being located in c:\games\samegame, and you created two files: mylayout.txt and mytileset.png. You may now create a subdirectory c:\games\samegame\layout\mycollection and put both files in this subdirectory, or you may zip them together in a file mycollection.zip and put that file in the directory c:\games\samegame\layout.
Within a layout definition file, lines are either comments, empty, or they consist of pairs of the form
Comments start with # or ; or / or ' and extend to the end of the line.
There are only two required entries; all other entries are optional. Those two entries are color-max and img-tiles. These two entries define the basic tileset that is needed to render the tiles of the game.
The tileset is an image showing one tile for every possible color, aligned in a row, like this:
All tiles must have the same size, but they need not be square. Therefore, it is necessairy to tell the programm how many tiles the tileset contains. Also, it is necessairy to tell the programm the name of the tileset image file. Example:
This requires of course that there is a file rectangle.png in the same folder as the layout definition file, and that it contains 10 different tiles.
The tileset image file can be a PNG, a BMP, a JPEG, a GIF, a TIFF or a XPM file. If it contains an alpha channel, SameGame will use the alpha channel to blend the tiles with the background.
If you don't specify a name for your layout, the filename of the layout definition file (without the extension .txt) is used. But with the keyword name, it is possible to explicitely set a name for your layout. This name will show up in the list of layouts in the Extra menu. Example:
If two different layouts share the same name, only one of them will show up in the game. It is therefore advisable to choose a name that is likely to be unique, like author: layout, as in the example above.
It is possible to specify alternative tileset image files for those tiles the mouse pointer is hovering over. Two cases are discriminated: the mouse pointer hovering over a single, isolated tile, and the mouse pointer hovering over an area of several tiles of the same color. The tilesets for both cases can be specified with the entries img-single (isolated tile) resp. img-hover (area of several tiles). Example:
If you don't specify img-hover or img-single, the value of img-tiles is used instead.
The default background of a layout is a uniform black. The easiest way to specify a different background is to specify a background color using the entry bg-color. This can be done in several ways. First, you can specify a tuple of three integers in the range 0...255, indicating the values for red, green and blue:
It is also posible to use the syntax of html color specifications, that is, a # followed by three hexadecimal numbers, like this:
It's possible to abreviate #rrggbb as #rgb, for example #aa5533 as #a53.
Another possibility is to use named colors. These color names are case insensitve, and internal whitespace within the name is ignored, that means, instead of saddlebrown, you are free to write Saddlebrown, SaddleBrown, saddle brown or SADDLE BROWN, as you like:
It is also possible to specify an image that should be used for the background. Once again, several different file formats are allowed, and alpha channels are respected. The name of the background image file is specified with the keyword bg-img.
Usually, the background image will not be of the same size as the playing field, since the user is free to set the dimensions of the game. There are different strategies to deal with this. One strategy is to tile the background image, repeating it as often as necessairy. This is the default behaviour, but it can be explicitely set with the value tile.
Another possibility is to resize the background image so that it fits the size of the game panel. This is achieved with the value scale.
Finally, it is possible to align the background image with the borders of the game panel, or to center it. This means that it is possible that not all of the game area is covered by the background image.
Those strategies can be chosen independently for the horizontal x-axis and the vertical y-axis. For example, it is possible to stretch the background image horizontally, and then to repeat this stretched version vertically, like this:
Possible values for the keyword bg-img-x are:
right
center
left
scale
tile
Possible values for the keyword bg-img-y are:
top
center
bottom
scale
tile