<< Previous

Next >>

indy_logo.gif (3362 bytes)

Step 4: making it harder for the player

This will actually make it harder for the programmer, too  ;-)
Suppose you want the player to talk to someone several times in order to get an item. We will need an INTEGER variable to control the program's flow.


ROOM main
{
	IMAGE { "gr/street_2.gif" }
	WALK { "gr/street_2_bm.gif" }

	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 { 140 140 0 }
	}

	ITEM sophia
	{
		ANIMATION
		{
			// --- standby images ---
			0  1  "gr/sophia_r.gif" 1 // Looking West
			0  3  "gr/sophia_l.gif" 1 // Looking East
			// --- walking animation ---
			1  1  "gr/sophia_r.gif" 1 // Looking West
			1  3  "gr/sophia_l.gif" 1 // Looking East
			// --- talking animation ---
			2  1  "gr/sophia_tr.gif" 4 // Looking West
			2  3  "gr/sophia_tl.gif" 4 // Looking East
		}
		INK { 3 }	// Sophia's speech will be pink  :)
		POSITION { 250 143 0 }
		ITEM medallion
		{
			ICON { "gr/medalion.gif" }
		}
		INTEGER { f }	// a simple flag
		COMMAND look sophia
		{
			SAY indy "My favorite girl"
		}
		COMMAND talk sophia
		{
			IF
			{
				EQ f 0	// ( f=0 ?) Did he talk to her before?
			}
			THEN
			{
				MOVE indy 210 142 0	// Move to her left.
				WAIT indy		// Wait for him to finish walking.
				TURN indy sophia	// Look at her.
				TURN sophia indy	// Look at him!
				SAY indy "Sophia!  I missed you so much since Atlantis!"
				WAIT indy		// Wait for his sentence to finish.
				SAY sophia "You? But you almost let me die there!"
				WAIT sophia		// Wait for her sentence to finish.
				SAY sophia "I will never play any adventure with you again!"
				WAIT sophia		// Wait for her sentence to finish.
				SAY indy "Sophia!  wait!"
			}

			IF
			{
				EQ f 1	// f=1 ?
			}
			THEN
			{
				MOVE indy 210 142 0	// Move to her left.
				WAIT indy		// Wait for him to finish walking.
				TURN indy sophia	// Look at her.
				TURN sophia indy	// Look at him!
				SAY indy "I need you. Give me another chance."
				WAIT indy
				SAY sophia "Mmmmm..."
				WAIT sophia
				SAY sophia "Take this, it might help you today."
				GIVE indy medallion	// Bingo!
				SOUND "snd/medal.au"
			}

			IF
			{
				EQ f 2	// ( f=2 ?) Did he already get the medalion from her?
			}
			THEN
			{
				SAY indy "Better let her alone for now."
			}

			ADD f 1		// (f=f+1) Increase variable "f"
		}
	}
}

COMMAND look *
{
	SAY indy "Nothing special"
}
COMMAND * *
{
	SAY indy "I can't do that"
}
COMMAND * * *
{
	SAY indy "I can't do this"
}

Look at the COMMAND block that handle the conversation through the use of an integer variable.
Variable f indicates the progression level reached within the conversation. The player will have to talk the girl two times to get the medalion. Initially, f = 0 , and f increases every time the player decides to talk to the girl. Based upon the value of this indicator, the conversation is different every time, giving the impression to the player that he is progressing by talking to her again.
Keep in mind that all variables in a script (whether global or local) are always "static", meaning that they retain their values during the whole game. Also, integer variables are all equal to 0 at the beginning of the game.

The WAIT keyword is essential in cutscenes. It pauses execution, taking control out of the player, while a character finishes his sentence or finishes walking.

MOVE and TURN are simple to use instructions that can give characters a bit of life by avoiding being too motionless.

The item "medalion" is placed into the player's inventory with the GIVE instruction. A wave file is played to reward the player at that second, with the SOUND instruction.

The speech text color can be specified for each character (see the Reference Manual for the list of color codes in SETINK). Using different colors makes it easier for the player to follow the conversation.

<< Previous

Next >>

Back to the main page

1