hi all
Im trying to make a marolike game with help from tonypa’s tutorials(http://www.tonypa.pri.ee),
i’ve made this so far this ( mario scroll.swf attachment) as you can see the sloped tiles don’t work
I’m using this tutorial http://www.tonypa.pri.ee/tbw/tut24.html
the functions are in the attached functions.as
the tiles in tiles1.as
the map in map1.as
and main fla is http://www.kzmu.nl/mario scroll.fla
their should be something wrong in this code : tiles1.as
game.Tile4= function () {};
game.Tile4.prototype.walkable=true;
game.Tile4.prototype.slope=1;
game.Tile4.prototype.frame=4;
game.Tile5= function () {};
game.Tile5.prototype.walkable=true;
game.Tile5.prototype.slope=-1;
game.Tile5.prototype.frame=5;
or (functions.as)
function checkForSlopes (ob, diry, dirx) {
if (game["t_"+(ob.ytile+1)+"_"+ob.xtile].slope and !ob.jump){
ob.ytile += 1;
ob.y += game.tileH;
}
if (game["t_"+ob.ytile+"_"+ob.xtile].slope and diry != -1){
if (diry == 1){
ob.y = (ob.ytile+1)*game.tileH-ob.height;
}
var xpos = ob.x-ob.xtile*game.tileW;
ob.onSlope = game["t_"+ob.ytile+"_"+ob.xtile].slope;
ob.jump = false;
if(game["t_"+ob.ytile+"_"+ob.xtile].slope == 1){
ob.addy = xpos;
ob.clip._y = (ob.ytile+1)*game.tileH-ob.height-ob.addy;
}else{
ob.addy = game.tileW-xpos;
ob.clip._y = (ob.ytile+1)*game.tileH-ob.height-ob.addy;
}
}else{
if((ob.onSlope == 1 and dirx == 1) or (ob.onSlope == -1 and dirx == -1)){
ob.ytile -= 1;
ob.y -= game.tileH;
ob.clip._y = ob.y;
}
ob.onSlope = false;
}
}
or (functions.as)
//left
if ((ob.downleft and ob.upleft) or ob.onSlope) {
//right
if ((ob.upright and ob.downright) or ob.onSlope) {
or ( functions.as)
ob.clip._x = ob.x;
ob.clip._y = ob.y;
checkForSlopes(ob, diry, dirx);
or (functions.as)
if (Key.isDown(Key.SPACE)) {
if (!ob.jump){
//if we were on slope, update
if (ob.onSlope) {
ob.y -=ob.addy;
ob.ytile = Math.floor(ob.y/game.tileH);
}
ob.jump = true;
ob.jumpspeed = ob.jumpstart;
}
}else if (Key.isDown(Key.RIGHT)) {
keyPressed=_root.moveChar(ob, 1, 0);
}else if (Key.isDown(Key.LEFT)) {
keyPressed=_root.moveChar(ob, -1, 0);
}
thanks for looking
Thomas