Game Design, Programming and running a one-man games business…

Coding for the sake of elegance

I’m working on campaign stuff for a future (long way off) GSB expansion pack.

Right now, when the player clicks the battle screen to show the missions, there is an extra “campaigns” tab, and when that screen is initialised, the game currently loads in all the campaign data, including data for all the encounters within each campaign.

That doesn’t take very long tbh, it’s fairly negligible, even in debug mode.

Yet I am determined to fix it. I can just load the campaign name, and only bother loading further data if that campaign gets selected, and the player goes to the next screen. Otherwise, I’m wasting time.

Back in the days of the ZX81, that sort of delay would be very long, slow and totally unacceptable. It would be hugely wasted processing to load any data you didn’t really need, regardless of how much effort it took or complexity was involevd to avoid it. These days, it really doesn’t matter so much. We have more than 1k of RAM, we have more than a million times as much.

And yet it still bugs me. The code is inelegant, and I must fix it. Like most games programmers > 30 years old, I’ll never shake that desire to code ‘close to the metal’ and get as much performance as I can, even in fairly unimportant scenarios like this. Maybe it’s a good thing? Maybe thats why GSB surprises people sometimes in how well it runs on crappy old PC’s :D.


5 thoughts on Coding for the sake of elegance

  1. lol! Sometimes you just have to code something because it’s neat, not because you actually need it!

    I remember when I was building an early Alpha version of my current project I did some stuff that really wouldn’t be noticeable at all, but was just really irritating when it wasn’t working perfectly. It was a time system for my RPG. It worked by incrementing a variable every few seconds. The seconds in-between were calculated by a timer, but the timer would reset every time you went into a new area (something I couldn’t change). I got so obsessive about losing a couple of seconds every time I changed to a new area that I gradually lowered the timer until it incremented the variable every quarter of a second or something stupid.

    At least yours actually has a practical use! ;)

    P.S. I solved the problem by just incrementing the time by one when you enter a new area.

  2. You must have run out of user-impacting bugs to fix then? If so, you’re free to do whatever you like. Just don’t spend too long on the polish otherwise you’re wasting time you could use to make your next earner.

  3. As Brad said, I suppose it’s not the best use of your time spent coding (I for one would much prefer a confirmation button added for the delete a schematic option on the deployment screen) but i do think too many coders are happy with being sloppy.

    With every small streamlining action, you’re opening your game to a wider and wider potential audience, that can only be a good thing

  4. Personally, I don’t care about wasting processing power (as long as it does not impact the user experience of course) because I prefer simple/naïve code that has less chance of containing bugs.
    However, I program for consoles, so I don’t have to worry about low-end PC who could potentially benefit any optimisation.
    Still, you worry about the snappiness of the UI, and that’s great.

  5. I’m with Cliff on this one. While I’m only just 30 I did start programming on a Spectrum +2 (yeah! 128KB of RAM!!)

    These days I don’t write much code at all but when I do I can’t help thinking “this is no challenge, look at how many clock cycles / RAM I’ve got!”

Comments are currently closed.