Monday, March 10, 2014

Game 1, Week 1

Well, I finished the game. I need to do a better job with my deadlines since I targetted last night a midnight, but I just got it done. This is in part due to 3 deadlines I had for work/school this last week, but it's all good!

The first game is finished. As mentioned previously, I wanted to start out simple. I created a Columns clone.  Columns was a game like Tetris where a block of 3 colors falls down from the top of the board.  The player can rotate the colors as they fall and move them to place them where they want.  Colors that line up in 3+ succession in vertical, diagonal, or horizontal will be broken.  Then the blocks above those are shifted down, and any new blocks that line up will be broken again.  This is the simplest possible configuration. For my stretch goal, I wanted to add power-ups much like in Yahoo! Towers, but I never reached that point.

The game currently has a board, pieces that fall, a high score, a current score, and a game over component.  The entire game was completed using SDL, OpenGL, and the SDL_ttf (for text display) libraries.  Everything else was done from scratch.  It was great to get into SDL, and since I haven't done much with text + OpenGL combinations, it was nice to refresh myself and see how tricky these things can truly be.

Issues

Even with a simple project like this, a number of issues came up which I'll need to be weary of in the future.  The foremost being text display. I used SDL_ttf which is a wrapper to a TrueType Font library.  You can write text directly into an SDL surface (which you can think of as an image buffer with formatting, etc.  Much like a GL/D3D texture in software, and in fact I use surfaces as intermediaries to hardware textures).  I think upload this texture to a GL hardware texture and display it as a quad on the screen.  There are a number of other ways to do it which I'll look into in the future (http://en.wikibooks.org/wiki/OpenGL_Programming/Modern_OpenGL_Tutorial_Text_Rendering_01), (http://www.opengl.org/archives/resources/features/fontsurvey/).

Another issue I will need to code for is animations. I'll have to survey different game engines to see how they handle animations (seperate thread, how to block other components, etc).  I wanted to have a simple animation of the blocks breaking when they are eliminated, but I didn't have the time. For now, everything happens instantaneously.

Menus will also need to be added.  I will need to create a library myself for this or resort to using something like QT ( but I'd rather do it myself at this point since I'm building on previous work each week).

I also had some issues with uploading SDL surface textures to hardware textures.  Primarily the issues were due to format conversion and flipping the SDL surface around for the hardware texture.

Postmortem

Although I didn't meat the stretch goals of power-ups and I didn't get any animations in there, I feel this succeeded in my first goal and is a good first GaW project.  I would have liked to have menus in there and I would have liked to have animations, but I do have the basic Columns functionality and a high-score system in place.  I'm looking forward to using SDL some more in the future.  For my OGL/C++ projects.

The scoring system just takes the number of blocks broken at once (including succession of breaks if a block shifts other blocks into a breaking patter) and squares the number and adds it to the score.

Summation:

Languages used: C++
Libraries used: SDL2, OpenGL, SDL_ttf (True type font library).
Code obtained for future projects:  Working with SDL surfaces, uploading to GPU, game loop.
Code to clean for future projects:
  1. Create a more generic game class for using in future projects.  Currently the game loop is kind of hard coded.  
  2. Create a more generic text-to-texture class to help with drawing text to the screen.
  3. Clean up some of the utility functions for manipulating textures.




No comments:

Post a Comment