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 />

158<br />

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

Catching<br />

� Line factor Adjust to increase or decrease line-drive occurrences.<br />

� Fly factor Adjust to increase or decrease fly ball occurrences.<br />

Here’s what a hitting-oriented script might look like:<br />

// JavaScript sample of "hitting" support<br />

function hitBall() {<br />

// Let's determine what happens when the ball is hit.<br />

// This script only takes into account angle to bat, also<br />

// should use ball speed and angle of the bat to player,<br />

// bat speed, bat arc, etc.<br />

if(ball.getAngle()>75) {<br />

ball.popupFoul();<br />

} else if(ball.getAngle()>60 || ball.getAngle()50 || ball.getAndle()40 || ball.getAngle()

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

Saved successfully!

Ooh no, something went wrong!