Hello again everyone! I think it’s time for another installment of “From the Programmer’s Den.” Remember that as you’re playing Pork please send all your thoughts, suggestions, constructive criticisms, and bugs to firstname.lastname@example.org! Pork may be crude as hell now, but with time and work it can become far better! Now on to the story…
PART TWO — The Game Engine
Before I could begin building the code that ran the engine, I had to set up some classes to represent significant things in the game (e.g. maps, items). I started with maps and decided to give each one possible directions that could be traveled to from the map and of course its name and description. At first I wanted to create a flag system that would tell the program what directions could and couldn’t be traveled in, but I soon figured out that it would not work. With little pieces being put in at a time to test the classes themselves I finally pieced together how I wanted the Pork Definition Format (.pmf files) structured. It was here that I devised the most integral part of Pork, the ID’s given to maps and items. With these IDs I could much more easily manipulate specific items and maps with a single function for each. I also solved my directionals problem with my maps: each direction would have a number and that number would specify the map ID that was in that direction, and 0 meaning that direction could not be traveled.
The engine was more or less pretty easy to design (although the file-parsing bits are arduous sometimes). I was putting in more and more commands that could be used to interact with the game and it was coming along nicely. There is not much to really talk about with the game engine aside from a few caveats that consistently annoy me (which I will now detail).
One of the most annoying aspects of my game engine is textual input. Currently, Pork uses the std::cin buffer to take all text. With std::cin extraction (std::cin >> blah;), spaces separate parts of the command with no exceptions. std::cin extraction is by far the easiest to manage; however, it causes glaring issues with things like multi-word item names (red rock, gray stone, dead elvis, rotten potato). Users must currently put in item names as such: DeadElvis, RedRock. To me, this is absolutely unacceptable and annoying. I would prefer that the game not have to rely on std::cin extraction like this and I’m trying to come up with alternatives.
The second thing that irks me about my engine is the Pork Definition Format. The PDF is extremely finicky and requires everything to be exact or there will be poor parsing results. It is also very difficult for me to add in new features. Everything must be in an exact order and it is very easy to screw things up. I have no doubt that it confuses anyone who attempts to mod the game. It is not the worst thing in the world, but it is pretty bad. What I think would be really cool is a scripting format. Some sort of code that can be in any order, doesn’t care about whitespace, easy to manage, and easy to add on to. Creating a structure for this is easy, but creating a parser is not. I would like to make it my next project in order to open up what can be done with Pork. The PDF limits Pork’s abilities and needs to be improved. For example, if I wanted to make an ‘eat’ command, I would have to create some sort of line that would be added on to the PDF (and at this point it would have to be optional, giving more work to the parser). The more commands I would want to add, the more the parser has to do, the more convoluted my C++ code gets, the more convoluted the PDF gets, and it all spirals down from there. Currently, I’m thinking of a new parser and scripting format that would work far better. If we want Pork to become infinitely versatile, the PDF MUST GO.
Well, I know that kind of just completely spun in a different direction, but there isn’t much in Pork to detail, as it’s quite cut and dry (except for the glaring issues)! I apologize for that, by the way. 😛 But now you know my pain and how I want to fix it. And hey, it could have been worse. I had half a mind to discuss how (with examples) I wanted my new scripting format to work! So, until next time (if there’s going to be one 😛 ), have a good [place time of day here]!