Computer Science Canada

[C++ Help] SDL Platformer Game

Author:  Shinobu [ Mon Dec 30, 2013 5:43 pm ]
Post subject:  [C++ Help] SDL Platformer Game

So I came back to programming after I stopped for a month and after I reviewed the stuff I learnt, I decided to try and make a platformer game.
The problem with my program is, after I press the up button (which is supposed to make my character jump), the player just floats in the air, and never comes back down.

The player's Y position just keeps going higher and higher, and never stops (the Y value goes lower and lower).
I've tried several ways to fix the problem, which they made it not as worse as when I first made it, but the player still has flying powers that I don't want.

Can someone please take a look at what I did wrong here?
I might have to work with simpler projects first. Aiming high when I first come back into programming again might not be too good. Sad

The player logic is in the player.cpp file

Edit: I UPLOADED THE WRONG FOLDER. Sorry Dreadnaught Sad

Both the catmario zip files are the same, I'm not sure why there's 2 uploaded.

Author:  Insectoid [ Mon Dec 30, 2013 8:57 pm ]
Post subject:  RE:[C++ Help] SDL Platformer Game

I can't look at your code right now, so I'm not sure if this is your issue, but remember that in sdl (and most graphics libraries), (0,0) is the top-left corner and increasing the y coordinate goes down. So to jump, you actually want to decrease the y value.

It could also be that you haven't implemented gravity yet. There are plenty of tutorials on this available in Turing Help. Don't worry that the examples are in Turing, the concepts still apply.

Author:  Shinobu [ Tue Dec 31, 2013 3:25 pm ]
Post subject:  Re: RE:[C++ Help] SDL Platformer Game

Insectoid @ December 30th 2013, 8:57 pm wrote:
I can't look at your code right now, so I'm not sure if this is your issue, but remember that in sdl (and most graphics libraries), (0,0) is the top-left corner and increasing the y coordinate goes down. So to jump, you actually want to decrease the y value.

It could also be that you haven't implemented gravity yet. There are plenty of tutorials on this available in Turing Help. Don't worry that the examples are in Turing, the concepts still apply.


Yup, I remember (0,0) is in the top left corner and increasing the y coordinate goes down.
I think I just didn't do the gravity properly. I'll look into that. Razz


: