Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>First of all, do you really need the states to be modular? If you are planning to write an engine for a specific purpose, your states are likely to not change much and thus should probably be compiled as part of the engine itself.</p> <p>Having the states separated from the engine will add an additional layer of complexity and make the implementation trickier.</p> <p>The next issue is whether you want your engine to be a library which games link in order to use, or if the engine's source is dropped in a subfolder of the game, and compiled along with it.</p> <p>Your choices are:</p> <ul> <li>Compile the engine and the states as one library (perhaps a static one that you link your game against)</li> <li>Compile the engine as a static library and then compile states as shared objects that can be dynamically linked (That would fit the modular state option, but it would add a lot of complexity)</li> <li>Compile the whole Engine + Game into one big executable which eliminates the need for any library linking (But also makes the engine and the game more coupled)</li> </ul> <p><strong>In my opinion option 1 looks like the best.</strong></p> <p>With either options, I would keep the engine in its own sub-directory from the game. Your file structure so far looks pretty solid and you should stick to it.</p> <p>If you still choose to allow the game to define its own states, then you will want to go with option two and implement a few core states in your engine (perhaps something like INIT, MAIN_MENU, SHUT_DOWN) as well as something like a "plugin manager", which in this case will be responsible for registering the game's states with the game engine.</p> <p>Each state can then be compiled individually as a shared object (.so) and loaded dynamically when the game is loaded.</p> <p>As for Makefiles, it really depends on what you plan to use (CMake, GNU autotools, etc.)</p> <p>GNU Makefiles have a pretty simple syntax, but learning to use them well might be a bit tricky.</p> <p>They consist of targets which are defined like so:</p> <pre><code>default: gcc [...] all: gcc [...] gcc [...] &lt;...&gt; </code></pre> <p>The first target is the default target when make is called with no arguments I will not describe in depth how to use makefiles (for GNU Make: <a href="http://www.gnu.org/s/hello/manual/make/Introduction.html" rel="nofollow" title="intro to GNU Make">this link</a>)</p> <p>You should know that makefiles quickly become incredibly tedious to maintain and a solution like <a href="http://www.gnu.org/s/hello/manual/automake/Autotools-Introduction.html" rel="nofollow">autotools</a> is usually preferred.</p> <p>Note that autotools is a very big system consisting of many programs and can be quite time consuming to learn. If what you want to focus on is developing your game engine, I would strongly suggest using a project IDE like <a href="http://www.codeblocks.org/" rel="nofollow">Code::blocks</a> to do the code compiling and linking for you.</p> <p><strong>EDIT</strong></p> <p>In response to your edit, I would add the following:</p> <p>You seem to be very aware of where you are headed, which is the most important part. From what you said, you would be much better as having the game engine be it's own static library that your many games link against.</p> <p>Your engine would then provide an interface to register states which the games will use to say "Here's my state called <em>title</em>" and would later tell the engine "switch to the state called <em>title</em>" whenever it needs to.</p> <p>One thing you might want to consider is having a few basic states that all games must register (imposed by the engine itself).</p> <p>The engine would then be a project of its own, and game projects would simply have a copy of the engine library in <em>/lib</em> for example. You would then statically link the engine to your game at compile time.</p> <p>If you want more details on how you could go about structuring the state objects, let me know.</p> <hr>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload