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.

JavaScript Sample<br />

function moveMonster() {<br />

if(monster.canSeePlayer()) {<br />

monster.attack();<br />

} else if(monster.canSeeWeapon()) {<br />

monster.pickupWeapon();<br />

} else {<br />

monster.patrol();<br />

}<br />

}<br />

Figure 6-1 shows what this script looks like inside an editor.<br />

Visual Basic Sample<br />

FIGURE 6-1<br />

Sub moveMonster()<br />

If monster.canSeePlayer() Then<br />

monster.attack()<br />

ElseIf monster.canSeeWeapon() Then<br />

monster.pickupWeapon()<br />

Else<br />

monster.patrol()<br />

End If<br />

End Sub<br />

JavaScript sample view in editor<br />

C H A P T E R 6<br />

139<br />

Scripting Action Events

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

Saved successfully!

Ooh no, something went wrong!