Wednesday, April 6, 2011

Wumpus planning 4

I got some good advice on how to divvy up the program responsibilities.

Let's say I started with the map data structure. Would I define it in a header file, or in a separate .c file? I rather imagine I'd put it in a header file. I don't have a particular preference, really.

I got some decent practice dealing with keeping functions in different .c files (really the trick is in the main .c file including the function prototype) and being able to see variables (extern) from .c file to .c file. I don't have all the trickier cases hashed out but I haven't had any real problems yet.

I'll try to stick to the Model/View/Controller paradigm that Matt tuned me into. I wonder how that would have helped me with the .plx reader? It certainly would have helped to keep the file reading functions away from the display functions. In fact the reader could have just done the right thing and dumped the data to allocated memory for whatever visualization function to deal with later.

I think this is a good plan, but the specifics of what goes where need to be nailed down. The map itself (static, non-moving parts anyways) will go in one function, and the player, bat, and Wumpus can go in another structure. A few posts ago I had them all in the same structure, but the map structure is going to get a bit more involved because I want it to contain pointers to the rooms it connects to (instead of assuming linearity). Saying "check if the room the player form this struct is has a swamp against the room in this struct" should be easy enough. I dunno - might think on that a bit more.

In the meantime I for real need to get banging on GTK a bit more so that I can get a UI going.

No comments:

Post a Comment