Code I might end up re-using for the competition
I am not a real programmer. I am still on the level of hacking around in AS2 and AS3 and writing code onto the timeline. I have written some functions for scrolling platformers which I tend to re-use… I guess you could call it my own 2D platformer engine in AS2. Anyhow, embarassing as it is I have pasted the parts I might re-use via cut-and-paste below in case I end up making a scrolling/platformer game. It’s all actionscript2.
Note I have moved on to using AS3 and am making some games intended for platforms outside the web browser. But for the purposes of this contest I will build a rapid prototype in AS2. The code below is an atrocity but it’s the result of what’s only been my hobby for years, and my strength is more in combining animation skills with cheap timeline tricks. So while from a programming standpoint things are a mess I can make some fun stuff nontheless.
//SCROLLING
function ScrollPlayField() {
_root.AI.rightwall = _root.AI.rightwall+_root.scrollspeed;
_root.AI.leftwall = _root.AI.leftwall+_root.scrollspeed;
//FOREGROUND PLANES
setProperty(“_root.fg1a”, _x, _root.fg1a._x+_root.scrollspeed*1.25);
}
function SetScroll(sprite) {
//UPDATE SCROLL SPEED TO HERO’S SPEED
//IF THE HERO HAS LATERAL CONTROL
//AND IS PRESSING LEFT OR RIGHT
//SCROLL LEFT OR RIGHT ACCORDINGLY
if (sprite.lateral==”active”) {
if (Key.isDown(Key.LEFT)) {
if (sprite.MoveXpos > _root.world_MinX) {
_root.scrolldirection = “LEFT”;
_root.scrollspeed = sprite.Walk_Speed;
sprite.MoveXpos = sprite.MoveXpos-_root.scrollspeed;
sprite.MovedMetres = sprite.MoveXpos/72
ScrollPlayField();
}
} else if (Key.isDown(Key.RIGHT)) {
if (sprite.MoveXpos < _root.world_MaxX) {
_root.scrolldirection = “RIGHT”
_root.scrollspeed = -sprite.Walk_Speed;
sprite.MoveXpos = sprite.MoveXpos-_root.scrollspeed;
sprite.MovedMetres = sprite.MoveXpos/72
ScrollPlayField();
}
}
}
}
//LOOPING
function LoopMe(Me) {
if (Me._x < Me.LoopLeft) {
setProperty(Me, _x, Me.LoopRight);
} else if (Me._x > Me.LoopRight) {
setProperty(Me, _x, Me.LoopLeft);
}
}
//VERTICAL SCROLLING
function VertPlayField() {
//FOREGROUND PLANES
_root.hero.Ground_Level = 3000;
//I THINK GROUND LEVEL IS NO LONGER IMPORTANT? I HAVE LOST TRACK OF MY OWN GAME ENGINE. LOL.
_root.AI.Ground_Level = _root.AI.Ground_Level+_root.Vscrollspeed;
setProperty(“_root.fg1a”, _y, _root.fg1a._y+(_root.Vscrollspeed*1.25));
setProperty(“_root.fg1b”, _y, _root.fg1b._y+(_root.Vscrollspeed*1.25));
setProperty(“_root.fg1c”, _y, _root.fg1c._y+(_root.Vscrollspeed*1.25));
setProperty(“_root.fg2a”, _y, _root.fg2a._y+(_root.Vscrollspeed*1.2));
setProperty(“_root.fg2b”, _y, _root.fg2b._y+(_root.Vscrollspeed*1.2));
setProperty(“_root.fg2c”, _y, _root.fg2c._y+(_root.Vscrollspeed*1.2));
setProperty(“_root.fg3a”, _y, _root.fg3a._y+(_root.Vscrollspeed*1.1));
setProperty(“_root.fg3b”, _y, _root.fg3b._y+(_root.Vscrollspeed*1.1));
setProperty(“_root.fg3c”, _y, _root.fg3c._y+(_root.Vscrollspeed*1.1));
setProperty(“_root.floor1”, _y, _root.floor1._y+(_root.Vscrollspeed));
setProperty(“_root.floor2”, _y, _root.floor2._y+(_root.Vscrollspeed));
//MIDGROUND (HERO) PLANES
setProperty(“_root.ground1”, _y, _root.ground1._y + _root.Vscrollspeed);
setProperty(“_root.ground2”, _y, _root.ground2._y + _root.Vscrollspeed);
//BACKGROUND PLANES
setProperty(“_root.mainbg01”, _y, _root.mainbg01._y +_root.Vscrollspeed);
setProperty(“_root.mainbg02”, _y, _root.mainbg02._y +_root.Vscrollspeed);
setProperty(“_root.mainbg03”, _y, _root.mainbg03._y +_root.Vscrollspeed);
setProperty(“_root.wall1”, _y, _root.wall1._y+(_root.Vscrollspeed/1.5));
setProperty(“_root.wall2”, _y, _root.wall2._y+(_root.Vscrollspeed/1.5));
}
function SetVertScroll() {
if (_root.hero._y < 280 && _root.shaking != “on”) {
//SCROLL UP
_root.Vscrolldirection = “UP”;
_root.Vscrollspeed = 6;
VertPlayField();
//END SCROLL UP
//TELEPORT
if (_root.hero.stance==”teleporting”) {
_root.Vscrollspeed = 40;
}
} else if ((_root.hero._y>460 && _root.shaking != “on”) || (_root.hero.feet==”flying” && _root.hero._y > 360)) {
//SCROLL DOWN
_root.Vscrolldirection = “DOWN”;
if (_root.hero.stance==”jetpack” && _root.hero._y < 460) {
//JETPACK IS ACTIVE AND HERO IS ABOVE SCROLL THRESHOLD
_root.Vscrollspeed = -_root.hero.jetpack.gravity;
_root.scrollcase = “JPNORM”;
} else if (_root.hero.stance==”jetpack” && _root.hero._y > 460 ) {
//EDGE CASE… HERO HAS FALLEN BELOW SCROLL THRESHOLD WHILE ACTIVATING JETPACK
if (Key.isDown(Key.UP)) {
_root.Vscrollspeed = _root.hero.jetpack.gravity*4;
} else {
_root.Vscrollspeed = -_root.hero.jetpack.gravity*4;
}
_root.scrollcase = “JPOUT”;
} else if (_root.hero._y > 600 && _root.hero.feet == “grnd”) {
_root.Vscrollspeed = -20;
} else if (_root.hero._y > 460 && _root.hero.feet == “grnd” && _root.hero.plattype!=”elevator”) {
_root.Vscrollspeed = -2;
} else if (_root.hero._y > 460 && _root.hero.feet == “air”) {
_root.Vscrollspeed = -_root.hero.jump
} else if (_root.hero.plattype==”elevator” && _root.hero._y < 460) {
//HERO IS ON ELEVATOR AND IS ABOVE SCROLL THRESHOLD
_root.Vscrollspeed = -herop.Vspeed;
_root.scrollcase = “ELNORM”;
} else {
//ALL OTHER CASES
_root.Vscrollspeed = -_root.hero.jump;
_root.scrollcase = “-HERO”
}
//
VertPlayField();
} else if (_root.shaking!=”on” && _root.hero.feet==”grnd” ){
_root.Vscrollspeed = 0;
}
}
//PLATFORM LOGIC
function platformLogic (plat) {
//CHECK FOR FALLING HERO
//OR JUMPING HERO
//GRAB HIM IF HE’S TOUCHING OR FALLING THROUGH PLATFORM
if (_root.hero.inpit==”false” && _root.hero._y < (plat._y + 20) && plat.hitTest(_root.hero) && (_root.hero.feet == “air” || _root.hero.feet==”laidout”) && (_root.hero.jump > 0 || _root.hero.lift > 0)) {
setProperty(_root.hero, _y, plat._y);
if (_root.hero.jump>10 && _root.hero.stance!=”laidout” && _root.hero.stance!=”airattack2″) {
_root.hero.gotoAndPlay(“land”);
} else if (_root.hero.stance==”laidout”) {
_root.hero.gotoAndPlay(“backslide”);
} else if (_root.hero.stance==”hurled”) {
_root.hero.gotoAndPlay(“faceslide”);
} else if (_root.hero.stance==”hammer”) {
_root.hero.gotoAndPlay(“failstomp”);
}else {
_root.hero.gotoAndPlay(_root.hero.Gait);
}
_root.hero.jump = 0;
if (_root.hero.stance != “laidout”) {
_root.hero.stance = “fight”;
}
_root.hero.feet = “grnd”;
plat.onplat = “true”;
plat.dbtag = plat._name;
_root.herop = plat._name;
_root.tx = plat._x;
_root.hero.plattype=plat.plattype;
}
//CHECK FOR HERO WALKING OFF PLATFORM
//PUSH HERO DOWN BEYOND THIS PLATFORM’S CATCH HEIGHT
//SET HERO’S JUMP TO 1 AND PUT HIS FEET IN AIR
//^THIS WILL MAKE HIM FALL TO GROUND LEVEL
//START HERO’S DROP ANIMATION
//SET ONPLAT TO FALSE
if (plat.onplat == “true” && Math.abs(plat._x – _root.hero._x) > plat._width/2 && (_root.hero.feet == “grnd” || _root.hero.stance==”sliding”) && _root.herop == plat._name) {
setProperty(_root.hero, _y, plat._y);
_root.hero.feet = “air”;
plat.onplat = “false”;
_root.herop = “none”;
//CHECK FOR HERO JUMPING OFF PLATFORM OR BEING LAID OUT WHILE ON PLATFORM
//(BEING LAID OUT SENDS HERO FALLING TO GROUND)
} else if (plat.onplat == “true” && _root.hero.feet != “grnd”) {
plat.onplat = “false”;
_root.herop = “none”;
}
//
//BUMP HERO’S HEAD (STOP HIS JUMP) IF THIS IS A CEILING
}
function heroHeadBump (plat) {
if (plat.hitTest(_root.hero) && _root.hero.jump<0) {
_root.hero.jump = -_root.hero.jump/10;
}
}
function elevatorLogic2(el) {
if (el.motor == “running” && el.climb > 0 && el.climbed < el.climb) {
// ELEVATOR GOING UP
el.climbed = el.climbed + el.Vspeed;
if (el.onplat==”true” && el.scrolltype!=”static” && el.motor==”running”)
{
_root.Vscrollspeed = el.baseVspeed*2;
_root.Vscrolldirection = “UP”;
_root.VertPlayField();
el.elevatorGoing=”up”;
_root.scrollcase = “ELUP”;
} else {
setProperty(el, _y, el._y – el.baseVspeed*2);
}
}
else if (el.motor == “running” && el.climb < 0 && el.climbed > el.climb) {
// ELEVATOR GOING DOWN
el.climbed = el.climbed – el.Vspeed;
if (el.onplat==”true” && el.scrolltype!=”static” && el.motor==”running”)
{
_root.Vscrollspeed = -el.baseVspeed*2;
_root.Vscrolldirection = “DOWN”;
_root.VertPlayField();
el.elevatorGoing=”down”;
_root.scrollcase = “ELDOWN”;
} else {
setProperty(el, _y, el._y + el.baseVspeed*2);
}
}
if ((el.climb > 0 && el.climbed >= el.climb) || (el.climb < 0 && el.climbed <= el.climb)) {
if ((el.returntrip == “up” && el.climb < 0 ) || (el.returntrip == “down” && el.climb > 0)) {
//el.roundtrip=”yes”;
} else {
//el.roundtrip=”no”;
}
el.motor = “off”;
el.climbed = 0;
el.climb = -el.climb;
el.gotoAndPlay(“shutdown”);
}
//Reduce the following singletons to a pure function
//HERO ELEVATOR LOGIC
//Remote note.. the following is broken because lookimng for hero below platform.. needs to be aboves
if (el.hitTest(_root.hero) && _root.hero.stance == “press”) {
_root.herop = el._name;
_root.hero._y = (el._y -1);
el.onplat=”true”;
_root.hero.plattype=”elevator”;
}
//NPC ELEVATOR LOGIC
if (el.hitTest(_root.NPC) && _root.NPC.feet == “grnd”) {
_root.NPCp = el._name;
_root.NPC._y = (el._y -el._height/2)+15;
NPC.onplat=”true”;
_root.NPC.plattype=”elevator”;
}
//AI ELEVATOR LOGIC
if (el.hitTest(_root.AI)) {
_root.AIp = el._name;
_root.AI._y = el._y + 20;
AI.onplat=”true”;
_root.AI.plattype=”elevator”;
}
}
//FLYING SENTRY WALL BLOCKING LOGIC
function blockSentryX(wall) {
//IS THE FLYING SENTRY TOUCHING ME?
if (wall.hitTest(_root.sentry)) {
//BOUNCE SENTRY
_root.sentry.Xflight = “blocked”;
_root.sentry.Xspeed = -_root.sentry.Xspeed;
}
}
function blockSentryY(wall) {
//IS THE FLYING SENTRY TOUCHING ME?
if (wall.hitTest(_root.sentry)) {
//BOUNCE SENTRY
_root.sentry.Yflight = “blocked”;
_root.sentry.Yspeed = -_root.sentry.Yspeed;
}
}
//BLOCK HERO
function blockHeroX (wall) {
//IS THE HERO TOUCHING ME AND WALKING?
if (wall.hitTest(_root.hero) && _root.hero.feet != “flying”) {
//IF HERO IS FACING ME, SET HIS SPEED TO 0:
if (wall._x<_root.hero._x && _root.hero.facing==”left”) {
_root.hero.Walk_Speed=0;
_root.hero.Walk_Path=”blocked”;
} else if (wall._x>_root.hero._x && _root.hero.facing==”right”) {
_root.hero.Walk_Speed=0;
_root.hero.Walk_Path=”blocked”;
} else if (_root.hero.stance==”laidout”) {
_root.hero.Walk_Speed=0;
_root.hero.Walk_Path=”blocked”;
}
}
}
//BLOCK AI
function blockAIX (wall) {
//IS THE HERO TOUCHING ME AND WALKING?
if (wall.hitTest(_root.AI) && _root.AI.feet != “flying”) {
//IF HERO IS FACING ME, SET HIS SPEED TO 0:
if (wall._x<_root.AI._x && _root.AI.facing==”left”) {
_root.AI.Walk_Speed=0;
_root.AI.Walk_Path=”blocked”;
} else if (wall._x>_root.AI._x && _root.AI.facing==”right”) {
_root.AI.Walk_Speed=0;
_root.AI.Walk_Path=”blocked”;
}
}
}
//BUMP HERO’S HEAD (STOP HIS JUMP) IF THIS IS A CEILING
function blockJetpack(wall) {
//AM I TOUCHING THE HERO AND IS HE FLYING?
if (wall.hitTest(_root.hero) && _root.hero.feet == “flying”) {
//IS THE HERO TO THE LEFT OF ME AND MOVING TO THE RIGHT?
if (_root.hero._x < wall._x – wall._width/2 && _root.scrollspeed<0) {
_root.hero.rebound = (Math.round(-_root.scrollspeed*110))/100 + 1;
_root.hero.jetspeed = 0;
//_root.hero.Walk_Path=”blocked”;
//IS THE HERO TO MY RIGHT AND MOVING TO THE LEFT?
} else if (_root.hero._x > wall._x + wall._width/2 && _root.scrollspeed>0) {
_root.hero.rebound = (Math.round(-_root.scrollspeed*110))/100 – 1;
_root.hero.jetspeed = 0;
//_root.hero.Walk_Path=”blocked”;
} else {
//IF I’M TOUCHING THE HERO BUT HE’S INSIDE MY WIDTH HE MUST BE APPROACHING FROM ABOVE OR BELOW
//BOUNCE ME UP/DOWN BY REVERSING MY GRAVITY
if (wall._y > _root.hero._y) {
_root.hero.jetpack.gravity = -_root.hero.jetpack.gravity/2;
_root.hero._y = _root.hero._y – 2;
} else if (wall._y < _root.hero._y) {
_root.hero.jetpack.gravity = -_root.hero.jetpack.gravity;
_root.hero._y = _root.hero._y + 2;
}
//FIGURE OUT IF THE HERO IS OVERLAPPING ME FROM TOP OR BOTTOM AND BUMP HIM UP OR DOWN ACCORDINGLY
}
}
}
//BOUNCE THE ASTEROIDS OFF AND/OR CONTAIN THEM
function blockAsteroidX(wall,ast) {
if(wall.hitTest(ast)) {
ast._x = ast._x – ast.vx;
ast.vx = -ast.vx;
if (ast.vy < 0 && ast.rotspeed < 6) {
ast.rotspeed = ast.rotspeed + .5;
} else if (ast.vy > 0 && ast.rotspeed > -6) {
ast.rotspeed = ast.rotspeed – .5;
}
// if (Math.abs(ast.vx) > 5) {
// ast.vx = -ast.vx;
// }
}
}
function blockAsteroidY(wall,ast) {
if(wall.hitTest(ast)) {
ast._y = ast._y – ast.vy;
ast.vy = -ast.vy;
//SPIN THE ASTEROID
if (ast.vx < 0 && ast.rotspeed > -6) {
ast.rotspeed = ast.rotspeed – .5;
} else if (ast.vx > 0 && ast.rotspeed < 6) {
ast.rotspeed = ast.rotspeed + .5;
}
//LIMIT THE BOUNCE TO A SANE SPEED IN THE CASE OF A LOOP CAUSED BY OVERLAPPING
// if (Math.abs(ast.vy) > 5) {
// ast.vy = -ast.vy;
// }
}
}
function openForAsteroid(wall,ast) {
if (wall.hitTest(ast) && ast._y < wall._y && wall.stance==”closed” && wall._y > ast._y) {
wall.gotoAndPlay(“trigger”);
}
}
function openForCharacter(wall,char) {
dx = wall._x – char._x;
dy = wall._y – char._y;
wall.dx = dx;
wall.dy = dy;
if (_root.hero.stance==”jetpack” && Math.abs(dy)<300 && ((Math.abs(dx) < wall._width/2) && Math.abs) ) {
if (wall.stance==”closed”) {
wall.gotoAndPlay(“trigger”);
} else {
wall.autoinput = “stayopen”;
}
} else {
wall.autoinput = “close”;
}
}
function ShakeScene() {
//IF SHAKING IS OFF AND SHAKESTRENGTH IS SET, TURN IT ON AND SET SHAKE DIRECTION TO DOWNWARDS
if (_root.shaking!=”on” && _root.shakestrength>0) {
_root.shaking = “on”;
_root.shake = “down”;
}
//CALL THE VSCROLL FUNCTION
VertPlayField();
//CHECK FOR SHAKE DIRECTION, SET VSCROLL NEGATIVE FOR UP AND POSITIVE FOR DOWN
//IF SHAKING DOWN, INCREMENT SHAKE STRENGTH (KEEPS UP AND DOWN SHAKES EQUAL STRENGTH)
if (_root.shake==”down”) {
_root.Vscrollspeed = _root.shakestrength;
_root.shake = “up”;
} else if (_root.shake==”up”) {
_root.Vscrollspeed = -_root.shakestrength;
_root.shake = “down”;
if (_root.shakestrength>0) {
_root.shakestrength = _root.shakestrength-1;
}
}
// IF SHAKING HAS STOPPED ON THE UPSTROKE (GONE TO 0 SHAKESTRENGTH) SHAKE IT DOWNWARDS ONE MORE TIME)
if (_root.shakestrength == 0 && shaking == “on”) {
if (_root.shake==”down”) {
_root.Vscrollspeed = -1;
VertPlayField();
}
_root.shaking = “off”;
_root.Vscrollspeed = 0;
}
}
//BRICK LOGIC
function brickLogic(plat) {
//CHECK FOR FALLING HERO
//OR JUMPING HERO
//GRAB HIM IF HE’S FALLING THROUGH PLATFORM
if (_root.hero.inpit==”false” && _root.hero._y < (plat._y + _root.hero._height) && plat.hitTest(_root.hero) && (_root.hero.feet == “air” || _root.hero.feet==”laidout”) && (_root.hero.jump > 0 || _root.hero.lift > 0))
{
setProperty(_root.hero, _y, plat._y);
if (_root.hero.jump>10 && _root.hero.stance!=”laidout” && _root.hero.stance!=”airattack2″) {
_root.hero.gotoAndPlay(“land”);
} else if (_root.hero.stance==”laidout”) {
_root.hero.gotoAndPlay(“backslide”);
} else if (_root.hero.stance==”hurled”) {
_root.hero.gotoAndPlay(“faceslide”);
} else if (_root.hero.stance==”hammer”) {
_root.hero.gotoAndPlay(“failstomp”);
}else {
_root.hero.gotoAndPlay(_root.hero.Gait);
}
_root.hero.jump = 0;
_root.hero.feet = “grnd”;
_root.hero.stance = “fight”;
plat.onplat = “true”;
plat.dbtag = plat._name;
_root.herop = plat._name;
_root.tx = plat._x;
}
// CHECK FOR HERO WALKING FROM BRICK TO BRICK
if (_root.hero.feet == “grnd” && plat.hitTest(_root.hero) && Math.abs(plat._x – _root.hero._x) < plat._width / 2 && _root.hero.jump == 0 && (Math.abs(plat._y – _root.hero._y) < 2)) {
plat.onplat = “true”;
_root.herop = plat._name;
}
// CHECK FOR HERO HITTING BRICK FROM BELOW
if (plat.hitTest(_root.hero) && (Math.abs(plat._x – _root.hero._x) < plat._width/2) && (_root.hero._y-_root.hero._height>plat._y-10) && _root.hero.jump < 0) {
_root.hero.jump = 0;
plat.play();
targ.play();
}
//CHECK FOR HERO WALKING OFF PLATFORM
//PUSH HERO DOWN BEYOND THIS PLATFORM’S CATCH HEIGHT
//SET HERO’S JUMP TO 1 AND PUT HIS FEET IN AIR
//^THIS WILL MAKE HIM FALL TO GROUND LEVEL
//START HERO’S DROP ANIMATION
//SET ONPLAT TO FALSE
if (plat.onplat == “true” && Math.abs(plat._x – _root.hero._x) > plat._width / 2 && _root.hero.feet == “grnd”) {
plat.onplat = “false”;
if (_root.herop == plat._name) {
_root.herop = “assbiscuits”;
_root.herop2 = plat._name;
}
} else if (plat.onplat == “true” && _root.hero.feet != “grnd”) {
plat.onplat = “false”;
}
if (Math.abs(plat._x – _root.hero._x) > plat._width/.75 && _root.hero.feet == “grnd”) {
if (_root.herop2 == plat._name) {
_root.herop2 = “nada”;
}
}
}
//
/// LEFT OR RIGHT FUNCTION
function LeftOrRight(sprite) {
//MOVE LEFT
//
//ADDITIONALLY COULD ADD IN SMOOTH ANIMATION FOR CHANGING DIRECTIONS
//NOTE THE SCALEFACTOR
_root.heroxscale = _root.hero._xscale;
if (Key.isDown(Key.LEFT)) {
if (sprite.feet == “grnd” || sprite.feet == “flying”) {
setProperty(sprite, _xscale, -100);
}
//MOVE RIGHT
} else if (Key.isDown(Key.RIGHT)) {
if (sprite.feet == “grnd” || sprite.feet == “flying”) {
setProperty(sprite, _xscale, 100);
}
}
}
/// END LEFT OR RIGHT FUNCTION
//
function Attack(sprite) {
if (Key.isDown(Key.DOWN) && Key.isDown(Key.SPACE) && sprite.dive == “enabled” && sprite.feet == “air”) {
sprite.gotoAndPlay(“airattack2″);
}
if (Key.isDown( 70 )) {
//F key
if (sprite.stance==”cover”) {
sprite.gotoAndPlay(“uppercut”);
sprite.stance = “uppercut”;
} else if (sprite.feet == “air”) {
sprite.gotoAndPlay(“airattack1″);
} else if (sprite.stance!=”cover”) {
sprite.gotoAndPlay(“attack1”);
}
}
}
function Combo(sprite) {
if (Key.isDown( 70 )) {
//F key
if (sprite.combo != “closed” && (_root.AI.stance == “hitchin”)) {
sprite.gotoAndPlay(sprite.combo);
}
}
}
function Cover(sprite) {
if (Key.isDown(Key.DOWN)) {
if (sprite.stance == “fight” && sprite.feet == “grnd”) {
sprite.stance = “cover”;
//TO KILL FLYING FEET BUG
sprite.feet = “grnd”;
sprite.gotoAndPlay(“cover”);
}
}
}
function KneeSlide(sprite) {
if (Key.isDown(Key.DOWN) && sprite.momentum > 8) {
sprite.gotoAndPlay(“kneeslide”);
}
}
function PressGrab(sprite) {
//G key
if (Key.isDown(71) && sprite.feet == “grnd” && sprite.stance!=”cover”) {
sprite.gotoAndPlay(“press”);
} else if (Key.isDown(71) && sprite.stance==”jetpack”) {
}
//START JETPACK
if (sprite.feet == “air” && sprite.stance != “jetpack” && Key.isDown(Key.UP) && Key.isDown(Key.SPACE)) {
if (_root.hero.jetpacktype == “minisub”) {
sprite.gotoAndPlay(“minisubon”);
} else {
sprite.gotoAndPlay(“jetpackon”);
}
sprite.stance=”jetpack”;
sprite.setspeed=_root.scrollspeed;
sprite.jump=0;
}
}
//JUMP ON INPUT
function SpriteJump(sprite) {
if (Key.isDown(Key.SPACE) && sprite.feet == “grnd” && sprite.stance == “fight”) {
sprite.gotoAndPlay(“jump”);
sprite.inpit = “false”;
sprite.jump = -1*(sprite.Jump_Height);
sprite.Speed_Boost = 0;
sprite.Walk_Speed = sprite.Walk_Speed + sprite.Speed_Boost;
sprite.feet = “air”;
sprite.stance = “jump”;
sprite.dive = “disabled”;
sprite._y=sprite._y-16;
}
if (Key.isDown(Key.SPACE) && Key.isDown(Key.DOWN) && sprite.feet == “grnd” && sprite.stance == “cover”) {
sprite.gotoAndPlay(“diveroll”);
}
}
//GRAVITY
function SpriteGravity(sprite) {
if (sprite._y < sprite.Ground_Level && sprite.feet == “air” && sprite.jump < sprite.Max_Yvel) {
sprite.jump = sprite.jump + _root.gravity;
}
}
//FALL THROUGH AIR
function SpriteFall(sprite) {
if (sprite.feet!=”grnd” && sprite.feet!=”sliding”) {
setProperty(sprite, _y, sprite._y + sprite.jump);
}
}
//START THE FRAME BY STORING CURRENT X,Y,FRAME#
function SpriteFrameStart(sprite) {
sprite.x1 = sprite._x;
sprite.y1 = sprite._y;
sprite.myframe = sprite._currentframe;
}
function SpriteFrameEnd(sprite) {
sprite.x2 = sprite._x;
sprite.y2 = sprite._y;
sprite.xvel = _root.scrollspeed;
sprite.yvel = sprite.y2-sprite.y1;
}