Wednesday 18 February 2009

Stolen Code (from Tiki Racer)

Some code for gravity, taken from 'Tiki Racer'. Should come in useful. Keep in mind that it's action script 2.

function lastFrame(){

if(this.voodoomask_mc._currentframe == 6){
voodoogod_mc.onEnterFrame = null;
this.voodoomask_mc.armspear_mc.spear_mc._alpha = 0;



var myPoint2:Object = new Object();
myPoint2.x = voodoogod_mc.voodoomask_mc.spearpoint_mc._x;
myPoint2.y = voodoogod_mc.voodoomask_mc.spearpoint_mc._y;


_root.voodoogod_mc.voodoomask_mc.localToGlobal(myPoint2);

vgravity =0.4;
vb =0.03;
vdx = 9;
vdy = -4;
makeSpear(myPoint2.x,myPoint2.y);
}
}

function makeSpear(thex,they){
theClip = _root.attachMovie("spear2","spear2_mc",voodoodepth+1);
theClip._x=thex;
theClip._y=they;
theClip.onEnterFrame=spearMove;
retreatId = setInterval(retreat,1000);
}

function spearMove(){
vdy += vgravity;
this._x += vdx;
this._y += vdy;
this._rotation +=4;
if(this.speartip_mc.hitTest(car_mc.target_mc)){
soundMachine1.attachSound("Coreyjerrhelm Scream2.mp3");
soundMachine1.start();
this.onEnterFrame = null;
this.removeMovieClip();
health_mc.gotoAndStop(health_mc._currentframe + arrowdamage);
}


if(this._y > 430){
this.onEnterFrame = null;
this.removeMovieClip();
}
}

function retreat(){
clearInterval(retreatId);
voodoogod_mc.onEnterFrame = voodooRetreat;
}

function voodooRetreat(){
this._x -= 5;
if (this._x < -80){
this.removeMovieClip();
voodooId = setInterval(createVoodoo,voodoofreq);
}
}


And also:

function lobCoconut(){
var myPoint:Object = new Object();
myPoint.x = ropeswing_mc.monkey_mc.sArm_mc.coconut_mc._x;
myPoint.y = ropeswing_mc.monkey_mc.sArm_mc.coconut_mc._y
/*trace("x: "+ myPoint.x);
trace("y: "+ myPoint.y);*/

_root.ropeswing_mc.monkey_mc.sArm_mc.localToGlobal(myPoint);


/*trace("after x: "+ myPoint.x);
trace("after y: "+ myPoint.y);*/
gravity =0.4;
b =0.05;
dx = -2;
dy = -0.02;
makeCoconut(myPoint.x,myPoint.y);

}



function coconutMove(){
dy += gravity;
this._x += dx;
this._y += dy;
if(this.hitTest(car_mc.target_mc)){
soundMachine1.attachSound("monkey1.mp3");
soundMachine1.start();
theClip = _root.attachMovie("coconutcrack","coconutcrack"+coconutDepth,coconutDepth+1);
theClip._x = this._x;
theClip._y = this._y;
gravity3 =0.9;
b3 =0.05;
dx3 = -2;
dy3 = -9;
theClip.onEnterFrame = crackMove;
this.onEnterFrame = null;
this.removeMovieClip();
health_mc.gotoAndStop(health_mc._currentframe + cocodamage);
}
}

No comments:

Post a Comment