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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

If (cave_guard.isDisturbed()) {<br />

playMessage(text1.txt);<br />

waitForUser();<br />

playMessage(text2.txt);<br />

waitForUser();<br />

playMessage(text3.txt);<br />

waitForUser();<br />

}<br />

In this example, the cave guard is disturbed and gives messages to the player, while<br />

waiting for the player to acknowledge receipt of the given messages. If the player<br />

came back to try to talk to the cave guard again after seeing the first three messages,<br />

you might want the cave guard to give random responses this time. You could do this<br />

by simply extending your script so that any contact after the first or initial contact<br />

would give random responses loaded into a file for playback to the player.<br />

Shooter Flying Patterns<br />

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

For arcade-style shooting <strong>game</strong>s, enemies often attack in different formations,<br />

speeds, and flying patterns. These kinds of behaviors can be edited via a script system<br />

as well. Let’s look at an example.<br />

Suppose you’re building a shooter. Enemies might simply attack from the far right<br />

and move toward the left of the screen. This is the formula for almost every classic<br />

side-scrolling shooter. Maybe we want to control the behaviors of those enemy attack<br />

formations. Here’s where I hope we all paid attention in math class! D’oh! <strong>Game</strong>s are<br />

pure math in motion. How does all of this amazing and brilliant 3-D manipulation<br />

happen? It’s solid math, toes to top hats.<br />

Scripting has become a very important part of the designer’s role on a development<br />

team, so knowing (at the very least) some basic programming and math is extremely<br />

helpful here. If your basic programming skills are rusty or nonexistent, download a<br />

free version of a JavaScript editor at (www.ngweb.biz/software/djsedit.shtml) and<br />

start experimenting.<br />

Here’s a simple script for defining the attack behavior of an enemy actor (for example,<br />

a Martian horde or evil flying donut) called enemyactor:<br />

function moveEnemy() {<br />

enemyactor.moveLeft();<br />

// Scale sine wave by 100 and add 240 to center<br />

// on a 640x480 screen<br />

var x = enemyactor.getX()%360;<br />

enemyactor.setY(100*sin(x*4)+240);<br />

}<br />

141<br />

Scripting Action Events

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

Saved successfully!

Ooh no, something went wrong!