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.

FIGURE 6-3<br />

Amplitude-modulated sine attack<br />

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

Here’s an example of modulating the frequency to change the attack pattern:<br />

// Alter sine wave attack for enemyactor by modulating frequency<br />

function moveEnemy() {<br />

enemyactor.moveLeft();<br />

// Modulate sine wave frequency by another sine wave<br />

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

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

}<br />

Figure 6-4 shows the modified attack pattern with the frequency shifted or modulated.<br />

FIGURE 6-4<br />

Frequency-modulated sine attack<br />

143<br />

Scripting Scripting Action Events

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

Saved successfully!

Ooh no, something went wrong!