Jump to content
  • Advertisement
Sign in to follow this  
  • entries
    5
  • comments
    2
  • views
    401

About this blog

The desire to get myself going on game development, modding, and other creative ventures has been a part of who I am ever since my parents sat a Commodore Vic-20 in front of me in the early 80s.  I suspect this longing is what brings many to sign up here on gamedev.net.  Whatever comes of taking this step into this community, I hope it will be a long and fruitful journey.  Follow along as I try my hands at a few simple 2D game projects!
 

Entries in this blog

 

Pong - Released!

Here it is - long awaited by nobody, haha! 😂 You can grab the source code and first release (1.5) over on my Github account. I'm planning one more entry in this blog series, focusing on the game states and game options.  Any feedback at all is welcomed and appreciated! Next up for me...  I looked around at various game-related frameworks, and liked what I saw with the SFML library.  As soon as I'm done with the final Pong video and blog entries, I'll be moving along to trying my hands at the classic "Snake" game using SFML.

rileyman

rileyman

 

Pong - Adding Game Modes

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...

rileyman

rileyman

 

Pong - Refactoring the Game State

Since my last blog entry, I've made several improvements to the collision detection against the ball and paddles.  I made a video explaining these improvements over on my Youtube channel:   Now I'd like to do something of an overhaul of the game state, making this Pong game much more my own.   So, what makes up a game of Pong?  Physically there is a ball, a left and right paddle, and a playing area.  There is also a more global game state, which currently only consists of the score.  As mentioned previously, I'd eventually like to add several game options, so those should be represented by our game state as well.  I'd also like to introduce the concept of a match, where there is a win condition and a state where the game pauses before playing a match. I also plan on changing up the co-ordinate system.  I'd like the center of the playing area to be at (0,0).  Each paddle's position will be at its center vertically; and along its collision plane horizontally.  Visually, I'd like to display the walls and out-of-bounds area, and make sure that the score is displayed above the playing area.  In the image below, the red lines won't actually be displayed in the game; they're just to illustrate the boundaries.   Match State vs. Client State Here I'm distinguishing between a single match, and the overall state of the game client.  A match starts when a key is pressed.  A match ends when one player reaches some score threshold.  The game client allows players to play multiple matches, pause the game, and eventually change the game options. Here's how I'll initially define a Pong Match State: Court Size Left Player (controls the left paddle, and has a current score) Right Player (controls the right paddle, and has a current score) Ball State And here's how I'll define the Pong Client State: Client Mode (an enumeration:  Waiting to Start, Playing a Match, Paused, or Match Won) Match State Total wins for each player There may eventually be additional game options represented, such as score threshold, ball speed, paddle size, and whether each player is being controlled by an AI.   Ball State The ball is controlled by the game at all times.  Its state consists of: Size (single dimension) Position Direction (expressed as a normalized 2D vector)   Paddle State Each paddle is controlled by a player, which may eventually be an AI.  Its state consists of: Size Side (an enumeration:  Left or Right) Position   Ball Movement Result If you following along with the aforementioned Youtube video on collision detection, you may have caught on to one more improvement that could be made.  If you increase the ball speed, it's possible that the ball could hit both a top or bottom wall, and one of the paddles, in the same frame.  This possibility isn't currently handled properly.  So as part of the restructuring, I'd also like to introduce the concept of a "ball movement result". A ball movement result consists of: List of collisions, in the order they occurred (can be empty) New Position Each collision consists of: Barrier Struck (an enumeration:  Top Wall, Bottom Wall, Left Paddle, Right Paddle) Percent of flight vector that the collision occurred X position of collision (if the barrier it struck was a wall) Y position of collision (if the barrier it struck was a paddle)   We have a Civic Holiday here in Canada today, so I hope to make good headway on the above before it's back to work tomorrow!  

rileyman

rileyman

 

Improvements to Good Old Pong

