On 10/2/2019 at 12:58 PM, Prototype said:
You're moving in the right direction, Phil
Agreed. This feels much better, with the start of logical groupings. Emphasis could be put back on managing state as @Prototype suggests with the onGround variable. One design here would be a controller(manager) for your objects that makes per frame pre-defined checks. Another design would be the object adjusts state based on it's own data (closer to what you seem to be trying to do). As your game systems mature, it becomes a mix. Although I understand that, case in point is currently a logic error, I though it might be positive to lean the discussion to overall design first instead of our pattern of one little piece missing. I also like that @phil67rpg is trying to make better descriptions. During your posts, spend some more time on expressing your things as @Rutin suggests. A lot more words. Don't worry if what you write is wrong. I think that would do two things. One, you may answer your own question in the process of trying to describe it completely (at which point the programmer in you can bloom) or the other, where we'll see where you are failing quicker.
With that said, the glut thing...I can understand the draw to this being also from the era. A few great frameworks (like the old F. Luna stuff) used it and probably survived time to be picked up again and again. I didn't because I was anti-everything back then but have tried more than a handful of the options. GLFW I liked, but I timed it against a raw OGL startup and doing input handling with the same ~80,000 vertices or so test (hmp...something) and it was measurably working harder (~15-20+%) somewhere in GLFW. Easy to get up and going with. SFML was okay, I'm not sure I gave it a fair chance. Currently I'm using SDL which is interesting if you like gluing together libraries as I do. Those are my C++ choices. For C#, I reach for monogame or Unity for fun. GoDot is the next on my list but runs funny on my (much) older system, so that fun is waiting for an upgrade.
edit;p I thought I might add one last thing...perhaps you might consider tracking your distance off the ground and doing a hard reaction/reset crossing zero..that might be interesting info. Also when i jump, all I do is give my object thing an impulse. (in whatever direction) fire it. forget it. All my dynamic objects, all the time, have a downward attraction. The fight then becomes when you are on the ground (falling through or wiggle with extreme purpose or better yet, do nothing at all)
Then again...a dozen more approaches are valid.
if (button == GLUT_LEFT_BUTTON && state == GLUT_DOWN &&
key_jump == false && onGround == true) // <-- and allow this state
{
// fire the jump impulse action here and forget it
key_jump = true;
}