Adarakion Developer Diary: Issue 18

A wise man once said, if at first you don’t succeed, cheat, bash the computer keyboard, moan, whittle and cry until someone helps you. That wise man is me!

I think this past week has taught me not only quite a lot about how the C++ compiler works, but also quite a lot about myself, which is strange, as at the age of 32 I thought I knew all about myself, considering we have been roomies for over 30 years now!

As I hinted at last week, whilst it is important to understand how to code in C++ what is equally important is to try and understand how the actual system is working behind the scenes to understand why errors do (and trust me they do) occur.  What is also apparent is that some of the quirks of the compiler are not at all obviously apparent!

– ARTICLE CONTINUES BELOW –

So, initially this week I have been breaking down my code to try and get all my global variables in a global header and source file.  Simple enough you’d think.  So did I!  I wasn’t sure if it was a combination of my inexperience or a quirk of the Blitz library but I really struggled to get the thing to compile.  As it happens, my issue was down to using constant variables and attempting to tell the compiler that these constants were global (technical term – by “extern”ing them) when in fact the compiler treats constant variables a little different and “extern”ing them wasn’t necessary!  I didn’t find this out by myself I hasten to add.  One of the guys helping me out is a professional programmer working for a large well known game developer and his input is invaluable to me as I stumble through learning the compiler.  I feel like a kid at school sometimes as the learning curve is quite steep right from the get go!  Once I had knocked these initial problems on the head I had a few “unhandled exception” errors which I decided I would try and sort myself.

So, after spending 4 or 5 days trying to figure out why these errors were occurring, tearing my hair our in frustration and trying numerous ideas, one morning I had a bit of a eureka! moment so I decided to try something a bit different with my variables and the initialisation of them and bingo, it worked!  The feeling of accomplishment is a great one – whilst what I have achieved is a very small part of a larger puzzle, the fact that I got this far without giving up has taught me that I am able to overcome these setbacks myself with a bit of time and effort!

Just to prove I am actually getting somewhere – here is my main menu coded in C++.

(yes, I did this, do you want to touch me?)

It’s essentially (almost) identical to the previous version. Just a couple of bits I need to sort out – such as the rectangles not QUITE being aligned correctly but this is quite a proud moment for me so excuse me whilst I gloat a minute.

Gloat.

There, that’s better.  There are still a couple of bugs in the code that I need to resolve – for example the menu doesn’t rotate right at the moment – left seems to work fine, but right doesn’t – it’ll be a silly mistake in the code and one which will hopefully only take a couple of minutes to resolve.  The colours of the rectangles also don’t change when rotating quite as I expected them too.   I’m also thinking about improving the style of the menu – but the main thing is to get the game running as was before I start looking to improve it.  There is still a lot of code to port over, but now I have cracked the initial bits, I am hopeful that the rest will port over without too many problems (although I’m sure Ill have more hair tearing moments in the future)!

As ever, I would be interested to hear from you all over at our forums at www.adarakion.co.uk – as we had an influx of spammers and weirdos over the past few weeks I have had to disable automatic access to the forums to admin approved members only – so once you sign up, one of the team will need to activate your account, but it should only be a short delay!

– PAGE CONTINUES BELOW –