ForumsProgramming Forummaking a jump code

7 5736
Koshionos
offline
Koshionos
881 posts
Jester

so every game i make i try to make a jump code, unfortunately i don't know how to make a limit (in truth i do but its only if the character's _y value is always starting in one spot)

  • 7 Replies
Koshionos
offline
Koshionos
881 posts
Jester

SHOULD THIS go in the sprites (or another action script file attached to a class) or the frame actions?

Koshionos
offline
Koshionos
881 posts
Jester

no i only know AS2 so far

pengper
offline
pengper
9 posts
Nomad

needs gravity i beleive

alsage
offline
alsage
132 posts
Nomad

why has this post been revived?

Secretmapper
offline
Secretmapper
1,747 posts
Nomad

Ahmm? yeah, why is this revived.

And yeah, you need gravity(in case Koshionis is still waiting)

Xinito
offline
Xinito
109 posts
Nomad

I can give you a script later its on my laptop.

abarrow
offline
abarrow
22 posts
Nomad

//AS2 code
var vy:Number=0;
hero.onEnterFrame=loop;
function loop(){
var landed:Boolean=false;
//gravity
vy+=1;
if(vy>10){
vy=10;
}
if(platforms.hitTest(hero._x, hero._y, true)){
landed=true;
vy=0;
//move you out of the ground
while(platforms.hitTest(hero._x, hero._y-1, true)){
hero._y--;
}
}
//jumping
if(isKeyDown(38)&&landed){
vy-=10;
}
//moving
this._y+=vy;
}

Showing 1-7 of 7