ForumsProgramming Forumplatform game

5 3201
rino
offline
rino
27 posts
Nomad

Does anyone have platform code that also allows the character to walk up and down hills

  • 5 Replies
GuardianGames
offline
GuardianGames
25 posts
Nomad

if (Key.LEFT.isDown(Key.LEFT)and hitest UPground X=+1 Y=+1
thats off the top of my head you'll have to sculpt it obviosly


if that even works

HAXALLNOOBS
offline
HAXALLNOOBS
19 posts
Nomad

with a circle or other shape or a stickman???

if a circle try this
if it is a stickman try this

HAXALLNOOBS
offline
HAXALLNOOBS
19 posts
Nomad

soz try this code for the guy

onClipEvent (load) {
scale = _xscale;
friction = 2;
airresist = 1;
gravity = 2;
jumpamount = 17;
speed = 12;
onfloor = true;

}
onClipEvent (enterFrame) {
if (Key.isDown(Key.LEFT)) {
_xscale = -scale;
_x -= walkSpeed;
this.gotoAndStop(2);
}
if(Key.isDown(Key.UP) and onfloor){
jump = true;
onfloor = false;
yvel = -jumpamount;
}
if (Key.isDown(Key.RIGHT)) {
_xscale = +scale;
_x += walkSpeed;
this.gotoAndStop(2);
}
}
onClipEvent (keyUp) {
this.gotoAndStop(1);
walkSpeed = 25;
}
onClipEvent(enterFrame){
if(xvel < 0){
if(onfloor){
xvel += friction
} else {
xvel += airresist
}
} else if(xvel > 0){
if(onfloor){
xvel -= friction
} else {
xvel -= airresist
}
}

_root.guy._y += yvel
if(!_root.platforms.hitTest(_x,_y+1,true)){
yvel += gravity;
} else {
while(_root.platforms.hitTest(_x,_y+1,true)){
_root.guy._y -= 1;
}
onfloor = true;
yvel = 0;
}
}

rino
offline
rino
27 posts
Nomad

thanks it now works perfect

rino
offline
rino
27 posts
Nomad

There is one problem if you jump on a slope you fall through it

Showing 1-5 of 5