I haven't coded in a long time, due to various reasons.. Free time / interest being the main sticking points. But I want to try and get things going again. I am trying to get started with some very basic work, as I have decided that if I am going to do anything reasonable, I need reasonable short-term goals.
Mainly my previous work consisted of prototyping a development tool for myself, using ProGUI, but I want to put that aside for the moment.
The first thing I want to do is get the basic engine for the game setup, which means doing the "rendering" (for lack of a better term) first.
Since I'm working on a text game, there is really nothing to "render", but I'm misappropriating the term anyway.. My current short-term goal is to design an implement the necesarry systems for the user to "load" the game. Meaning basic interaction with the database to display the game rooms and navigate through them.
As part of that goal, I got to thinking about the Engine as a whole. I don't really want to put myself in the situation of building the game in a few dozen files (as well structured as they may be) and then having to go back and extrapolate the Engine out of them..
But I realize I have little idea how to design an Engine, or how the process is supposed to work. I know there are half a dozen ways, but the reading I do rarely translates into productive ideas / results I can actually use. I figure it is best to start with the "Interface" or something like that.. Basically I want to decouple the engine from the GUI as much as possible, and use communication facilitating processes to allow the main program, and various sub-processes to communicate with each other, as well as talk with some form of universal input, and return output in a format I can universally adapt to whatever I want to do..
I'm not sure how to do that though.. I have little idea how to accomplish "passing" data and variables between functions in a simple to understand way (pointers??? ugh...).
In terms of how I see it working. Let's say I have a couple different "layers". An "I/O Layer" which basically takes input send from the command bar in the GUI, and returns output to the screen in response (but also outputs as a result of internal game events). The GUI sends its input to some kind of listener, and it decides where to dispatch it to from there (command parser, that one is easy enough). But lets say a creature decides to attack - how does it initiate an attack routine and what is it attacking? An NPC decides to walk North - how does it tell the game to move it?
Once that is done, if output is required (Tell the GUI to print the result of the Monster attacking the player, or if the player is in the room with the NPC, print "NPC walks away, moving north." etc)
Basically I need to come up with some kind of internal communications method, that doesn't involve writing some elaborate scripting language or anything complex like that.
If anyone can help with example is how this might be done, it would really help me out.. Hopefully it doesn't need to be anything complex, just something basic I can get an idea from and implement in my own way. I am guessing examples of easy, clean, ways of passing data between Procedures and stuff like that is going to be involved? Or can I do something different like user sockets locally on the machine? (i.e a "Fake" server/client interface?)
Here is a crude example, I guess?
Code: Select all
[GUI] -Player inputs command "Attack Orc"
[GUI] sends input string to command parser
[Parser] -Ok I have recognized an "attack" command, with a target of "orc"
[Parser] sends notification to listener "run the "attack" procedure on target "orc"
[Attack Procedure] -I got a message to attack target "orc"! OK
[Attack Procedure] Runs, verifies target is attackable, runs calculations and needs to return output
[Attack Procedure] sends output result of the attack command to GUI
[GUI] - I just received input from the game!
[GUI] Prints (formatted/parsed) output to screen