created by Bradd Birmingham
INSTRUCTIONS
First dodge all 15
snowballs!
Then shoot the Ice Giant in the head to kill him.
*If you are hit, you must Refresh
in order for game to work right.
CONTROLS
Arrows : move you up, down,
left, right
Space Bar : fires missile
STORY
In northern Alaska an evil as old as the earth has awoken.
The town of Smallville is under attack by an Ice-Giant.
Its up to you, Guy Malone, to save Smallville from destruction.
here's the code used to construct it..
// collision check - snowball to guy relationship
function collisioncheck() {
// list variables for snowball & guy's circles
var p = guymalone.getlcircle();
var d1x = snowball._x - p.x;
var d1y = snowball._y - p.y;
p = guymalone.getrcircle();
var d2x = snowball._x - p.x;
var d2y = snowball._y - p.y;
// the math
var d1 = Math.sqrt((d1x * d1x) + (d1y * d1y));
var d2 = Math.sqrt((d2x * d2x) + (d2y * d2y));
// set touch threshold - any separation less than this implies touch
var touchThreshold1 = snowball.radius + guymalone.leftcircle.radius;
var touchThreshold2 = snowball.radius + guymalone.rightcircle.radius;
// check distance (separation) against threshold
if ((d1 <= touchThreshold1) || (d2 <= touchThreshold2)) {
// hit! collision detected
guymalone.gotoAndPlay("death");
}
//
// **** missle against head relationship
// distance in x dimension
var dx = rocket._x - head._x;
// distance in y dimension
var dy = rocket._y - head._y;
var d = Math.sqrt((dx * dx) + (dy * dy));
// set touch threshold-- any separation less than this implies touch
var touchThreshold = head.radius + rocket.radius;
// check distance (separation) against threshold
if (d <= touchThreshold) {
// head hit! collision detected!
icegiant.gotoAndPlay("icedeath");
}
}
// associate collision check with onEnterFrame
_root.onEnterFrame = collisioncheck;
//limit the area that Guy Malone can fly
var radius = guymalone._width * .2;
//
function updateflyarea() {
// instructions
if (guymalone._x < radius) {
guymalone._x = radius;
}
else if (guymalone._x > Stage.width - radius) {
guymalone._x = Stage.width - radius;
}
if (guymalone._y < radius) {
guymalone._y = radius;
}
else if (guymalone._y > Stage.height - radius) {
guymalone._y = Stage.height - radius;
}
}
//
// associate guymalone with the enterFrame event
guymalone.onEnterFrame = updateflyarea;
// Flights of the snowballs
var startx = 215.8;
var starty = 86.7;
var endx = Math.random() * Stage.width;
var endy = Stage.height + 50;
var t = 0;
var count = 0;
var limit = 15;
// figure the snowball location
function ballerp(A, B, t) {
var totalDistance = B - A;
var completedDistance = totalDistance * t;
var currentPosition = A + completedDistance;
return currentPosition;
}
function updatesnowball() {
if (count < limit) {
t += .04;
if (t >= 1) {
t = 0;
endx = Math.random() * Stage.width;
count += 1;
}
snowball._y = ballerp(starty, endy, t);
snowball._x = ballerp(startx, endx, t);
snowball._yscale = ballerp(60,225,t);
snowball._xscale = ballerp(60,225,t);
}
}
// associate a function with the enterFrame event
snowball.onEnterFrame = updatesnowball;
//
// Guys flight controls
var dist = 15;
function updateguymalone() {
// called upon key event
// move Guy Malone based on key pressed
//
switch (Key.getCode()) {
case Key.UP :
guymalone._y -= dist;
break;
case Key.DOWN :
guymalone._y += dist;
break;
case Key.LEFT :
guymalone._x -= dist;
break;
case Key.RIGHT :
guymalone._x += dist;
break;
case Key.SPACE :
guymalone.gotoAndPlay(2);
}
}
//
//
// Control Rocket movement
var dist = 15;
function updaterocket() {
// called upon key event
// move rocket based on key pressed
//
switch (Key.getCode()) {
case Key.UP :
rocket._y -= dist;
break;
case Key.DOWN :
rocket._y += dist;
break;
case Key.LEFT :
rocket._x -= dist;
break;
case Key.RIGHT :
rocket._x += dist;
break;
case Key.SPACE :
rocket.gotoAndPlay("shoot");
}
}
//