Frame 2
new Flappy(this);
Symbol 67 MovieClip [__Packages.library.State] Frame 0
class library.State
{
var mcRef, sState;
function State (_mcRef, _sState) {
mcRef = _mcRef;
setState(_sState);
}
function setState(_sState) {
if (sState != _sState) {
sState = _sState;
mcRef.gotoAndStop(_sState);
this["start" + _sState]();
}
}
function update() {
this["do" + sState]();
}
function get getState() {
return(sState);
}
function isStateComplete() {
return(mcRef.mcState._currentframe == mcRef.mcState._totalframes);
}
function get Mc() {
return(mcRef);
}
}
Symbol 68 MovieClip [__Packages.Flappy] Frame 0
class Flappy extends library.State
{
var update, mcRef, aBackground, aGround, aPipe, aSquirt, nHighScore, nPoint, nTimeSpawn, setState, bButtonDown, nSpeedY, nTimeScore, nNextSpawn;
function Flappy (_mcRef) {
super(_mcRef, "");
_mcRef.stop();
mcRef.onEnterFrame = library.Delegate.create(this, update);
aBackground = new Array();
aGround = new Array();
aPipe = new Array();
aSquirt = new Array();
nHighScore = 0;
nPoint = 0;
nTimeSpawn = 0;
setState(sSTATE_TITLE);
}
function startTitle() {
mcRef.mcPlayer._y = 300;
mcRef.mcPlayer.gotoAndPlay(1);
mcRef.mcPopupStart._visible = true;
mcRef.mcPopupLose._visible = false;
var _local2;
while (aBackground.length > 0) {
aBackground[0].removeMovieClip();
aGround[0].removeMovieClip();
aBackground.shift();
aGround.shift();
}
while (aPipe.length > 0) {
aPipe[0].removeMovieClip();
aPipe.shift();
}
while (aSquirt.length > 0) {
aSquirt[0].removeMovieClip();
aSquirt.shift();
}
_local2 = 0;
while (_local2 < 3) {
aBackground.push(mcRef.mcBackground.attachMovie("mcBackground", "mcBackground" + mcRef.mcBackground.getNextHighestDepth(), mcRef.mcBackground.getNextHighestDepth()));
aGround.push(mcRef.mcGround.attachMovie("mcGround", "mcGround" + mcRef.mcGround.getNextHighestDepth(), mcRef.mcGround.getNextHighestDepth()));
aBackground[_local2]._x = 600 * _local2;
aBackground[_local2]._y = 0;
aGround[_local2]._x = 600 * _local2;
aGround[_local2]._y = 0;
_local2++;
}
}
function doTitle() {
movebackground();
if (Key.isDown(38)) {
if (!bButtonDown) {
bButtonDown = true;
setState(sSTATE_PLAY);
}
} else {
bButtonDown = false;
}
}
function startPlay() {
mcRef.mcPopupStart._visible = false;
mcRef.mcPopupLose._visible = false;
nPoint = 0;
mcRef.txPoints.text = "0";
bButtonDown = true;
nSpeedY = -nSWITCH_FALL;
nTimeScore = 0;
nTimeSpawn = nTIME_TO_SPAWN;
nNextSpawn = nTIME_TO_SPAWN;
}
function doPlay() {
if (Key.isDown(38)) {
if (!bButtonDown) {
bButtonDown = true;
playerUp();
}
} else {
bButtonDown = false;
}
playerFall();
squirtFall();
tryCollide();
movebackground();
spawnPipe();
}
function doFalling() {
playerFall();
squirtFall();
if (mcRef.mcPlayer._y >= ((600 - (mcRef.mcPlayer._height / 2)) - aGround[0]._height)) {
mcRef.mcPlayer._y = (600 - (mcRef.mcPlayer._height / 2)) - aGround[0]._height;
setState(sSTATE_LOST);
}
}
function startLost() {
nTimeSpawn = 7;
mcRef.mcPlayer.gotoAndStop(6);
mcRef.mcPopupStart._visible = false;
mcRef.mcPopupLose._visible = true;
}
function doLost() {
nTimeSpawn--;
squirtFall();
if (Key.isDown(38) && (nTimeSpawn <= 0)) {
if (!bButtonDown) {
bButtonDown = true;
setState(sSTATE_TITLE);
}
} else {
bButtonDown = false;
}
}
function playerUp() {
mcRef.mcPlayer.gotoAndPlay(1);
mcRef.mcPlayer.mcCock.play();
nSpeedY = nRAISE;
aSquirt.push(mcRef.mcPipes.attachMovie("mcSquirt", "mcSquirt" + mcRef.mcPipes.getNextHighestDepth(), mcRef.mcPipes.getNextHighestDepth()));
aSquirt[aSquirt.length - 1]._x = mcRef.mcPlayer._x;
aSquirt[aSquirt.length - 1]._y = mcRef.mcPlayer._y + aSquirt[aSquirt.length - 1]._height;
aSquirt[aSquirt.length - 1].gotoAndStop(1);
}
function playerFall() {
mcRef.mcPlayer._y = mcRef.mcPlayer._y - nSpeedY;
mcRef.mcPlayer._y = Math.max(0, mcRef.mcPlayer._y);
if (nSpeedY > 0) {
nSpeedY = nSpeedY * nGRAVITY_RAISE;
if (nSpeedY < nSWITCH_FALL) {
nSpeedY = -nSWITCH_FALL;
}
} else {
nSpeedY = nSpeedY / nGRAVITY_FALL;
nSpeedY = Math.max(nSpeedY, nFALL);
}
}
function tryCollide() {
if (mcRef.mcPlayer._y >= ((600 - (mcRef.mcPlayer._height / 2)) - aGround[0]._height)) {
mcRef.mcPlayer._y = (600 - (mcRef.mcPlayer._height / 2)) - aGround[0]._height;
setState(sSTATE_LOST);
}
nTimeScore--;
var _local2;
_local2 = 0;
while (_local2 < aPipe.length) {
if (mcRef.mcPlayer.hitTest(aPipe[_local2]) && (!(((mcRef.mcPlayer._y - 25) > (aPipe[_local2]._y - 90)) && ((mcRef.mcPlayer._y + 25) < (aPipe[_local2]._y + 90))))) {
if ((mcRef.mcPlayer._y - 25) < (aPipe[_local2]._y - 90)) {
mcRef.mcPlayer._y = aPipe[_local2]._y - 75;
nSpeedY = -nSWITCH_FALL;
}
setState(sSTATE_FALLING);
} else if (nTimeScore <= 0) {
if ((mcRef.mcPlayer._x > aPipe[_local2]._x) && (mcRef.mcPlayer._x < (aPipe[_local2]._x + 60))) {
nTimeScore = 30;
nPoint = nPoint + 1;
mcRef.txPoints.text = nPoint;
if (nHighScore < nPoint) {
nHighScore = nPoint;
mcRef.txtHighScore.text = nHighScore;
}
}
}
_local2++;
}
}
function movebackground() {
var _local2;
_local2 = 0;
while (_local2 < aBackground.length) {
aBackground[_local2]._x = aBackground[_local2]._x - nSPEED_BACK;
if (aBackground[_local2]._x < -600) {
aBackground[_local2]._x = aBackground[_local2]._x + 1200;
}
_local2++;
}
_local2 = 0;
while (_local2 < aGround.length) {
aGround[_local2]._x = aGround[_local2]._x - nSPEED_FRONT;
if (aGround[_local2]._x < -600) {
aGround[_local2]._x = aGround[_local2]._x + 1200;
}
_local2++;
}
_local2 = 0;
while (_local2 < aPipe.length) {
aPipe[_local2]._x = aPipe[_local2]._x - nSPEED_FRONT;
if (aPipe[_local2]._x < -600) {
aPipe[_local2].removeMovieClip();
aPipe.splice(_local2, 1);
_local2--;
} else {
setEye(aPipe[_local2].mcLeftEye);
setEye(aPipe[_local2].mcRightEye);
}
_local2++;
}
var _local4;
var _local3;
_local2 = 0;
while (_local2 < aSquirt.length) {
aSquirt[_local2]._x = aSquirt[_local2]._x - nSPEED_FRONT;
if (aSquirt[_local2]._x < -600) {
aSquirt[_local2].removeMovieClip();
aSquirt.splice(_local2, 1);
_local2--;
}
_local2++;
}
}
function squirtFall() {
var _local4;
var _local2;
var _local3;
_local2 = 0;
while (_local2 < aSquirt.length) {
_local4 = false;
aSquirt[_local2]._y = aSquirt[_local2]._y + nSPEED_SQUIRT;
_local3 = 0;
while (_local3 < aPipe.length) {
if ((aSquirt[_local2]._x > (aPipe[_local3]._x - 60)) && (aSquirt[_local2]._x < (aPipe[_local3]._x + 60))) {
_local4 = true;
aSquirt[_local2]._y = Math.min(aSquirt[_local2]._y, aPipe[_local3]._y + 90);
if (aSquirt[_local2]._y >= (aPipe[_local3]._y + 89.9)) {
aSquirt[_local2].gotoAndStop(2);
}
}
_local3++;
}
if (!_local4) {
aSquirt[_local2]._y = Math.min(aSquirt[_local2]._y, 550);
if (aSquirt[_local2]._y >= 550) {
aSquirt[_local2].gotoAndStop(2);
}
}
_local2++;
}
}
function spawnPipe() {
nTimeSpawn--;
if (nTimeSpawn <= 0) {
nTimeSpawn = Math.ceil(nNextSpawn);
nNextSpawn = nNextSpawn - 0.4;
nNextSpawn = Math.max(nNextSpawn, 35);
aPipe.push(mcRef.mcPipes.attachMovie("mcPipes", "mcPipes" + mcRef.mcPipes.getNextHighestDepth(), mcRef.mcPipes.getNextHighestDepth()));
aPipe[aPipe.length - 1]._x = 700;
aPipe[aPipe.length - 1]._y = (Math.random() * 240) + 200;
aPipe[aPipe.length - 1].gotoAndStop(Math.ceil(Math.random() * 2));
}
}
function setEye(_mcEye) {
var _local3 = angleDirection(_mcEye._x + _mcEye._parent._x, _mcEye._y + _mcEye._parent._y, mcRef.mcPlayer._x, mcRef.mcPlayer._y);
_mcEye.gotoAndStop(Math.floor(_local3 / 3));
}
function angleDirection(x1, y1, x2, y2) {
var _local8 = Math.abs(x2 - x1);
var _local7 = lineSize(x1, y1, x2, y2);
var _local2 = Math.asin(_local8 / _local7) * 57.2957795130823;
if ((x2 >= x1) && (y2 >= y1)) {
_local2 = 90 + (90 - _local2);
} else if ((x2 <= x1) && (y2 >= y1)) {
_local2 = _local2 + 180;
} else if ((x2 <= x1) && (y2 <= y1)) {
_local2 = 270 + (90 - _local2);
}
return(_local2);
}
function lineSize(x1, y1, x2, y2) {
var _local2 = Math.abs(x2 - x1);
var _local1 = Math.abs(y2 - y1);
return(Math.sqrt(Math.pow(_local2, 2) + Math.pow(_local1, 2)));
}
var nGRAVITY_RAISE = 0.6;
var nGRAVITY_FALL = 0.5;
var nSWITCH_FALL = 2.5;
var nRAISE = 39;
var nFALL = -10;
var nSPEED_BACK = 3;
var nSPEED_FRONT = 7;
var nSPEED_SQUIRT = 21;
var nTIME_TO_SPAWN = 75;
var sSTATE_TITLE = "Title";
var sSTATE_PLAY = "Play";
var sSTATE_FALLING = "Falling";
var sSTATE_LOST = "Lost";
}
Symbol 69 MovieClip [__Packages.library.Delegate] Frame 0
class library.Delegate extends Object
{
var func;
function Delegate (f) {
super();
func = f;
}
static function create(obj, func) {
var _local2 = function () {
var _local3 = arguments.callee.target;
var _local4 = arguments.callee.func;
var _local2 = arguments.callee.arg;
_local2 = _local2.concat(arguments);
return(_local4.apply(_local3, _local2));
};
_local2.target = obj;
_local2.func = func;
_local2.arg = arguments.slice(2);
return(_local2);
}
function createDelegate(obj) {
return(create(obj, func));
}
}
Symbol 35 MovieClip Frame 1
stop();
Symbol 35 MovieClip Frame 7
gotoAndStop (1);
Symbol 52 MovieClip Frame 1
stop();
Symbol 61 MovieClip Frame 1
stop();
Instance of Symbol 52 MovieClip in Symbol 62 MovieClip Frame 1
on (press) {
getURL ("http://www.furaffinity.net/user/bahamutdragons/", "_blank");
}
on (rollOver) {
this.gotoAndStop(2);
}
on (rollOut) {
this.gotoAndStop(1);
}
Instance of Symbol 61 MovieClip in Symbol 62 MovieClip Frame 1
on (press) {
getURL ("http://www.furaffinity.net/user/brubearbrown/", "_blank");
}
on (rollOver) {
this.gotoAndStop(2);
}
on (rollOut) {
this.gotoAndStop(1);
}