Infinite jumping

The Partridge Family were neither partridges nor a family. Discuss.
Post Reply
lori3
Posts: 3
Joined: March 1st, 2017, 6:54 pm

Infinite jumping

Post by lori3 » March 1st, 2017, 6:59 pm

Hey. I tried to make a super mario - copy for myself in chilli framework, and after a few minutes of development i ran into a few errors. These files show how the mario object is animated to jump.
Can this be fixed somehow?
Attachments
sdw.JPG
sdw.JPG (29.39 KiB) Viewed 2308 times
dwf.JPG
(35.08 KiB) Not downloaded yet

User avatar
Zedtho
Posts: 189
Joined: February 14th, 2017, 7:32 pm

Re: Infinite jumping

Post by Zedtho » March 1st, 2017, 7:06 pm

With infinite jumping, do you mean that you can double jump and stuff or do you mean that Mario is jumping whenever it hits the ground.

I needed similar physics a week ago, I'll send them here:

Code: Select all

BallY = BallY + BallVY;
		++BallVY;
		
		if (BallY >= (gfx.ScreenHeight - 1 - BallHeight))
		{
			BallVY = 1;
			SpaceBarWasPressed = false;
		}
		if (wnd.kbd.KeyIsPressed(VK_SPACE) && !SpaceBarWasPressed)
		{
			BallVY = BallVY - 20;
			SpaceBarWasPressed = true;
		}
		if (BallY <= 0)
		{
			BallVY = 1;

		}
		BallX = ClampScreenX(BallX, BallWidth);
		BallY = ClampScreenY(BallY, BallHeight);
I'll continue looking at this, though.

Also, use { } with your if statement, although you're only executing one thing after the if statement. Because if one adds things one will often forget to add the parameters.

If I were to debug this I'd think the error is in the
if(y <= (Graphics::Screenheight - Groundheight - 400)
Last edited by Zedtho on March 1st, 2017, 7:29 pm, edited 1 time in total.

lori3
Posts: 3
Joined: March 1st, 2017, 6:54 pm

Re: Infinite jumping

Post by lori3 » March 1st, 2017, 7:24 pm

I mean that the animation is executed properly, but when mario touches the ground it bounces back infinitely.

The line you pointed out is just supposed to set the height the guy jumps to..

User avatar
Zedtho
Posts: 189
Joined: February 14th, 2017, 7:32 pm

Re: Infinite jumping

Post by Zedtho » March 1st, 2017, 7:32 pm

I don't see Mario being pulled back to the ground with a y += 10; or something anywhere, so it might get stuck at it's maximum height. Sorry, but I can't say much with this little code shown.

I apologise for the mistake with the if statement, by the way. Kind of stupid of me, haha.
Last edited by Zedtho on March 1st, 2017, 7:35 pm, edited 1 time in total.

lori3
Posts: 3
Joined: March 1st, 2017, 6:54 pm

Re: Infinite jumping

Post by lori3 » March 1st, 2017, 7:34 pm

This code makes it fall if not touching the ground.Forgot to share it sorry.
Attachments
sdaw.JPG
sdaw.JPG (14.02 KiB) Viewed 2296 times

User avatar
Zedtho
Posts: 189
Joined: February 14th, 2017, 7:32 pm

Re: Infinite jumping

Post by Zedtho » March 1st, 2017, 9:15 pm

Hmm, I guess more experienced programmers should get a go at this, then.
If you could post the whole code to the forum (via github or by attaching file after having zipped it with the tool by Chili) I could probably figure it out, though.

User avatar
chili
Site Admin
Posts: 3948
Joined: December 31st, 2011, 4:53 pm
Location: Japan
Contact:

Re: Infinite jumping

Post by chili » March 2nd, 2017, 1:46 am

Yes, always post full code.
Chili

Post Reply