Tuesday, June 12, 2007

General purpose

While my tile class is not finished, it is finished enough for what Coffee Quest Revenge needs. To be perfectly honest, I have probably spent more time on the tile system then was needed. I could probably have gotten away without having a tile class and having a fairly simple map class (what I am working on this week, or at least will be working on Thursday through Saturday). I am writing a more elaborate class for both maps and tiles. The reason being is that these classes have uses with a large variety of games so having general purpose classes will allow me to use these classes with many additional games in the future. The obvious advantage is that once the work is done, the work does not have to be re-created for slightly different versions used in future games. While cut and paste coding can also be used to gain this advantage, it is probably better to have a proper set of classes. The key disadvantages to creating general purpose classes is the extra time required, the speed, and the overhead.

Obviously, if you are creating a class that is going to be used for a very specific thing, you only need to write the code necessary to do the particular thing that is needed. When you are creating a general purpose class, you have to take into account all sorts of uses for the class. This takes time to figure out and time to implement. Of course, nobody says that the whole class needs to be implemented, so only the functions that Coffee Quest Revenge needs have been implemented, with a todo list of additional functions that can be added when they are needed, so the time requirements are not as bad as they could have been.

Speed is another issue and is one reason may game developers, especially in the early days, would avoid using common libraries. Because you are doing things in a more general way, there is less code optimization and shortcuts that can be taken. This means that overall, the common libraries will run slower than something that was written for a specific purpose. In the old days, this could have a significant impact on a game. With the speed of today's computers, this is much less of an issue.

Finally, there is some overhead in getting the general purpose classes to work the way you need them to. In the case of Coffee Quest Revenge, the tileset used is pretty hard set so could have easily been hard coded into the game. Other CQFS engine games will not be so lucky and need to have much more flexible tile sets. This means that Coffee Quest Revenge needs to set up the tileset information to use the common classes even though this work could have been avoided if I would have wrote special purpose code for handling the map.

One final note. I have plans for Wednesday night so won't be getting any work on CQR done. This means that the second build will be delayed another week, though I will be putting in my ten hours on Thursday night, Friday night, and Saturday with hopes that I don't fall behind in my ten hour commitment again. This also means that I will not be posting tomorrow, but will try to post Thursday evening.

No comments: