Day 1 - Moving @


Sat down to start coding and ran into a bit of coder's block.  It took me a lot longer than I had anticipated to think through how I was going to structure the codebase, specifically the relationships between the UI console layer and the map layer.  The problem is, the UI needs a reference to the map to be able to display what is at every grid location, while (I expect) the map will need a reference to the UI to be able to trigger a message to the user from different points in the underlying logic.  In prior projects, I've handled this by storing both the map data and the UI objects in a static class that I can reference from anywhere, but (among other things) that makes it difficult to write good unit tests.

I'm sure there is an elegant solution to this problem already out there (maybe something involving event handlers?), and I'm sure that once I do figure it out that I'll be kicking myself for not thinking of it sooner.  For now, since I'm under a time constraint, I decided to just move forwards with giving the UI layer a reference to the map object.  If (or when) I get to the point of trying to message the user from deeper in the map code I'll have to tackle that problem then.

Once I got past that, I was able to make some decent progress!  I've currently got a basic UI with a small static map (just a box, really) that you can move the "@" character around with the arrow keys.  It will detect if the player is trying to move into a wall, and will stop instead of moving.  It's not that impressive yet, but it is the first big step.  I've also got unit tests written and working for the underlying map code, although I haven't tried to tackle unit testing the UI.

So far, I'm very pleased with my decision to use RogueSharp for a log of my game logic.  It has a lot of features in it that I had to write from scratch before, and it is pretty easy to use.  I'm also satisfied with using SunshineConsole for the front end, at least for now, but I am a little disappointed that it doesn't look like I natively have access to the full set of Unicode characters.  It is very easy to setup the basic use case of putting characters on a screen, and accepting user input, but it doesn't have any fancier functionality.  In the past, I've had good success with libtcod (although that needed some help to support Unicode as well), but libtcod doesn't support C# anymore, and I've had trouble even getting my old projects to work on my new laptop, which is why I'm branching out to something new.

That's all for now!  Tomorrow I'll get started on adding the ability to find letters in the maze to make a word, and see if I can tackle random level generation.  I'd also like to start moving a lot of the metadata (colors, characters, UI size) into a JSON data file to make it easier to tweak later on, but we shall see how far I get.

Get Word Hunt

Leave a comment

Log in with itch.io to leave a comment.