Groups
Groups
Groups are sets of objects, bricks, and items which can be placed all together with one click by a level designer. They are used to simplify level design and to allow modular placement of certain structures such as loops.
Case study: A group in action
The template level of Opensurge uses groups heavily because of the new brick specification. You may take a look at themes/template.grp for more information. Let's see a small piece of it:
group { brick 49 16 16 brick 50 0 16 brick 0 0 0 brick 50 32 16 brick 49 48 16 brick 0 32 0 brick 50 64 16 brick 49 80 16 brick 0 64 0 brick 50 96 16 brick 49 112 16 brick 0 96 0 brick 50 128 16 brick 49 144 16 brick 0 128 0 } //In this case, the objects are all bricks and therefore their names are all numbers.
In the above code, the syntax is as follows:
group //This must be present { ... brick/item/object name/id xpos ypos layer ... }
Where layer is an optional parameter which accepts green and yellow.
You must now add the grouptheme command to the .lev file in order to make the groups appear in the level editor. Let's take a look at a small piece of levels/template.lev:
// header name "Template" author "OS Team" version "1.0" requires 0.2.0 act 1 theme "themes/template.brk" bgtheme "themes/template.bg" spawn_point 56 6424 music "musics/template.ogg" grouptheme "themes/template.grp" startup ".default_startup" players "Surge" "Neon" "Charge"
Note: these files (.grp files) can be incredibly difficult to write if you attempt to write them by hand. The level editor offers a way to create them quite easily though. Simply create an empty level which you will place the selected objects into, save it, and then grab the coding out of the .lev file and format it to the above syntax. You must then repeat this for each group you wish to create.