Hi, i have gotton bits and peices of platformer engines frome all over the net. But i can never find any platform engines that have the slope element with them. Usualy its just a strait board or strait wall.
Does anyone Know a way of putting slopes in my engine?
onClipEvent(load){
speed = 0;
maxspeed = 8;
jumpspeed = 0;
jumpheight = 13;
fall = 0;
maxgravity = 15;
platforms = //how many platforms you have;
stagecentrex = Stage.width/2;
stagecentrey = Stage.height/2;
var jump:Boolean = true;
}
onClipEvent(enterFrame) {
charx = _root.char._x;
chary = _root.char._y;
charh = _root.char._height;
charw = _root.char._width;
_root.char._x += speed;
_root.char._y += fall;
if(charx > Stage.width/2) {
_root._x = -charx+stagecentrex;
} else {
_root._x = 0;
if(charx < Stage.width/2) {
_root._x = -charx+stagecentrex;
} else {
_root._x = 0;
}
}
if(chary < Stage.height/2) {
_root._y = -chary+stagecentrey;
} else {
_root._y = 0;
}
fall++
if(fall >= maxgravity) {
fall = maxgravity;
}
if(Key.isDown(Key.LEFT)) {
speed--;
_root.char.gotoAndStop(2);
_root.char._xscale = +180
if(speed <= maxspeed*-1) {
speed = maxspeed*-1;
}
} else if(Key.isDown(Key.RIGHT)) {
speed++;
_root.char.gotoAndStop(2);
_root.char._xscale = -180
if(speed >= maxspeed*+1) {
speed = maxspeed*+1;
}
} else {
if(speed > 0) {
speed--;
if(speed <= 0) {
speed = 0;
_root.char.gotoAndStop(1);
}
} else if(speed < 0) {
speed++;
if(speed >= 0) {
speed = 0;
_root.char.gotoAndStop(1);
}
}
}
if(Key.isDown(Key.SPACE) && jump == false && fall <= 1) {
jump = true;
}
if(jump == true) {
if(jumpspeed > 0) {
jumpspeed--;
fall = 0;
_root.char._y -= jumpspeed;
} else {
jump = false;
}
} else {
jumpspeed = jumpheight;
}
for(i=1; i<=platforms; i++) {
plat = _root["p"+i];
if(_root.char.hitTest(plat)) {
if(charx+charw/3 < plat._x-plat._width/2) {
_root.char._x = plat._x-plat._width/2-charw/2 - .1;
speed = .5;
} else if(charx-charw/3 > plat._x+plat._width/2) {
_root.char._x = plat._x+plat._width/2+charw/2 + .1;
speed = .5;
}
if(chary+charh/2-1 < plat._y-plat._height/2) {
_root.char._y = plat._y-plat._height/2-charh/2 - .1;
jumpspeed = jumpheight;
fall = 0;
jump = false;
}
}
}
}
Thanx in advance:)