Designed and built interactive video game.
Screen Capture
Play The Game Here
Requires Adobe Flash Player. Install or enable Flash to play the game http://www.adobe.com/go/getflash/
How to enable Flash Player in Chrome
Actionscript Code Sample
/***************import classes***************/
import mx.transitions.easing.*;
import mx.transitions.*;
/*********declare variables and instances*******/
var mcGunBarrel:MovieClip;
var bossHealth:MovieClip;
var nStageWidth:Number = Stage.width;
var nStageHeight:Number = Stage.height;
var nStageWidthTenth:Number = Stage.width/10;
var btnCrossHair:Button;
var nBulletStartY:Number = 550;
var nBulletStartX:Number = 300;
var bulletCount:Number = 1;
var bulletName:String;
var enemyCount:Number = 1;
var enemyName:String;
var sWindSound:Sound = new Sound();
var sGunSound:Sound = new Sound();
var nEnemySpeed:Number = 5;
var nEnemyFlySpeed:Number = 3;
var nHealth:Number = 156;
var nEnemyHitCount = 0;
var sEnemyType:String;
var nMouseXFromMiddle:Number;
var nMouseYFromMiddle:Number;
var nRandomEnemy:Number;
var nWave:Number;
var nBossSwitch:Boolean = true;
var mcEnemyOn:Boolean = false;
var mcEnemy2On:Boolean = false;
var mcEnemy3On:Boolean = false;
var mcEnemy4On:Boolean = false;
var mcEnemy5On:Boolean = false;
var mcEnemy6On:Boolean = false;
var nBossHealth:Number = 100;
var nHitCountAmountForBoss = 150;
var healthLowSoundOn:Boolean = false;
/****************create objects**************/
var oBullet:Object = new Object();
var oEnemy:Object = new Object();
var oEnemyFly:Object = new Object();
var enemyObject:Object;
var keyListner:Object = new Object();
/****************handle events**************/
keyListner.onKeyDown = function() {
if (Key.getCode() == Key.RIGHT) {
}
if (Key.getCode() == Key.LEFT) {
}
if (Key.getCode() == Key.UP) {
}
if (Key.getCode() == Key.DOWN) {
}
if (Key.getCode() == Key.SPACE) {
if (_root.mcShield._currentframe == _root.mcShield._totalframes) {
_root.mcShield.gotoAndPlay("on");
}
if (_root.mcShield._currentframe == 10) {
_root.mcShield.gotoAndPlay("off");
}
}
};
oBullet.onEnterFrame = function() {
// ----------- BULLET MOVE ---------- \\
if (this._y == nBulletStartY) {
var flyX:Tween = new Tween(this, "_x", Strong.easeOut, nBulletStartX, _root.btnCrossHair._x, .5, true);
var flyX:Tween = new Tween(this, "_y", Strong.easeOut, nBulletStartY, _root.btnCrossHair._y, .5, true);
// Add shoot sound
}
this._yscale = this._y/3;
this._xscale = this._y/3;
// ----------- HITTEST ENEMY ---------- \\
for (var i:Number = 1; i<=enemyCount; i++) {
//check if enemy already dead
// check it bullet hits target
if (this.hitTest(this._parent["mcEnemy"+i])) {
nEnemyHitCount++;
if (nEnemyHitCount == 100) {
displayMessage("USE SPACEBAR TO ACTIVATE SHIELDS");
}
if (nEnemyHitCount == nHitCountAmountForBoss) {
sWindSound.stop();
sWindSound.attachSound("hunterSeeker");
sWindSound.start(1, 999);
}
_root.tbEnemyHitCount.text = nEnemyHitCount;
this._parent["mcEnemy"+i].nextFrame();
removeMovieClip(this);
}
}
// ----------- HITTEST BOSS ---------- \\
if (this.hitTest(_root.main.mcBoss.mcBossF1.mcBossWalk.mcBossTarget)) {
nBossHealth--;
sBossHit.start();
if (nBossHealth<=0) {
displayMessage("STAGE CLEAR");
_root.gotoFinish.play();
sHeartBeat.stop();
sWindSound.stop();
}
_root.bossHealth._xscale = nBossHealth;
if (nBossHealth<=0) { _root.main.mcBoss.mcBossF1.stop(); _root.main.mcBoss.mcBossF1.mcBossWalk.gotoAndPlay("die"); } } }; // ----------- WALKING ENEMY BEHAVIOR ---------- \\ oEnemy.onEnterFrame = function() { this._y = this._y+nEnemySpeed; // size enemy to y location this._xscale = this._y/3; this._yscale = this._y/3; // remove enemy at end of screen if (this._y>=Stage.height+30) {
removeMovieClip(this);
}
// reduce health when enemy reaches 400
if (_root.mcShield._currentframe == 10) {
} else {
if (this._y>=500) {
reduceHealth(1);
}
}
};
// ----------- FLYINH ENEMY BEHAVIOR ---------- \\
oEnemyFly.onEnterFrame = function() {
this._y = this._y-nEnemyFlySpeed;
// size enemy to y location
this._xscale = 300-this._y;
this._yscale = 300-this._y;
// remove enemy at end of screen
if (this._y<=-100) { removeMovieClip(this); } // reduce health when enemy reaches 400 if (this._y>=500) {
reduceHealth(1);
}
};
/******************functions****************/
function die() {
//stopAllSounds();
sHeartBeat.stop();
sWindSound.stop();
trace(nEnemyHitCount/bulletCount*100);
_root.tbAccuracy.text = String(nEnemyHitCount/bulletCount*100);
_root.gotoAndStop("gameover");
}
function reduceHealth(healthAmount) {
// ----------- HEALTH MINUS HEALTH AMOUNT ---------- \\
reduceHealthSound.start();
if (healthLowSoundOn == false) {
if (nHealth<=30) { sHeartBeat.start(0, 999); _root.mcHealthHolder.mcHealthBar.blink(true); healthLowSoundOn = true; } } nHealth = nHealth-healthAmount; _root.tbHealth.text = nHealth; if (_root.mcHealthHolder.mcHealthBar._rotation>=-156) {
_root.mcHealthHolder.mcHealthBar._rotation = _root.mcHealthHolder.mcHealthBar._rotation-healthAmount;
}
// ---------- GOTO DEATH ANIMATION --------- \\
if (nHealth<=0) { die(); } } function displayMessage(sMessage) { _root.mcWave.tbWave.text = String(sMessage); _root.mcWave.blink(true); _root.mcWave._visible = true; messageInterval = setInterval(messageVisible, 3000); } function messageVisible() { // add warning sound _root.mcWave.blink(false); _root.mcWave._visible = false; clearInterval(messageInterval); } function enemy() { // ----------- ADD RANDOM BADDY ---------- \\ nRandomEnemy = Math.random()*1000; //nWave = 1; //if (nWave == 1) { if (nRandomEnemy>=900) {
if (mcEnemy5On == true) {
sEnemyType = "mcEnemy5";
}
}
if (nRandomEnemy>=800 and nRandomEnemy<=900) { if (mcEnemy4On == true) { sEnemyType = "mcEnemy4"; } } if (nRandomEnemy>=500 and nRandomEnemy<=800) { sEnemyType = "mcEnemy3"; } if (nRandomEnemy>=0 and nRandomEnemy<=500) {
if (nRandomEnemy<300) {
sEnemyType = "mcEnemy";
} else {
if (mcEnemy6On == true) {
sEnemyType = "mcEnemy6";
}
}
}
if (sEnemyType == "mcEnemy6") {
enemyObject = oEnemyFly;
} else {
enemyObject = oEnemy;
}
enemyName = "mcEnemy"+String(enemyCount);
enemyDepth = this.getNextHighestDepth();
this.attachMovie(sEnemyType, enemyName, enemyDepth, enemyObject);
this[enemyName]._x = Math.random()*930-30;
this[enemyName]._y = Math.random()*50+150;
enemyCount++;
}
function startGame() {
displayMessage("GET READY");
startDrag(_parent.btnCrossHair, true);
Mouse.hide();
sWindSound.start(1, 999);
sGunSound.attachSound("sLaser");
_root.tbHealth.text = nHealth;
//----------- CREATE ENEMIES SWITCH ON AND OFF ----------------\\
createEnemy = setInterval(this, "enemy", 2000);
}
function shoot() {
// IF SHILD OFF THEN SHOOT
if (this._parent.mcShield._currentframe == 10) {
} else {
sGunSound.start();
bulletName = "mcBullet"+String(bulletCount);
bulletDepth = this.getNextHighestDepth();
this.attachMovie("mcBullet", bulletName, bulletDepth, oBullet);
this[bulletName]._x = nBulletStartX;
this[bulletName]._y = nBulletStartY;
bulletCount++;
}
}
/****************set properties**************/
Key.addListener(keyListner);
_root.bossHealth._visible = false;
// SOUND
sWindSound.attachSound("notAfraid");
var reduceHealthSound:Sound = new Sound();
reduceHealthSound.attachSound("stab");
var sHeartBeat:Sound = new Sound();
sHeartBeat.attachSound("heartBeat");
var sBossHit:Sound = new Sound();
sBossHit.attachSound("bossHit");
_root.mcHealthHolder.mcHealthBar.blink(false);
/******************run now*****************/
startGame();
_root.btnCrossHair.onRelease = function() {
shoot();
};
this._parent.mcGunBarrel.onEnterFrame = function() {
var nMouseX:Number = _parent.btnCrossHair._x;
if (nMouseX<=nStageWidthTenth && nMouseX>=0) {
this.gotoAndStop(1);
}
if (nMouseX<=nStageWidthTenth*2 && nMouseX>=nStageWidthTenth) {
this.gotoAndStop(2);
}
if (nMouseX<=nStageWidthTenth*3 && nMouseX>=nStageWidthTenth*2) {
this.gotoAndStop(3);
}
if (nMouseX<=nStageWidthTenth*4 && nMouseX>=nStageWidthTenth*3) {
this.gotoAndStop(4);
}
if (nMouseX<=nStageWidthTenth*5 && nMouseX>=nStageWidthTenth*4) {
this.gotoAndStop(5);
}
if (nMouseX<=nStageWidthTenth*6 && nMouseX>=nStageWidthTenth*5) {
this.gotoAndStop(6);
}
if (nMouseX<=nStageWidthTenth*7 && nMouseX>=nStageWidthTenth*6) {
this.gotoAndStop(7);
}
if (nMouseX<=nStageWidthTenth*8 && nMouseX>=nStageWidthTenth*7) {
this.gotoAndStop(8);
}
if (nMouseX<=nStageWidthTenth*9 && nMouseX>=nStageWidthTenth*8) {
this.gotoAndStop(9);
}
if (nMouseX<=nStageWidthTenth*10 && nMouseX>=nStageWidthTenth*9) {
this.gotoAndStop(10);
}
};
this.onEnterFrame = function() {
//----------- MAIN MOVEMENT----------------\\
nMouseXFromMiddle = nStageWidth/2-this._xmouse;
nMouseYFromMiddle = nStageHeight/2-this._ymouse;
// - 400 to -1000
if (this.main._x<=-1400 && this.main._x>=0) {
var flyX:Tween = new Tween(_root.main, "_x", Strong.easeOut, _root.main._x, nMouseXFromMiddle/3.5, 1, true);
}
if (this.main._y<=-90 && this.main._y>=-20) {
var flyY:Tween = new Tween(_root.main, "_y", Strong.easeOut, _root.main._y, nMouseYFromMiddle/5, 1, true);
}
// ---------- TARGET TRAIL MOVEMENT --------- \\
var targetX = _root.mcHelmit.mcTargetCircle;
var targetY = _root.mcHelmit.mcTargetCircle;
var targetFlyX:Tween = new Tween(targetX, "_x", Strong.easeOut, targetX._x, -nMouseXFromMiddle, 1, true);
var targetFlyY:Tween = new Tween(targetY, "_y", Strong.easeOut, targetY._y, -nMouseYFromMiddle, 1, true);
// ----------- Change Wave ---------- \\
if (nEnemyHitCount<=50) {
// ----------- SWITCH BOSS ON AND REMOVE ENEMY CREATION ---------- \\
}
if (nEnemyHitCount<=100 and nEnemyHitCount>50) {
mcEnemy4On = true;
mcEnemy5On = true;
mcEnemy6On = true;
}
if (nEnemyHitCount == nHitCountAmountForBoss) {
clearInterval(createEnemy);
if (nBossSwitch == true) {
_root.bossHealth._visible = true;
_root.main.mcBoss.mcBossF1.gotoAndPlay(2);
nBossSwitch = false;
}
}
};
