25.12.2012 Views

Ultimate Game Design : Building game worlds

Ultimate Game Design : Building game worlds

Ultimate Game Design : Building game worlds

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>Building</strong> <strong>Game</strong> Worlds<br />

146<br />

U L T I M A T E G A M E D E S I G N<br />

Here’s a script sample to make the enemies cower in fear and then flee once they<br />

have tripped the “fearthis” trigger:<br />

Line of Sight<br />

Crowd<br />

// JavaScript sample of "fearthis" trigger support<br />

if(monster.inside(fearThisTrigger.getBoundary())) {<br />

monster.playAnimation(fearAnim);<br />

monster.reverseDirection();<br />

}<br />

Line of sight has a couple of different uses and meanings in <strong>game</strong> terminology.<br />

Usually, it refers to what is visible to an actor. It could refer to what is visible to the<br />

particular actor representing the player in the <strong>game</strong>. Normally, it refers to whether or<br />

not an actor can see a particular object or another actor. Line of sight can be calculated<br />

in several ways, and doesn’t always mean that something is physically viewable from<br />

a character’s perspective. Enough semantics.<br />

A line of sight trigger launches its event when a player breaks the line of sight radius;<br />

in other words, when the player gets physically close enough on the grid to the line of<br />

sight trigger. This can be used to start a giant boulder rolling perilously into motion<br />

(think of Raiders of the Lost Ark/Indiana Jones). When a character breaks the line of<br />

sight trigger, the boulder-rolling animation is launched on a motion path (in other<br />

words, where the boulder starts rolling from, what path it follows, and where it is<br />

destroyed or terminates).<br />

Notice that many triggers rely on a radius. Much of tuning the right “feel” for the<br />

interaction between events comes down to tuning radii.<br />

If the boulder is visible to a player, here’s a script that starts the boulder rolling and<br />

focuses a camera on the action:<br />

// JavaScript sample of "line of sight" trigger support<br />

if(objectVisible(player.currentPosition(), boulder)) {<br />

boulder.startRolling();<br />

playSound(boulderSound);<br />

camera.focus(boulder);<br />

}<br />

A crowd trigger, when tripped, gives animation behavior information to a crowd of<br />

actors. For instance, you might have entered a tribal village with several warriors<br />

lined up at the village gateway to meet you. By picking up or attempting to steal<br />

something from the village, you might trip a crowd trigger. This might cause all of

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!