1 decade ago
by Eddie
I've been following a ton of slope sliding threads because it seems there are a good amount of people out there who are trying to achieve the same result I am.
That result is to NOT slide off slopes.
The main thread I've been following has been
this one, but still no one has come up with a definite universal answer.
I've tried several of the approaches, even changing the traceMovement methods still to no avail. Does anyone out there have a definite solution to this?
I'm sure I speak for a lot of Impact devs when I say thank you to anyone who can provide some insight.
I can haz cookie?
ig.module(
'game.entities.player'
)
.requires(
'impact.entity'
)
.defines(function(){
EntityPlayer = ig.Entity.extend({
//impact
animSheet: new ig.AnimationSheet( 'media/player.png', 16, 16 ),
size: { x: 16, y: 16 },
//collision
checkAgainst: ig.Entity.TYPE.B,
collides: ig.Entity.COLLIDES.ACTIVE,
type: ig.Entity.TYPE.A,
//unique
flip: false,
jump: 200,
speed: 30,
init: function( x, y, settings ){
this.parent( x, y, settings );
this.addAnim( 'idle', 1, [0] );
this.addAnim( 'run', 0.07, [0, 1, 2, 3, 4, 5] );
this.addAnim( 'jump', 1, [9] );
this.addAnim( 'fall', 0.4, [6, 7] );
},
handleMovementTrace: function( res ){
this.parent( res );
//if standing on slope and no key press
//stop all movement
if( res.collision.slope && this.standing && this.noKeyPress() ){
this.pos.x = this.last.x;
this.pos.y = this.last.y;
this.vel.x = 0;
this.vel.y = 0;
}
},
noKeyPress: function(){
var actions = ig.input.actions;
for( var action in actions ){
if( actions[action] ){
return false;
}
}
var presses = ig.input.presses;
for( var press in presses ){
if( presses[press] ){
return false;
}
}
return true;
},
update: function(){
if( ig.input.state( 'left' ) ){
this.flip = true;
this.vel.x = -this.speed;
}
else if( ig.input.state( 'right' ) ){
this.flip = false;
this.vel.x = this.speed;
}
else{
this.vel.x = 0;
}
if( ig.input.pressed( 'jump' ) && this.standing ){
this.vel.y = -this.jump;
}
if( this.vel.y < 0 && !this.standing ){
this.currentAnim = this.anims.jump;
}
else if( this.vel.y > 0 && !this.standing ){
this.currentAnim = this.anims.fall;
}
else if( this.vel.x !== 0 ){
this.currentAnim = this.anims.run;
}
else{
this.currentAnim = this.anims.idle;
}
this.currentAnim.flip.x = this.flip;
this.parent();
}
});
});
@Eddie are you looking to do something like this?
http://marketjs.com/game/emmas-gems . it's built with slopes
1 decade ago
by Eddie
1 decade ago
by Eddie
That being said, there are a couple of bugs, but I'll figure it out as I go :]
The player glitches out when resolving collisions with slopes (weird animation glitches) that sometimes spill over to one way tiles, but still, much appreciated :D
Try upping ig.game.gravity
by a large margin. Slope collisions add vel that can make your character feel bouncy, even if .bounciness = 1
.
I removed the
this.vel.y = 0
from
.handleMovementTrace()
:
handleMovementTrace: function( res ){
this.parent( res );
//if standing on slope and no key press
//stop all movement
if( res.collision.slope && this.standing && this.noKeyPress() ){
this.pos.x = this.last.x;
this.pos.y = this.last.y;
this.vel.x = 0;
}
},
I then set
ig.game.gravity = 800
. This allowed me to run up and down hills with minimal bounce. Setting gravity even higher will eliminate bounce altogether.
Page 1 of 1
« first
« previous
next ›
last »