Wannabe Developer Diary 23-09-2010

xml-data-loading.png

I had to overcome some serious hurdles today. The biggest was my state of mind. Exhausted after a short bike ride and irritated at the new neighbours who are on the roof constantly and don’t care who they disturb, even at this hour, I sat down in front of the machine finally at around 8ish. I didn’t make any headway until 9 when I decided that I wasn’t going to play Call of Duty, I wasn’t going to mope, and despite feeling nauseous, I wasn’t going to take the easy option.

I knuckled down and I got stuck into the room loading XML code.

I had to learn quite a few little things today, and in aiming for full room-display using my Blocks class, I almost overshot. I should have been happy at getting the basic roomdata.xml file parsed correctly. That was a big achievement. I wanted more. So I went for Block storing (didn’t quite pull off the STL list, bodged it with the usual C array code nonsense) and then Block display.

As you can see from the extra blocks, some pink, some blue as well as grey, I’m now loading, parsing and displaying roomdata correctly. This is a breakthrough that I expected would take a few days. I’m very happy.

It’s late, I’ve been unwell all evening, I’m exhausted, but I’m exhilarated. That’s a lot of progress in one evening.

XML files successfully read

Screen shot 2010-09-05 at 02.30.16.png

One of the things I used to enjoy about coding was removing “crutches”. Allow me to explain.

Crutches are constants you use to put together a working demo. At some point, these constants need to be replaced with real data, loaded at run-time and editable outside the code.

I’ve just got rid of the first of the crutches. And those were the room width, depth and height constants, which are now being read out of an XML file. I’m also being sensible and sending more status output to the debug console. When I used to code in the early to mid 90s, I got my team to use an awful lot of assertions. I’m not sure how I feel about those, or exceptions now. It’s probably useful (I learned the method from McConnell’s seminal “Writing Solid Code” of course). Assertions really do make the code look a mess, but they are very useful and catch a lot of bugs.

What methods do you use nowadays to code defensively?

Room Data

Screen shot 2010-09-05 at 01.29.51.png

I can’t run away from this, it’s time to stick some data in and make it work as a little puzzle world. In the old days, I just had a bunch of bytes. You’ll recall that I wrote the map data in by hand. Well that won’t cut it in the 21st century and the biggest reason for that is not because it’s the quickest way – it is actually quicker to do it by hand and not have to write any code. It’s the best way because if you don’t get it right first time, and you certainly won’t, then you need a tool that doesn’t force you back to the drawing board every time. You need a map editor or room editor that is actually part of the game so that you, or a game designer, or a tester, can make tweaks and changes until you’ve got the playability, challenge, difficulty and surprise just right.

I’ve managed to successfully add the XML addon to openFrameworks (not a challenge for a decent programmer at all, and not a challenge even for me, apart from having to overcome the usual inertia, the temptations offered by distraction, the constant shooting, agonising pain of diabetic neuropathy I get in my feet, my hands and other parts of the body and the incorrect self-image I have of not being able to do this. I can do this, God willing, and I damn well will do it.

I know it looks like I haven’t got much yet, but this is more progress than I’ve made in a while, I’m winning the internal battle and I am determined to see this through. If you’re still with me, if you’re still reading, please, send your friends here and give me all the encouragement I can get. This is a much bigger personal challenge than I’m disclosing.

(Oh, yesterday was a day off, thus no work then)

 

Room Editor

chimera-map.gif

The last Room Editor I wrote was on the Atari 800XL in 1984. It could be used with an Atari Touch Tablet and saved and loaded room data files from floppy disk. It was the quickest way of getting room data made for “room” based games like Jet Set Willy. The Touch Tablet I’m using now is called a Magic Trackpad and it’s by Apple. Obviously, the resolution and functionality is worlds apart.

I’d written Jet Set Willy on the Commodore 64 the year before Chimera and towards the end of 1984 I was wondering whether I was finished in video games or not. I did a game with a friend called “Baby Starts Walking” on the Commodore 64. My friend did most of the graphics and room design, I took the code I’d written for Jet Set Willy and cleaned it up a bit. Before we’d quite finished and before we’d had a chance to create any enemy sprites, we decided to try and sell the game.

I won’t say where we took it, but we were offered £3000 and turned it down. Daft really, we should have taken the money and moved on. Instead I carried on playing video games, having already pretty much dropped out of school. Chimera was my last chance saloon. Having started in 1983, 27 years later, here I still am.

So the Room Editor I need to write now needs to have the following characteristics and properties:

1) Allow me “play the game” (whatever that turns out to be)

2) Allow the insertion of various “nouns”, including walls, artifacts, blocks and characters

3) Allow the editing of the properties of the nouns (i.e. choose adjectives)

4) Understand the physics (or the verbs) of the game

5) Allow saving/loading of the room data

I’m wondering if I should be using XML for the room data format, or something else. For now, I guess it would be sensible to use XML, given the availability of libraries for it.

To begin with, I just need to hard-code certain objects and allow for flexible placement.

Oh, and I also need to write an Isometric class. Not so tough.