Impact

This forum is read only and just serves as an archive. If you have any questions, please post them on github.com/phoboslab/impact

1 decade ago by dryas

Hi,

in my new game I'm doing some testing with slopes but I got some problems with it.

1) Is it possible to deactivate the "physics" when the player stands on a slope? I mean that the player is moving like normal without sliding or jumping when he moves over a "bumper". I just want to move over a slope like I move on a flat tile. How can I implement it without take away the ability to jump?

2) When I fire a projectile and it hits a collision tile I can call the "kill" method to remove it. If the projectile hits a slope it will climb up the slope but the "kill" is not triggered. Why?!

3) Is it possible to let the player jump higher as longer he presses the jump button? I've seen that this reaction is implemented in Biolab Disaster but not in the jump&run demo. What do I need todo to implement it?!

Thanks for your help!

Best,

Benny

1 decade ago by mimik

1. in your player code you can do something like this.
then you can work your use the this.slope in conjuction with your regular movement code.


andleMovementTrace: function(res) {

	if(res.collision.slope && res.collision.slope.nx != 0) {

		this.slope = true;

		if(this.standing) {
			this.pos.x = this.last.x;
			this.pos.y = this.last.y;
			this.vel.x = 0;			
		}
	} else {
		this.slope = false;
	}

}


you can also work with this setting in your entity
	slopeStanding: {
		min: (0).toRad(),
		max: (360).toRad()
	},

For longer jumping you must set some kind of timer to record the jump
something like this

if(ig.input.pressed('jump') && this.standing) {
	this.jumpTimer.set(0);
	this.vel.y = this.jumpAttackVel;

} else if(ig.input.state('jump') && this.jumpTimer.delta() < 0.25) {
	this.vel.y = this.jumpSustainVel;
}

1 decade ago by dryas

Hi,

thanks for the help. #2 and #3 are solved, but I can't get #1 working. :-(

I want a handling where the player doesn't slide down a slope and where the player can move over like he's moving on a straight tile... In your solution I got stuck, so I think I need to check if the player is doing some input and if he does I don't need to start the functionality you have written. I've tried the last few hours, but I can't get it working. :-(

Any more ideas?

Best,

Benny

1 decade ago by dryas

Got it working! :-) It was my fault, I've called the "this.parent()" method after my changes and they got overwritten by it. :)

Thanks a lot!

Benny
Page 1 of 1
« first « previous next › last »