<< Previous

Next >>

indy_logo.gif (3362 bytes)

Step 2: deeping into the business

The first example offered very little gameplay. Let's make it more appealing.
We will add a nice background, and a few interesting commands for the player.

tutorial_2.gif (14829 bytes)Backgrounds are essential in this kind of games, but adding a background is not about just specifying a picture. You need to specify a walkable area for the player. If you don't, realism will be lost since the player will freely walk across the screen, giving the impression of flying above everything.
The areas are defined in a two-color (black&white) picture with the same pixel ratio as the backdrop, as show below. Care must be taken of initially placing the character in a "walkable" area of the room, otherwise he won't be able to move at all! This is really a common error.
The two image files are specified in the room's IMAGE and WALK sections of the script, like this:


ROOM main
{
	IMAGE
	{
		"gr/idol.jpg"		// Backdrop picture
	}
	WALK
	{
		"gr/idol_bm.gif"	// Walking area
	}
	ITEM Indy       // My hero   :)
	{
		ANIMATION
		{
			// --- standby images ---
			0  0  "gr/indy_d.gif"  1 // Looking South
			0  1  "gr/indy_r.gif"  1 // Looking West
			0  2  "gr/indy_u.gif"  1 // Looking North
			0  3  "gr/indy_l.gif"  1 // Looking East
			// --- walking animation ---
			1  0  "gr/indy_wd.gif" 4 // Looking South
			1  1  "gr/indy_wr.gif" 6 // Looking West
			1  2  "gr/indy_wu.gif" 4 // Looking North
			1  3  "gr/indy_wl.gif" 6 // Looking East
			// --- talking animation ---
			2  0  "gr/indy_td.gif" 7 // Looking South
			2  1  "gr/indy_tr.gif" 4 // Looking West
			2  2  "gr/indy_tu.gif" 1 // Looking North
			2  3  "gr/indy_tl.gif" 4 // Looking East
		}
		POSITION { 170 170 0 }
		ITEM whip
		{
			ICON { "gr/whip.gif" }
		}
	}

	ITEM Idol	// An archeological marvel !
	{
		IMAGE { 0  0  "gr/idol.gif" }
		POSITION { 155 135 0 }
	}
	/* And now, a bit of foreground vegetation */
	ITEM plant_1
	{
		IMAGE { 0  0  "gr/plant_1.gif" }
		POSITION { 0 182 0 }
	}
	ITEM plant_2
	{
		IMAGE { 0  0  "gr/plant_2.gif" }
		POSITION { 256 182 38 }
	}
	ITEM plant_3
	{
		IMAGE { 0  0  "gr/plant_3.gif" }
		POSITION { 190 182 0 }
	}
}
/* Triggers */
COMMAND Look whip
{
	SAY indy "I never get out without it!"
}
COMMAND * whip	// This will match any sentence refering to the "whip" object
{
	SAY indy "I can't do that"
}

In the listing, you can also see the item's ANIMATION block detailed.
There are 4 directions (N,S,E,W) and several attitudes (STANDBY, WALKING, TALKING) for each item. Each attitude and each direction is associated to a number. For example, "talking" is attitude #2 and "south" is direction #0 for the system.
For each attitude and each direction, an image filename can be specified. The last number after the image filename is the actual number of frames in the animation. As you can see below, an animation file is made up of an horizontal stripe of frames included into a single regular picture. So, for INDY_WR.GIF this number would be 6. All the frames included in the stripe must have exactly the same pixel width.
tutorial_2_2.gif (1662 bytes)
The IMAGE blocks are very similar to ANIMATION, except that only one frame is included in the specified image file, so no need to specify any number after the filename.
You only need to specify images for the directions and attitudes that are really going to be used throughout the game. For example, the vegetation items are never going to move, so only one image is specified for them. Also, no ICON block is specified for them because they are not expected to appear in the player's inventoy.

The 3 coordinates positioning system is quite simple. The first 2 coordinates are the absolute pixel position within the background picture, with point (0,0) being the topleft corner of the background. The third coordinate is the elevation from the floor (normally zero). Positioning is always relative to the middle of the item's bottom line, that is, between the feet of the character.

Notice the use of the wildcard character "*" to match words in COMMAND sentences. In this case, any verb the player tries relative to the Whip object, will lead to an answer from the hero.

As before, you have to Import this script into the engine, and test it.

<< Previous

Next >>

Back to the main page

Hosted by www.Geocities.ws

1