Design Lab 5: Game Media [ Monday 6pm - Rm 908]
instructor: Jonah Warren
email: jonah AT feedtank DOT com
url: http://www.playfulsystems.com/teaching/2006/gamemedia
The following program has the following structure:
stop();
var numBoxes = 10;
var boxes:Array;
boxes = new Array(numBoxes);
for(var i=0;i<numBoxes;i++) {
boxes[i] = attachMovie("box", "box" + i, _root.getNextHighestDepth());
boxes[i]._x = random(175);
boxes[i]._y = -random(250) + -25
}
onEnterFrame = function() {
if (Key.isDown(Key.RIGHT)) {
guy._x = guy._x + 5;
}
if (Key.isDown(Key.LEFT)) {
guy._x = guy._x - 5;
}
var numHit = 0;
for(var i=0;i<numBoxes;i++) {
boxes[i]._y = boxes[i]._y + 2;
if (boxes[i]._y > 250) {
boxes[i]._y = -25;
boxes[i]._x = random(175);
}
if (boxes[i].hitTest(guy)) numHit++;
}
if (numHit > 0) guy.gotoAndStop(2);
else guy.gotoAndStop(1);
}
[ First click inside the rectangle, then press the left and right arrow keys. ]