Brock J. Stearn
Task 12
Programming for Artists
Magic Ball
Left, Right, Up, and Down - Move the Magic Ball around
Spacebar - Make the Magic Ball bigger
Shift - Make the Magic Ball smaller
The code
/*
Programming for Artists - Assignment #12
Brock J. Stearn
"Magic Ball"
*/
var dist = 4;
//
function updateBall() {
// called upon key event
// move the ship based on key just pressed
//
switch (Key.getCode()) {
case Key.UP :
Mask._y -= dist;
break;
case Key.DOWN :
Mask._y += dist;
break;
case Key.LEFT :
Mask._x -= dist;
break;
case Key.RIGHT :
Mask._x += dist;
break;
case Key.SPACE :
zoomin();
break;
case Key.SHIFT :
zoomout();
break;
}
}
//
// For SpaceBar - Make Ball Bigger
// No larger then 600
function zoomin() {
if (Mask._xscale <= 600) {
Mask._xscale = Mask._xscale * 2;
Mask._yscale = Mask._yscale * 2;
}
}
//
// For Shift - Make Ball Smaller
// No smaller then 25
function zoomout() {
if (Mask._xscale >= 25) {
Mask._xscale = Mask._xscale / 2;
Mask._yscale = Mask._yscale / 2;
}
}
*********** For the Mask ************
this.Mask_Text._x = 530-(_root.mask._x*2);
this.Mask_Text._y = 375-(_root.mask._y*2);