Part 2 of the Pong game development video series is over on my Youtube channel:
I'm reasonably satisfied with the refactoring pass. I considered moving initialization of the window into the "GameClient" class as well, but wasn't sure how that would play with FreeGlut's use of callback functions.
In the meantime, I've been making my way through adding the game states:
- Adding a "Press ENTER to Start" screen.
- Ability to pause.
- Adding a "Match Won" screen after a player reaches 10 points.
The only thing worth noting while working on these items is related to keyboard input. Prior to this, I'd just been using the GetAsyncKeyState function, which is a Windows-specific function. It's useful if all you want to know is whether a particular key is currently being pressed down. The documentation warns against using it to tell if the key has been pressed since the last time the function was called, as it's not local to the currently-running application or window.
I hadn't used FreeGlut prior to this, so I was curious if it had its own keyboard functionality. Lo and behold, you can set up callback functions with glutKeyboardFunc and glutSpecialFunc. So I'll be using those for toggling between the Pause screen.
After I've done the game states, I'll start adding some game options:
- Paddle size
- Ball speed
- Computer-controlled paddles
I'll be keeping track of my progress as I go using the Issues feature over on my GitHub account!
I do really hope to be done with Pong by the end of next weekend, as I've been brainstorming a ton about my next mini-project...