10/21/09

The first step is always the toughest

Well, I'm finally off and running on my game project. I've decided to create a Tetris clone, because I don't want to deal with any major game design, I just want to create a well polished game. A Tetris clone will let me do that since there are already well established game rules for Tetris allowing me to focus more on programming than game design.

My first step for creating this game was to set up a new solution/project in visual studio and get an app that simply creates a window and draws a blank screen using directX. I've always had problems starting a game project and this one is no exception. Figuring out which libraries need to be linked and what properties need to be set for each project has always given me fits.

I'm trying to create a solution where most of the base game functionality is stored in one project, while the game specific stuff is stored in another project. This was the source of most of my frustration. I've never created a multi project C++ solution before, so I was getting linker errors all over the place when I was trying to use a class from GameBase in my TestrisClone Project. After much research I figured how to get the two projects to play nice:
  1. Make sure the base project outputs a .lib and not a .exe. To do this right click on the project and select properties. Go to Configuration Properties -> General -> Configuration Type and change it to Static Library (.lib)
  2. Now you need to tell the game project where the base project is so it can include the headers. Right click on the game project and select properties. Go to Configuration Properties -> C/C++ -> General -> Additional Include Directories and add the directory that contains the files you want to include, in my case ..\GameBase
  3. You also need to point the game project to the game base library. Open the properties again for the game project and go to Configuration Properties -> Linker -> General -> Additional Library Directories and enter in the directory where the .lib file is created, in my case it was $(OutDir)
  4. Finally you need to set up the solution project dependencies so that the projects build in the correct order. To do that, right click the game project and select Project Dependencies. Select the GameBase project as a project that the game project depends on. Now the GameBase project will always build before the game project
With that all finally set up (which took me about 4 hours), I was finally able to do some actual work. Actually I did a lot of copy/paste from the DirectX CreateDevice sample for creating the window and initializing the directX device. I now have a app that simply opens a window and draws it blue. As simple as it is, I can't tell you how happy I was to see it! There really is no better feeling than when you get something working that you have been frustratingly working on for way longer than you thought it should have taken.


My next goal of the project is to get a process manager created where all the game logic will be managed.

No comments:

Post a Comment