πŸŽ‰ Celebrating 25 Years of GameDev.net! πŸŽ‰

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Jump has a higher jump, had problems with editor.

Started by
15 comments, last by fleabay 4Β years, 2Β months ago

Also, wouldn't there be two different jumps?

Josheir

Advertisement

Josheir said:

Also, wouldn't there be two different jumps?

Josheir

Without debugging I think this is what is happening. The character jumps and touches the first platform in such a way that signals that the character is in a location where it is again able to jump, and since the key is pressed it jumps again. It all happens so fast it looks like 1 large jump.

πŸ™‚πŸ™‚πŸ™‚πŸ™‚πŸ™‚<←The tone posse, ready for action.

fleabay, You were so right! Thanks a million! here is the working code:

window.setKeyRepeatEnabled(false);
	while (window.isOpen())
	{
		sf::Clock clock;
		sf::Event event;
		while (window.pollEvent(event))
		{
			if (event.type == sf::Event::Closed)
				window.close();

			///////////jump/scroll//////////
			//if (sf::Keyboard::isKeyPressed(sf::Keyboard::J))
			else if (event.type == sf::Event::KeyPressed) {
				if (event.key.code == sf::Keyboard::J) {

					character.JumpInEndZone(line, SCREENWIDTH, SCREENHEIGHT, character, vectorPlatforms, positionX, positionY, velocityY, velocityX,
						gravity, isLeft, window, marioSpriteR, marioSpriteL, goingDown, characterOnBar);


				}
			}
		}
	}

A bit too late for the party, but this dynamic behavior stuff can be debugged nicely by injecting a few print statements in the code at relevant places.

Here it would be at the spot where you start the jump. If you have that output next to the graphic display, you can easily see how often such relevant spots are visited, but also, at which point in time. The latter usually provides useful hints for where to search for the bug.

Thanks everyone, some real good help! My jump function has a while, but because I want variable jumping and the ability to control the horizontal aspect a bit I need to jump one step than check for ongoing keypresses. I was thinking of using a counter, and for example, every fourth run change the jump.

Josheir

Josheir said:
My jump function has a while

I think ideally you should have update methods for all your game objects and pass in delta time from the game loop,

update(dt);

and incorporate faux gravity for the player's game object jump routine.

Maybe you are doing this but from the quoted text, I'm not so sure. It seems like any use of a while in a jump routine would freeze the other game objects in place until the jump was complete.

πŸ™‚πŸ™‚πŸ™‚πŸ™‚πŸ™‚<←The tone posse, ready for action.

This topic is closed to new replies.

Advertisement