Tuesday, July 4, 2017

Almost There!

Another couple of months have gone by, and while they've gotten busier and busier as spring has turned to summer, I've been able to make another good bit of progress on Pongquetball, including something that I've really been looking forward to doing! In keeping with tradition, here's my changelog:
  • Only change the color of the ball when it hits the inward facing sides of the paddles
    There's not much I need to say about this. I just wanted to refine the way the color changes a bit. No need to change it when the ball is just going to go out of bounds anyway.
  • Make the ball appear above the score text (and other elements) instead of underneath
  • Display the high score on the title screen
  • Add a menu on the title screen to choose between a 1- or 2-player game and to reset the high score
  • Some general code cleanup
    This needed done for a while. I had some random numbers scattered throughout the code with no apparent meaning to them, so I assigned them to variables so they had meaning and weren't repeated. Also, I eliminated a few boolean variables and replaced them with a GameState variable, which is used to keep track of whether the game is at the title screen, is paused briefly just before starting, is actually running, or is paused. Doing that definitely helped make some parts of my code a bit cleaner and easier to read, and it just makes more sense.
  • And finally, the big one: TWO PLAYER MODE!
    This has been on my mind for a while, as a goal that I really wanted to work toward. So I was so happy when I finally got to it. Some of it was fairly simple, such as removing the left wall and replacing it with another paddle. All of the code needed for it to work correctly was simply copied from the code for the right paddle and modified slightly whenever necessary.

    Beyond the paddle, I also added a dotted line down the center, because come on, it's not proper pong without it, lol! The line actually took me a few tries to get right when I was creating it in Pyxel Edit. I couldn't quite get my math right for the correct number of black and white sections and the proper (in my mind, at least) height for them. Eventually I was able to figure out that the problem was the fact that I was trying to make it only as tall as it needed to be; i.e., the height between the top and bottom walls. The solution was to make it as tall as the entire window, which means that most of the very top and bottom "dots" in the line are actually *in* the top and bottom walls. It's a little weird, but hey, it works!

    Now, you can't play a proper two-player game of pong without keeping score, right? So I also had to add in proper point scoring, rather than keeping track of time like a single player game. And I went ahead and limited two player games to a maximum of 10 points.

    The last thing I did was to modify how the ball changes color for two-player games. Rather than being random, I just assigned a color to each side, and the color changes back and forth as the ball is hit back and forth. This was suggested by a friend, and I think it's a nice little touch. :)

Check it out! :D

So, I'm down to the last few changes I want to make to this game before I put it down. I want to add some simple sounds, remove the incomplete controller support it currently has (it just feels unnecessary to me now), and redo the "Paused" and "Game Over" messages so that they aren't obscured by the dotted line in two-player games. I also have a couple obscure bugs that I may work on for a bit, depending on how I'm feeling at the time. :)

That's all for now. Time to go finish this up and move on!

No comments:

Post a Comment