|
|
Index: Home | What Is Izumi | Misc Links | Random Thoughts | Too Much To Read | The Rant Vault | Quotes Dev: Projects | Ideas For Dev | Nerdkill | Rig | Hint
They are all expandable.
Note: this is the development page Nerdkill C#, not to be confused with the Nerdkill C# home page.
Site License And Disclaimer as well as contact information are available here.
$Id: Nerdkill.izu,v 1.1 2005/11/05 21:55:57 ralf Exp $
Gameplay <=> Engine <=> Low-level
(glue) DD/DS
The "engine" is simply there to hide the low-level handling from the gameplay, in case it changes. So basically it's not much more than a glue or a passthru. Also it's a good place to store the state of the game (nerds, etc.)
Something like that:
+---------------------------------------------------+ | init -->--+ | | | | | gameplay engine low-level | | -------- --------- --------- | | | main loop <- control | | | <----- actions [] <- capture input (mouse) | | | <----> nerds [] -> render sprites | | | -----> sounds [] -> play | | | <----> stats -> display | | menus -> display | +---------------------------------------------------+
Later (added 20031102):
Architecture the main loop as a state buffer and a callback, instead of the traditional monolithic while loop. This way it's easier to adapt to a timer callback, or a thread, or a main app loop.
20030923
PlatformEngine:
PlatformGameplay:
The game will start with a menu, directly using a 2d renderer.
The main loop (platform) starts the game loop, inits the renderer, etc.
At the beginning on the platform, it should be possible to switch renderers at runtime, i.e. not a compile time.
Typically I may want to select the renderer depending on the hardware caps.
Later I may want to switch between a 2d or 3d rendering and gameplay at runtime.
Nerdkill C# 1.0 is almost finished and quite frankly the experiment is a success. OK the initial idea was to use to learn C# and F#. Currently it's all in C#. Using F# can be seen as milestone 2.
Milestone 1 had two goals: first recreate the nerdkill game, functional. And second write a descend architecture, relatively modular and self-explicit. These two goals are completed. This will detail more about the architecture and the methodology.
The methodology was more or less the following:
Some details:
Some things could be done better though:
A note on the storage of the game state: initially I wanted this to be in the engine.
The idea was that both the renderer and the gameplay would access let's say the list of nerds.
The problem is that means the renderer knows what the game is about. Instead the renderer should only know
about displaying a sprite or a list of sprites. It's up to the gameplay to know what kind of entities are
handled and then order the renderer to display some sprite at some location. The renderer must not have
any semantic associated with its sprites.
The same goes with sound: the resource module loads sounds and calls a method from the platform's sound class
(thru its generic interface) to actually allocate the sound buffer. All what is stored in the resource module
is an anonymous object. Later on the gameplay will ask the resource module for the sound description (some
kind of id) and pass to the sound player class for playback. The modules are truly independant: the sound player
has no knowledge of the semantic of the sound whilst the resource or the gameplay modules have no knowledge of
the structure of a sound.
DirectX uses a mechanism where resources are typically created in the associated device.
For example sprites are either stored in the graphic card or at least in a format compatible with it.
Same for the sound. That implies that creation of a sprite must be done by the platform specific class,
nor the generic resource module. Another important detail is that surfaces or buffers can be lost -- for example
when switching from fullscreen to windowed. That means that at some point during the game, the resources may have
to be reloaded.
Handling that situation is done in the engine main loop: the main loop will ask the renderer is the main surface
has been lost. If yes, it needs to put the main graphic loop on hold. When the surface is available again,
sprite resources need to be restored.
A side implication of that is that the gameplay cannot cache structures returned by the resource module
for a long term (but it can in the context of one frame loop). Each time a sprite is to be rendered, the
gameplay will grab the opaque sprite definition by its id from the resource module and transmit it as a
black box to the renderer.
Where do I go from now?
First finish and public the game. Two minor weapons are missing and there's no annoying bug left.
Next explorer using NUnits and F#, in parallel. I may not recode the full gameplay module using F# as I originally intended to but it should be interesting. One of the problems is that since I already have a C# module working, it is going to make it more challenging to think the way ML wants one to think. Rewriting the full gameplay module may be just too much, instead I'd like to have a mix/match of C# and F# working on the same data structures, and maybe limit the F# code to a couple of key algorithms like handling the state of the nerds.
Next, or rather in parallel, explorer NUnits to add non-regression testing to the game. Given the simplicity of Nerdkill that may seem unecessary. But on the other hand, that means it shouldn't be too difficult so why not doing it, right? Regression testing for the engine and the gameplay seems like a good thing, whereas for platform or renderer that may be less obvious.
20031108
I did explore separating the current engine in several DLLs.
That did not work very well. There are many problems here:
Obviously to be able to produce real DLLs I need some modifications:
20031111
Real modules have been created. Each module is now a sub C# project.
A "core" module was added, to contain the former main loop and engine loop.
The engine module now refers to the engine interfaces, the engine constants and some minor structs (REvent f.ex.).
Also started adding some NUnit testing, as a test.
|
|

This work is licensed by Raphaël Moll under a Creative Commons License.
|
|
| Color Theme: | Gray | Blue | Black | Sand | Khaki | Egg | None |
|
|
|
|