I am still writing on my game. But I habe come to a problem where I don't know right now how to solve it. Basically it is a platform game. Everything works so far good but I need to limit the jump hight of the player. But I don't really now right now how to do this. Maybe you can give me a hint?
I know that but the problem is that the platforms have different hights. So he needs to be able to jump at each block like 10 point up. Oh and it is set in an different function back to true.
Also, I would personally not use '== true' and '==false'. If you write 'if(playerH.isOnGround)' this is the same as 'if(playerH.isOnGround == true', and 'if(!playerH.isOnGround)' is the same as 'if(playerH.isOnGround == false)'. The workings are the same, it just looks better.
I used 'playerH.vy++' which is the same as 'playerH.vy += 1;'
@Kelevra: First of all, does your player class hold all of it's variables as either floats or doubles? (as opposed to ints)
Second: if you are having trouble with what you think is absolutely true, run the program through your debugger. Step through the program at specific key breakpoints and you will see where the error is.
Third: Don't use friction as a multiplier. If you have the ability, make it a constant.
Fourth, it looks like you don't have persistent velocity, is that true?
Ok a while ago I wondered the same thing and I came up with this idea:
What if you had two bounding boxes around the floor? The first one would keep you falling through and the second one would go as high above the floor as you wanted the player to be able to jump. Then when the player presses the jump key AND he is in the jump box he will go up. When he gets out of the jumpbox has_jumped is set to true until he touches the floor bounding box again.
Thank you very much for your code. I rewrote it so that it works very well for my jumping but I still have the problem of the double jump. I thought that I would set a boolean to false if the key is released so that pressing space isn't accepted by the game until the player reaches the ground. But there is no way with keystates to tell if the player released the space key. So maybe somebody of you has an idea for that.
But thanks a lot so far!