Now that you have defined the objects with their behavior in the form of events and actions, it is time to create the rooms or levels in which the game takes place. Any game will need at least one room. In these rooms we place instances of the objects. Once the game starts the first room is sho wn and the instances in it come to life because of the actions in their creation events.
There are a large number of possibilities when creating rooms. Besides setting a number of properties and adding the instances of the objects you can add backgrounds, define views, and add tiles. Most of these options are discusses later in Chapter 20. In this chapter we will only discuss some basic settings, the addition of instances of objects, and the setting of background images.
To create a room, choose Add Room from the Add menu. The following form will appear:
At the left you will see three tab pages (five in advanced mode). The objects tab is where you add instances of objects to the room. In the settings tab yo u can indicate a number of
settings for the room. In the backgrounds tab you can set background images for the room.
13.1 Adding instances
At the right in the room design form you see the room. At the start it is empty, with a gray background.
To add instances to the room, first select the objects tab if this one is not already visible. Next select the object you want to add by clicking on the button with the menu icon (or by clicking in the image area at the left). The image of the object appears at the left. (Note that there is a cross in the image. This indicates how the instances will be aligned with the grid.) Now click with your left mouse button in the room area at the right. An instance of the object appears. It will snap to the indicated grid. (You can change the grid in the settings; see below. If you hold the <Alt> key while placing the instance it is not aligned to the grid.) With the right mouse button you can remove instances. In this way you define the contents of the room. If you hold down the mouse button while dragging it over the room, multiple instances are added or removed.
As you will notice, if you place an instance on top of another one, the original instance disappears. Normally this is what you want, but not always. This can be avoided by unchecking the box labeled Delete underlying at the left. There are three other actions you can perform using the right mouse button: When you hold the <Ctrl> key while clicking on an instance with the right mouse button, the bottommost instance at the position is brought to the top. Holding the <Alt> key will send the topmost instance to the bottom. This can be used to change the order of overlapping instances. Finally, holding the <Shift> key while clicking with the right mouse button will remove all instances at the position, not just the top one.
There are four useful buttons in the tab at the left. When you press the Clear button all instances are removed from the room. When you press the Shift button you can shift all instances over a number of pixels. Use negative numbers to shift them left or up. This is useful when you decided to e.g. enlarge the room. (You can also use this to place instances outside the room, which is sometimes useful.) Finally there are two buttons to sort the instances by X or by Y coordinate. This is useful when instances partially overlap.
13.2 Room setting
Each room has a number of settings that you can change by clicking on the settings tab. We will only consider the most important ones here.
Each room has a name. Best give it a meaningful name. There also is a caption. This caption is displayed in the window caption when the game is running. You can set the width and height of the room (in pixels). Also you can set the speed of the game. This is the number of steps per second. The higher the speed, the smoother the motion is. But you will need a rather fast computer to run it.
At the bottom of the settings tab you can indicate the size of the grid cells used for aligning objects. By clicking on the button labeled Show you can indicate whether to e.g. show the grid lines. (You can also indicate here whether to show the backgrounds, etc. It is sometimes useful to temporarily hide certain aspects of the room.)
13.3 Setting the background
With the tab backgrounds you can set the background image for the room. Actually, you can specify multiple backgrounds. The tab page looks as follows:
At the top you will see the background color. You can click on it to change it. The background color is only useful if you don't use a background image that covers the whole room. Otherwise, you better uncheck the box labeled Draw background color because this will be a waste of time. At the top you see a list of 8 backgrounds. You can define each of them but most of the time you will need just one or two. To define a background, first select it in the list. Next check the box labeled Visible when room starts otherwise you won't see it. The name of the background will become bold when it is defined. Now indicate a background image in the menu. There are a number of settings you can change. First of all you can indicate whether the background image should tile the room horizontally and/or vertically. You can also indicate the position of the background in the room (this will also influence the tiling). Finally you can make the background scrolling by giving it a horizontal or vertical speed (pixels per step).
There is one more checkbox labeled Foreground image. When you check this box, the background is actually a foreground, which is drawn on top of everything else rather than behind it. Clearly such an image should be partially transparent to be of any use.