It seems the slopes are setup somewhat odd with impact. The slopes have a weird affect when I run up them, like its a normal square tile that I am jumping up onto and I get pushed down by gravity until I hit the halfway point of the tile.
My question is, is there a way to make it so that I do not slide down tiles when standing on them when affected by gravity or acceleration on the y axis.
A good example would be a sloped area in something like super mario bros. 3.
This is what I came up with as a solution for my problem.
handleMovementTrace: function(res){
var mx, my, trace;
mx = this.vel.x * ig.system.tick;
my = this.vel.y * ig.system.tick;
mx = (this.flip) ? mx+10 : mx-10;
trace = ig.game.collisionMap.trace(
this.pos.x, this.pos.y, mx, my+10, this.size.x, this.size.y
);
if(ig.input.pressed('shoot')){
console.log("Trace: ", trace);
console.log("Res: ", res);
}
if(res.collision.slope){
this.slopeData.slope = true;
this.slopeData.x = res.collision.slope.x;
this.slopeData.y = res.collision.slope.y;
}else{
this.slopeData.slope = false;
}
if(trace.collision.slope){
//this.vel.y = 150;
this.slopeData.x = trace.collision.slope.x;
this.slopeData.y = trace.collision.slope.y;
console.log('slope');
}
this.parent(res);
}
antiSlideSlope: function (slopeData){
slopeData = slopeData || false;
if(slopeData.slope){
if(this.flip){
if(slopeData.y < 0){
if(!ig.input.state('right') && !ig.input.state('left')){
this.vel.x = 1.05;
}
if(this.standing && !this.jump){
this.vel.y = -4;
}
if(ig.input.state('left')){
this.vel.y = 75;
this.vel.x = this.vel.x/2;
}
}else if(slopeData.y > 0){
if(!ig.input.state('right') && !ig.input.state('left')){
this.vel.x = -1.05;
}
if(this.standing && !this.jump){
this.vel.y = -4;
}
}
}else{
if(slopeData.y < 0){
if(!ig.input.state('right') && !ig.input.state('left')){
this.vel.x = 1.05;
}
if(this.standing && !this.jump){
this.vel.y = -4;
}
}else if(slopeData.y > 0){
if(!ig.input.state('right') && !ig.input.state('left')){
this.vel.x = -1.05;
}
if(this.standing && !this.jump){
this.vel.y = -4;
}
if(ig.input.state('right')){
this.vel.y = 75;
this.vel.x = this.vel.x/2;
}
}
}
}
}
Page 1 of 1
« first
« previous
next ›
last »