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

5 years ago by eLouai

An effect similar to biolab, when jumping what is the best way to allow a user to control the jump height (by keeping the key pressed longer).

I have my own ideas, but was curious what was best practices regarding this issue.

I am assuming I would need to check with the state of the key in the game loop, the longer its help down the higher he goes, so for the first 3 frames the character is just bending at the news getting ready to jump?

Ideas on code implementation?

5 years ago by FunnyFunk91

This could be helpful http://gamemechanicexplorer.com/#platformer-6

The code is implemented with Phaser but the concepts should carry over to impact

5 years ago by stahlmanDesign

In my game I have a normal jump and a super jump when pressing up and jump at the same time:

			if( this.standing && ig.input.pressed('jump') ) {
				if (ig.input.state('up')) {
					this.vel.y = -this.bigJump;
				}
				else {
					this.vel.y = -this.jump;

				}

				this.sfxJump.play();
			}

For variable jump, you could start by detecting ig.input.state('jump') on the update loop. (state, not pressed) On each update while the jump state is still true, you could increase your power. When state is no longer true, then jump according to the power built up.

5 years ago by eLouai

Thanks for the replies,
FunnyFunk: great link, bookmarked it.
StahlmanDesign: Interesting idea, I wanted to create something like the old Mario games, or even the biolab demo, but I dont think he provided the player code to see how it was done

5 years ago by alexandre

eLouai, this bit of code may help.

5 years ago by eLouai

alexandre: Yes that solves the problem perfectly
Page 1 of 1
« first « previous next › last »