Today I had a good deal of time to play around with stuff, but have very little to show for it.
Until now, the maps/rooms have all been hard-coded into the game or randomly-generated. I need to be able to edit the entire world map (and submaps) with an editor of some sort, so it was necessary to break away from the hard-coded stuff and let the game read in an external file.
This isn’t a tough task for regular C# stuff, in fact, this is partly why I did my EarthBound Reshuffler – as a way to learn how to deal with file I/O.
The thing is, if I ever wanted to release this game on something like Xbox Indie Games or other such things, you aren’t permitted to read or write external files (except for save data I assume). Instead, you’re expected to use the XNA content pipeline, which apparently makes things more secure.
The problem with THIS is that if you have a custom data format (like I do, with this map data stuff) then you have to jump through a lot of hoops to make it work. Luckily, I was able to get the hang of it, and although it’s a bit annoying to work with (no multi-dimensional arrays allowed? BOO) I got my game to load the entire world map data through an XML file.
That just leaves the ugly part – actually finding a way to edit the map. I spent most of my time trying out a handful of different tile/map editors, but they all had their problems in various ways. The biggest problem of all was that none of them generated map files anywhere similar to what I needed.
So, with a heavy heart, I accepted my fate and decided to try to write my own map editor. I should say that I absolutely HATE programming Windows stuff. I mean, REALLY hate.
I say it because I’ve tried many times to get the hang of it, always able to make something shoddy but never really knowing WTF I’m actually doing. So I was already tearing my hair out.
I’m sure if you’re a pro and have lots of experience, programming Windows stuff isn’t THAT hard. But trying to get into it every few years, there’s always a completely new library or framework to use, with tons of stuff that just go woosh, right over your head. And the documentation is horrible in trying to explain how everything is supposed to work together.
So I basically found myself just going like, “Okay, I know I need to do something like X. But how the hell do I go about that?” Then I’d have to Google around and scour all kinds of places just to get the info I need. Nothing straightforward at all. EVERY LITTLE THING had to be done this way: want to know the coordinates where the mouse clicked? Too bad, you gotta figure that out yourself, and all the message boards are wrong. Want to know how to draw a simple bitmap image? Too bad, you have to learn 50 new things first, including multi-threaded programming constructs. ARGH
Still, after getting past a small part of the learning curve I currently have the bare bones for a map editor for my game. It’s not much to look at, and it currently only poops red rectangles, but it lets you scroll around and resize the window and everything.
It’s not much, but I will say that I never, ever would’ve been able to do this back in the MFC days. WPF is definitely nicer, but Windows programming is truly for the insane.