Wednesday, 17 February 2010

HS: Neoforce and variable rate game clock

Implementing the game clock was really very easy. I just have a class with an internal DateTime that has its ticks incremented by gameTime * timeRate, where time rate is set by one of the Neoforce buttons in the top left of the screen:


I initially subclassed Neoforce.Button, because I couldn't see how to otherwise pass custom data into the button click. I don't think I've really worked it out properly now, either, but I am now using the "Tag" property, both for this and for game difficulty selection:


Pushing the 'new game' button toggles the dialog box open and closed. Annoyingly, the Dialog box comes with default caption and description set, and it took me a while to figure out that you need to do dialog.TopPanel.Description.Text to access (and remove) it, despite C# allowing you to make string assignments to dialog.TopPanel.Description.

Anothing thing to note is that when a dialog is closed, it is not removed, simply marked as visible=false - which was exactly what I wanted, since I wanted the ability to bring it back easily. But I can see how it might not be everyone's preferred choice. Presumably to remove it entirely you need to remove it from the Neoforce Manager.

Finally, the background image for the start screen was taken from here. I am always grateful that so many people make their flickr photos CC-Attribution licensed. You can see that the photographer is credited on my start screen, too.

No comments:

Post a Comment