Sign in to follow this  
pepsi coder

[web] Need pro flash coder

Recommended Posts

Hi i have a problem with my player code, in any other language iv written games in i have had no problems but im stuck and have not moved on with the development of my game now for a month. To take a look at the games current state go to http://www.mpepper.co.uk it seems that the animation for the player goes wrong about %5 of the time.Can someone throw some light on the subject thanks in advance.

Share this post


Link to post
Share on other sites
Here is player code if u move around u will notice that sometimes the first frame of a walking animation remains static/and sometimes u will be moving one way horizontally and player will be doing the animation for the opposite direction please please please help. :-

onClipEvent(enterFrame) {

if (_root.playerstate==1) {

// move right
if(Key.isDown(Key.RIGHT)) {
if (_root.floortouch==true) {
if (_root.anim!=4) {
this.gotoAndPlay("runright");
_root.anim=4;
}
} else {
if (_root.anim!=6) {
this.gotoAndPlay("jumpright");
_root.anim=6;
}
}
if (_root.xs<=6) _root.xs+=_root.xv;
_root.facing=1;
}

// move left
else if (Key.isDown(Key.LEFT)) {
if (_root.floortouch==true) {
if (_root.anim!=3) {
this.gotoAndPlay("runleft");
_root.anim=3;
}
} else {
if (_root.anim!=5) {
this.gotoAndPlay("jumpleft");
_root.anim=5;
}
}
if (_root.xs>=-6)_root.xs-=_root.xv;
_root.facing=0;
}

// no x input so slow down
else {
if (_root.xs<0) {
_root.xs+=_root.xv;
if (_root.xs>0) _root.xs=0;
}
else if (_root.xs>0) {
_root.xs-=_root.xv;
if (_root.xs<0) _root.xs=0;
}

if (_root.facing==0) {
if (_root.floortouch==true) {
if (_root.anim!=1) {
this.gotoAndPlay("campleft");
_root.anim=1;
}
} else {
if (_root.anim!=5) {
this.gotoAndPlay("jumpleft");
_root.anim=5;
}
}
} else {
if (_root.floortouch==true) {
if (_root.anim!=2) {
this.gotoAndPlay("campright");
_root.anim=2;
}
} else {
if (_root.anim!=6) {
this.gotoAndPlay("jumpright");
_root.anim=6;
}
}
}

}

// shoot // end key
if(Key.isDown(Key.SPACE)) {

if(getTimer()>=_root.reload) {
_root.gruntfire();
_root.reload = getTimer()+100;
}
}

// jump // page down key
if(Key.isDown(Key.UP)) {
if (_root.floortouch==true) {
// play npc spawn sound
sfx_grunt_jump = new Sound();
sfx_grunt_jump.attachSound("grunt jump");
sfx_grunt_jump.start();
_root.ys=-13;
}
}

// limit horizontal movement
if(_x < 10) {
_root.xs=0
_x=10;
} else if(_x > _root.dw-10) {
_root.xs=0
_x=_root.dw-10;
}

// apply movement
_root.ys+=_root.yv;
_y+=_root.ys;
_x+=_root.xs;

// limit fall speed
if (_root.ys>=31) _root.ys=31;

// platform check
_root.floortouch=false;
var a=_x>>5;
var b=_y>>5;
var c=((b*22)+a);
var d=_root.pd[c]
var e=b<<5;
if (d>0) {
if (lfy<=e) {
_y=e;
_root.ys=0;
_root.floortouch=true;
}
}
lfy=_y;

} else {

_root.ys+=_root.yv;
_y+=_root.ys;
if (_root.ys>=13) _root.ys=13;
if (_y>_root.dh+200) {
_root.lives-=1;
if (_root.lives==0) {
// remove all npc
for (var i = _root.npcarray.length-1; i>=0; i--) {
_root.npcarray[i].removeMovieClip();
}
// set removal of npc weapons
_root.removenpcweapons=true;

_root.gameevent=1;
} else {
this.gotoAndPlay("campleft");
_root.playerstate=1;
_root.grunt._rotation=0;
_root.grunt._x=_root.dw/2;
_root.grunt._y=_root.dh/2;
}
}

}

}


Share this post


Link to post
Share on other sites
Guest Anonymous Poster
you could try here too: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Share this post


Link to post
Share on other sites
Well, i dont know if its just me, but the link to get to your game didn't seem to work.
if you could post a link direct to your game or something so i can see the fault, that would be good.
another option could be to send me the fla file...but you dont have to do that if you dont want to.

Esaptonor.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this