In my last post, I mentioned I followed along with a tutorial showing how to build a basic game of Pong.  This is what it looks like: And the source code is over on my Github account: https://github.com/ryantherileyman/riley-basic-games I followed the tutorial with very little changes.  But here are some things that came to mind while seeing it come together: Game Loops I won't be making any changes here, but the use of FreeGlut and an "update" timer callback made me think about game loops in general.  I likely would have just made a "while ( gameActive )" type of loop if left to my own devices.  Here's an interesting article I found on the subject: http://gameprogrammingpatterns.com/game-loop.html Lots of Global Variables My instincts are to avoid global variables, and find ways to encapsulate program data into some kind of structure.  So among my enhancements will be splitting up the game state to make things a bit more flexible. Paddles Away! The players can move their paddles off screen.  Let's get some collision detection on those. Balls Away! That sounds a little inappropriate...  But the collision detection on the ball allows it to go a little off-screen before it bounces.  Let's fix that. No Game Mode or Game Options There is no "press a key to start" screen, no menu, and no game options.  Let's add a few of these to make it more interesting, such as paddle length and ball speed. Computer Opponent One of the options should be to allow a computer opponent, hopefully with a few difficulty levels as an option. Something Fun I don't want to take Pong too far before I move onto something else, so I'll limit myself to just one "fun" thing to add to the game.  I'll let it be a surprise.  My plan is that a week or so from now, I'll already be on to the next basic game idea. My next entry will cover the above changes.

rileyman

rileyman

 

It Starts Here

Apparently I also need to shake off the gamedev.net blogging rust...  I thought I was putting up a single blog post, but it was just a description for a blog series. 😏  So anyway, here's where it will all begin... My need to get creative has been reasonably satiated by video editing and Youtube projects for the past few years.  But game development of some kind is always in the back of my mind.  So a few days ago I hopped onto a search engine to find game development communities, tutorials, and anything related that would give me a little push in this direction.  I came across an article here on this site with some very reasonable advice: https://www.gamedev.net/articles/programming/general-and-gameplay-programming/your-first-step-to-game-development-starts-here-r2976 So I took note of the old version of Microsoft Visual Studio I'd installed years ago, and immediately upgraded to the 2019 version.  Then I found a simple tutorial on noobtuts.com for the first game mentioned, Pong, and whipped through it.  Feels good to see something come together, even if it's done in the simplest possible way (hello there, global variables). While I'm here, I figure I may as well document my progress in getting myself back on the game development bandwagon, even if it's just as a hobbiest.  Who knows, maybe some of you will take note, get your own inspiration, pass along advice, or exchange thoughts and ideas that help us both. Some things I stumbled on briefly as I shook off the rust: Visual Studio's concept of Solutions and Projects is not what I'm most familiar with, as I primarily code in Eclipse at my workplace.  A "Solution" is sort of just a container of related Projects.  The folder structure it produces when you create a new empty project is a bit overwhelming at first (Pong/Pong/Pong -- really?).  For anyone new, I recommend just creating a new "MyFirst" test project, and taking note of where it's putting everything. The "Pong" tutorial I followed had an include for "stdafx.h", which I confess threw me for a loop for a moment.  This is a common filename for precompiled headers, but when I created my project, Visual Studio had precompiled headers turned off by default.  For a really small project, it isn't really needed.  The idea behind it is to vastly speed up build times.  Use it if you're referencing large header files from existing APIs, such as Windows.h. Getting things hooked up with Github was rather easy.  My account there had been dormant for some time, but no longer!  What I did was create a mock project first, and just take note of the .gitattributes and .gitignore files Visual Studio created.  Then I cloned the new Github repository I created where I wanted it on my file system, and created the new Pong project in a sub-folder there.  I wanted all my "basic games" development in one repo. The version of Pong I built was just the result of following along with the aforementioned tutorial.  There are a lot of things about the coding style that I'd like to change, and a few little enhancements I'd like to make.  I think my next post will detail that -- though I do want to move forward to other more interesting game ideas soon...

rileyman

rileyman

Sign in to follow this  
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!