Pages

Tuesday, March 13, 2012

Factory Simulator

     Last time I mentioned that I was writing a game in C++ using the graphics library Simple DirectMedia Layer (SDL). The goal in writing this game is to practice C++ and explore some of the popular C++ libraries available.

     I discovered that SDL has many similarities to XNA and was not difficult to learn. I was able to start making my game within about an hour or two of learning SDL basics.

     I decided to make a simulation game, similar to games like SimCity, since this is a style of game that I enjoyed when I was younger but most of my favorite series have since become discontinued. I came up with an interesting idea for a factory simulator where the player owns a factory and must manage the happiness of the workers. Then I broke the problem down in to the simplest parts so that I could plan to implement it in roughly two days.

     In my game the player can build three types of buildings: houses, power plants and factories. The houses produce workers, the power plants produce power and the factories produce money. Also, The factories can only produce money if they have enough workers and power.

     So far I have implemented everything I mentioned but will refrain from showing any pictures just yet since it is still mostly text based with a few placeholder graphics.

     I plan to extend this by giving factories different kinds of input and output resources, for example a paper factory might require wood as an input and produce paper as an output. By doing this I can create chains of resources that the player needs to manage, for example a logging camp is required to produce wood for the paper factory. Also, since the game is about managing the workers happiness I need to keep track of the mood of each worker which will be affected by factors such as wages, safety, housing and environment.

     Overall I have enjoyed learning SDL and I think it is a useful graphics library. It handles most of the same aspects of drawing 2D sprites to the screen as XNA and has extension libraries for drawing text, handling input and playing music. To draw 3D graphics it is common to combine SDL with OpenGL which is something I may try in the future. In contrast to XNA, I have not yet figured out how to use pixel shaders but suspect that I may need to use OpenGL's GLSL shader language which I have heard is more complicated than XNA's HLSL.

     I plan to continue working on this game in, my free time, to practice my C++. If I get it to a more complete state I will post some pictures and videos in a future blog entry.

No comments:

Post a Comment