home *** CD-ROM | disk | FTP | other *** search
- function initialize()
- {
- horse.attachMovie("h1","h1",1);
- horse.h1._x = 100;
- horse.h1._y = 250;
- horse.attachMovie("h2","h2",2);
- horse.h2._x = 200;
- horse.h2._y = 250;
- horse.attachMovie("downCount","downCount",100);
- horse.downCount._x = 300;
- horse.downCount._y = 150;
- horse.downCount.onEnterFrame = function()
- {
- if(this._currentframe == 60)
- {
- horse.h1.h.gotoAndStop(1);
- horse.h2.h.gotoAndStop(1);
- difficultySet();
- mie.start();
- startGame();
- this.onEnterFrame = null;
- this.removeMovieClip();
- }
- };
- }
- function difficultySet()
- {
- trace(difficulty);
- if(difficulty == 1)
- {
- l1 = 0.15;
- l2 = 0.4;
- l3 = 0.9;
- h2Speed = 0.02;
- rndJump = 0.5;
- }
- else if(difficulty == 2)
- {
- l1 = 0.25;
- l2 = 0.6;
- l3 = 0.9;
- h2Speed = 0.05;
- rndJump = 0.9;
- }
- else if(difficulty == 3)
- {
- l1 = 0.35;
- l2 = 0.7;
- l3 = 0.9;
- h2Speed = 0.07;
- rndJump = 1;
- }
- }
- function startGame()
- {
- bs.start(0,9999);
- var mouseListener = new Object();
- mouseListener.onMouseDown = function()
- {
- if(energy > 2 && allowScroll == true)
- {
- horse.h1.jumpTimes = horse.h1.jumpTimes + 1;
- if(horse.h1.jumpTimes <= 2)
- {
- horse.h1.gotoAndPlay("jump");
- horse.h1.dy = 10;
- horse.h1.onEnterFrame = function()
- {
- this.allowMoving = false;
- this._y -= this.dy;
- this.dy -= 0.8;
- if(this._y >= 250)
- {
- this.jumpTimes = 0;
- if(this.f == false)
- {
- this.allowMoving = true;
- this.gotoAndPlay("descend");
- }
- this._y = 250;
- this.onEnterFrame = null;
- }
- };
- }
- }
- };
- Mouse.addListener(mouseListener);
- horse.h1.gotoAndPlay("gallop");
- horse.h2.gotoAndPlay("gallop");
- horse.h1.jumpTimes = 0;
- horse.h1.allowMoving = true;
- horse.h2.allowMoving = true;
- horse.h2.allowJump = true;
- horse.h1.f = false;
- horse.h2.f = false;
- energy = 100;
- table_mc.flag._visible = false;
- ground.onEnterFrame = function()
- {
- if(allowScroll == true && energy > 2 && h1Distance < allDistance && h2Distance < allDistance)
- {
- if(this._x < -1180)
- {
- this._x = 0;
- }
- if(hill._x < -1200)
- {
- hill._x = 0;
- }
- if(horse.h1._x < 200)
- {
- ground._x -= 10;
- hill._x -= 3.333333;
- }
- else
- {
- ground._x -= horse.h1._x / 20;
- hill._x -= horse.h1._x / 60;
- }
- speed = Math.floor(horse.h1._x / Stage.width * 200);
- h1Distance += speed / 2000;
- }
- else
- {
- speed = 1;
- if(energy < 2)
- {
- for(var _loc2_ in za)
- {
- za[_loc2_].onEnterFrame = null;
- }
- trace("energy");
- Mouse.removeListener(mouseListener);
- horse.h1.gotoAndStop(1);
- horse.h2.gotoAndStop(1);
- showWinLose("energy");
- horse.h1.allowMoving = false;
- horse.h1.f = true;
- this.onEnterFrame = null;
- clearInterval(itl);
- clearInterval(energyItl);
- clearInterval(timeItl);
- }
- if(h1Distance >= allDistance)
- {
- for(_loc2_ in za)
- {
- za[_loc2_].onEnterFrame = null;
- }
- trace("win");
- Mouse.removeListener(mouseListener);
- horse.h1.gotoAndStop(1);
- horse.h2.gotoAndStop(1);
- showWinLose("win");
- horse.h1.allowMoving = false;
- table_mc.flag._visible = true;
- table_mc.flag._y = 6;
- horse.h1.f = true;
- this.onEnterFrame = null;
- clearInterval(itl);
- clearInterval(energyItl);
- clearInterval(timeItl);
- }
- if(h2Distance >= allDistance)
- {
- for(_loc2_ in za)
- {
- za[_loc2_].onEnterFrame = null;
- }
- trace("lose");
- Mouse.removeListener(mouseListener);
- horse.h1.gotoAndStop(1);
- horse.h2.gotoAndStop(1);
- showWinLose("lose");
- horse.h1.allowMoving = false;
- table_mc.flag._visible = true;
- table_mc.flag._y = 40;
- horse.h1.f = true;
- this.onEnterFrame = null;
- clearInterval(itl);
- clearInterval(energyItl);
- clearInterval(timeItl);
- }
- }
- if(horse.h1.allowMoving == true && horse.h1.f == false)
- {
- if(horse.h1._x < 600 - horse.h1._width)
- {
- horse.h1._x += (this._parent._xmouse - horse.h1._x) / 15;
- }
- else
- {
- horse.h1._x -= 3;
- }
- if(horse.h1._x > 500)
- {
- horse.h1._x = 500;
- }
- }
- h2AI();
- energy_mc.gotoAndStop(energy);
- speed_mc.gotoAndStop(speed);
- table_mc.h1.gotoAndStop(Math.floor(h1Distance));
- table_mc.h2.gotoAndStop(Math.floor(h2Distance));
- };
- itl = setInterval(addZa,800);
- energyItl = setInterval(decressEnergy,1000);
- timeItl = setInterval(timeFunc,1000);
- horse.h2.jump = h2Jump;
- }
- function addZa()
- {
- if(!cZa)
- {
- trace(oldza + "-" + newza);
- if(newza == 1)
- {
- w_2.gotoAndPlay(2);
- }
- if(newza == 2)
- {
- w_1.gotoAndPlay(2);
- }
- if(newza == 3)
- {
- w_3.gotoAndPlay(2);
- }
- newza = 0;
- }
- else if(allowScroll == true)
- {
- var _loc1_ = Math.random();
- if(_loc1_ < l1)
- {
- newza = 1;
- createZa(1);
- }
- else if(_loc1_ >= l1 && _loc1_ < l2)
- {
- newza = 2;
- createZa(2);
- }
- else if(_loc1_ >= l2 && _loc1_ < l3)
- {
- newza = 3;
- createZa(3);
- }
- }
- cZa = !cZa;
- }
- function createZa(num)
- {
- za.childNum = za.childNum + 1;
- var _loc2_ = "za" + za.childNum;
- za.attachMovie("za",_loc2_,za.getNextHighestDepth());
- za[_loc2_].gotoAndStop(num);
- za[_loc2_]._x = 1500;
- za[_loc2_]._y = 300;
- za[_loc2_].onEnterFrame = function()
- {
- if(allowScroll == true)
- {
- if(horse.h1._x < 200)
- {
- this._x -= 10;
- }
- else
- {
- this._x -= horse.h1._x / 20;
- }
- }
- if(this.hitTest(box))
- {
- this.removeMovieClip();
- }
- if(this.box.hitTest(horse.h1.box) && this.type == 1 && horse.h1.f == false)
- {
- clearInterval(bugItl);
- horse.h1.f = true;
- allowScroll = false;
- horse.h1.allowMoving = false;
- ground._x -= 7.5;
- hill._x -= 2.5;
- this._x -= 150;
- horse.h2._x -= 150;
- horse.h1.f = false;
- fall.start();
- horse.h1.gotoAndPlay("fall");
- bugItl = setInterval(bugFunc,1000);
- }
- if(this.box.hitTest(horse.h2.box) && horse.h2.allowJump == true && Math.random() < rndJump)
- {
- horse.h2.allowJump = false;
- horse.h2.jump();
- }
- if(this.box.hitTest(horse.h2.body) && horse.h2.f == false)
- {
- horse.h2.f = true;
- horse.h2.gotoAndPlay("fall");
- }
- if(this.food.hitTest(horse.h1.mouth))
- {
- if(this.food.type == 1)
- {
- if(energy < 95)
- {
- energy += 5;
- }
- eat.start();
- this.food.gotoAndPlay("remove1");
- }
- if(this.food.type == 2 || this.food.type == 3)
- {
- if(energy < 90)
- {
- energy += 10;
- }
- var _loc2_ = Math.random();
- if(_loc2_ < 0.5)
- {
- eat.start();
- this.food.gotoAndPlay("remove2");
- }
- else
- {
- eat.start();
- this.food.gotoAndPlay("remove3");
- }
- }
- if(this.food.type == 4)
- {
- horse.h1.w1.gotoAndPlay("fly");
- horse.h1.w2.gotoAndPlay("fly");
- sing.start();
- horse.h1.dy += 15;
- this.food.gotoAndStop(1);
- }
- }
- };
- }
- function decressEnergy()
- {
- if(energy > 1)
- {
- energy -= 2;
- }
- }
- function h2AI()
- {
- horse.h2._x = horse.h1._x - (h1Distance - h2Distance) * 200;
- h2Distance += h2Speed;
- }
- function h2Jump()
- {
- this.dy = 15;
- this.gotoAndPlay("jump");
- this.onEnterFrame = function()
- {
- this._y -= this.dy;
- this.dy -= 0.9;
- if(this._y > 250)
- {
- if(this.f == false)
- {
- this.gotoAndPlay("descend");
- }
- this._y = 250;
- this.allowJump = true;
- this.f = false;
- this.onEnterFrame = null;
- }
- };
- }
- function timeFunc()
- {
- time++;
- time_txt.text = time + "s";
- time2_txt.text = time + "s";
- if(time < 60)
- {
- sunColorTrans.blueOffset += 3.3;
- sunColorTrans.redOffset -= 1.6;
- sunColorTrans.greenOffset -= 3;
- sunColorTrans.alphaOffset += 0.83;
- sunTrans.colorTransform = sunColorTrans;
- }
- if(time > 10 && backColorTrans.redOffset < 180)
- {
- backColorTrans.redOffset = (time - 10) * 3;
- backColorTrans.greenOffset = -1 * time;
- backTrans.colorTransform = backColorTrans;
- hillColorTrans.redMultiplier = 1 - 0.0121428 * time;
- hillColorTrans.greenMultiplier = 1 - 0.0121428 * time;
- hillColorTrans.blueMultiplier = 1 - 0.0121428 * time;
- hillTrans.colorTransform = hillColorTrans;
- groundColorTrans.redMultiplier = 1 - 0.0057142 * time;
- groundColorTrans.greenMultiplier = 1 - 0.0057142 * time;
- groundColorTrans.blueMultiplier = 1 - 0.0057142 * time;
- groundTrans.colorTransform = groundColorTrans;
- }
- if(sun._currentframe != 100 && Math.random() < 0.7)
- {
- sun.nextFrame();
- }
- }
- function showWinLose(str)
- {
- winLose.swapDepths(999999);
- winLose.gotoAndStop(2);
- if(time - baseTime > 0)
- {
- winLose.flag = 1;
- }
- else
- {
- winLose.flag = -1;
- }
- winLose.onEnterFrame = function()
- {
- if(str == "win")
- {
- this.score_txt.text = this.score2_txt.text = 65 + (baseTime - time) * scoreVar;
- }
- if(str == "lose")
- {
- this.score_txt.text = this.score2_txt.text = 30 + (baseTime - time) * scoreVar;
- }
- if(str == "energy")
- {
- this.score_txt.text = this.score2_txt.text = 8 + Math.floor(h1Distance * scoreVar * 0.3);
- }
- winLose.time2_txt.text = time;
- };
- }
- function bugFunc()
- {
- if(allowScroll == false)
- {
- trace(bug);
- horse.h1.allowMoving = true;
- horse.h1.f = false;
- allowScroll = true;
- clearInterval(bugItl);
- }
- }
- stop();
- var backColorTrans = new flash.geom.ColorTransform();
- var backTrans = new flash.geom.Transform(back);
- backTrans.colorTransform = backColorTrans;
- var hillColorTrans = new flash.geom.ColorTransform();
- var hillTrans = new flash.geom.Transform(hill);
- hillTrans.colorTransform = hillColorTrans;
- var groundColorTrans = new flash.geom.ColorTransform();
- var groundTrans = new flash.geom.Transform(ground);
- groundTrans.colorTransform = groundColorTrans;
- var sunColorTrans = new flash.geom.ColorTransform();
- var sunTrans = new flash.geom.Transform(sun);
- sunColorTrans.blueOffset -= 200;
- sunColorTrans.redOffset += 100;
- sunColorTrans.greenOffset += 180;
- sunColorTrans.alphaOffset -= 50;
- sunTrans.colorTransform = sunColorTrans;
- var horse = this.createEmptyMovieClip("horse",3);
- var za = this.createEmptyMovieClip("za",1);
- winLose.swapDepths(2);
- za.childNum = 0;
- var oldza = 0;
- var newza = 0;
- var cZa = false;
- var itl;
- var energyItl;
- var timeItl;
- var time = 0;
- var allowScroll = true;
- var speed = 0;
- var energy = 0;
- var h1Distance = 0;
- var allDistance = 100;
- var h2Distance = 0.5;
- var h2Speed;
- var l1;
- var l2;
- var l3;
- var rndJump;
- var baseTime = 80;
- var baseScore = 500;
- var scoreVar = 1;
- var bugItl;
- var sing = new Sound();
- sing.attachSound("sing");
- var mie = new Sound();
- mie.attachSound("mie");
- var eat = new Sound();
- eat.attachSound("eat");
- var fall = new Sound();
- fall.attachSound("fall");
- var bs = new Sound();
- bs.attachSound("bs");
- initialize();
-