Program Games with Sauerbraten Cube 2 CubeScript

How to Create and Edit Maps for the Sauerbraten Games Engine

© Mark Alexander Bain

Sep 19, 2009
An Introduction to Sauerbraten Cube 2 CubeScript, Mark Alexander Bain
The Sauerbraten Cube 2 games engine allows programmers to modify maps by using its GUI and CubeScript code. And that's all done while a game is running

Cube 2: Sauerbraten is a first person shoot-em-up games engine. It can be played in single player mode or in multiplayer mode across a network. However, this is more than just a bit of light relief for a programmer while they're waiting for a program to compile or for a database to update. Cube 2: Sauerbraten allows a user to make changes to the game in one of two ways:

  • editing maps using the Cube 2: Sauerbraten GUI (Graphical User Interface)
  • using the CubeScript scripting language

And most remarkably, the programmer can do this while a game is actually running. The starting point is, therefore, to download Cube 2: Sauerbraten and then to start creating customized maps.

Obtaining Cube 2: Sauerbraten

To obtain Cube 2: Sauerbraten it's just a matter of downloading it from the Cube 2: Sauerbraten web site. It's free and is open source (it is written in C++).

Running Cube 2: Sauerbraten

Once it's been installed it can be run by:

  • using the Sauerbraten icon in the start menu
  • running sauerbraten.bat on a Windows machine
  • running unix_ sauerbraten on a Linux machine

The command file is particularly useful to the programmer because it allows them to start the application in different modes. For example, changing:

bin\sauerbraten.exe -r %*

to:

bin\sauerbraten.exe -tr %*

will start Cube 2: Sauerbraten in Windowed mode rather than full screen (as shown in figure 1 at the bottom of this article). That will be very useful when referring back to this article to see what to do next.

Editing the Cube 2: Sauerbraten Map

Existing maps can be edited from within a game but, to begin with, it may be easier to start with a blank canvas:

  • press "E" to start the edit mode
  • press "`" (next to the number 1) to enable the Cube 2: Sauerbraten CubeScript console
  • enter newmap, and it's worth noting that every CubeScript input must be preceded by a "/", for example:
    /newmap

A new, blank map will appear (as shown in figure 2). This can be edited in a few ways:

  • items such as walls an pits can be created by left clicking a block and scrolling the mouse wheel
  • items can be added by pressing the Esc key and then selecting "Editing..."
  • the programmer can use CubeScript to create objects. For example, a tree can be added by entering:
    /newent mapmodel tree1

This new map can then be saved (and this should be done as often as possible) by using the savemap command, for example:

/savemap mabworld

This will save the map (in this case it will be saved as mabword.ogz and will appear something like figure 3), and it can reloaded at any time by typing:

/map mabworld

However, at the moment, the new map will not be available for any games.

Making the Map Visible to Game Players

Cube 2: Sauerbraten accesses all of its maps though a set of menus, but these menus do not update automatically. That must be done manually. Fortunately this is not difficult to do. The information is stored in a text file in the Cube 2: Sauerbraten directory, and that file is:

data/menus.cfg

The new map is then added to the most appropriate menu, for example:

conceptmaps = "ladder spiralz canyon secondevermap firstevermap mabworld"

When Cube 2: Sauerbraten is restarted then the new custom map will be available to any players and it can be used in any of the single or multiplayer game modes(as shown in figure 4). It can then be tested, modified and remodeled as required.


The copyright of the article Program Games with Sauerbraten Cube 2 CubeScript in Computer Programming is owned by Mark Alexander Bain. Permission to republish Program Games with Sauerbraten Cube 2 CubeScript in print or online must be granted by the author in writing.


An Introduction to Sauerbraten Cube 2 CubeScript, Mark Alexander Bain
 Figure 1 Cube 2: Sauerbraten, Mark Alexander Bain
Figure 2: A Blank Map, Mark Alexander Bain
Figure 3: A Custom Map, Mark Alexander Bain
Figure 4: The Custom Map in Action, Mark Alexander Bain


Post this Article to facebook Add this Article to del.icio.us! Digg this Article furl this Article Add this Article to Reddit Add this Article to Technorati Add this Article to Newsvine Add this Article to Windows Live Add this Article to Yahoo Add this Article to StumbleUpon Add this Article to BlinkLists Add this Article to Spurl Add this Article to Google Add this Article to Ask Add this Article to Squidoo