Project Hex: Part 1

By Shamus Posted Wednesday Oct 13, 2010

Filed under: Programming 147 comments

Well, I seem to have found myself with some extra free time, so let’s put that to use and start a new project.

Like a lot of wannabe developers I have a stack of game ideas floating around in my head. Some are just fragments of a game – a basic mechanic or a story hook. Others are decent one or two person projects. And some are immense pipe dreams that would require a team of people and a silver-plated eighteen wheeler carrying a diamond-encrusted vault packed with golden briefcases full of money. And Sid Meier would need to drive the truck.

This particular idea has been floating around in my head for a few years and I thought I’d tinker with it a bit. However, I don’t want to start with talking about the game. Not because I’m afraid anyone will “steal” my idea. Like having “a great idea for a movie / book”, an idea alone is basically worthless. Anyone capable enough to use the idea is going to be too interested in working on their own stuff to worry about stealing ideas from random mooks on the internet. I don’t want to start off this series with pages and pages of mechanics and concepts. Doing so would only invite an avalanche of “but how does this part work?” sorts of questions. I might not have answers for those, the design might change once I see it in action, and I’m not even going to be working on that stuff right away. So let’s start simple.

First, I need a bit of technology.

What language to use? I’ve got a couple of weeks of Java rolling around in my head. I made some sort of puzzle-ish game in Java way back in 2003. I liked how easy it was. Disliked how slow it was. I’m told the speed is much better now, and the explosive success of Minecraft has impressed upon me the extreme utility of having a portable game that can even run in a browser window.

On the other hand, two weeks of Java is chump change compared to a decade of C++. In C++, I’ve got a familiar development environment and I theoretically know what I’m doing. There will be a learning curve to using Java and it will eat time until I can transition from crawling to running. Also, I’ve got a bunch of utility code I always bring with me on a project like this. It handles the special variables and math you need when doing 3D rendering. Moving to Java would mean re-writing all of that. So what am I looking to do? If I’m honestly setting out to launch a commercial project I should probably go with Java. But if I want to tinker and prototype, then I should go with C++.

I think I’m more interested in prototyping at this point. I’m doing this because I want to play around with some ideas, not because I want to blow a couple of weeks reading docs, re-writing old code, and wrestling with a new development environment. So C++ it is. If I like the idea or it seems to be heading someplace, I could always port it later. It’s more work that way, but less risk up front.

(Although if any of you Java types have suggestions on where to start, I wouldn’t mind reading about that. It’s been years since I fiddled with Java and I imagine a lot has changed.)

Having said that, there is some value to starting with something that’s not completely married to Microsoft Windows. Okay, I’m using their development environment and their operating system, but in an ideal world the code I write could be taken to (say) a Mac or a Linux machine and have a reasonable chance of compiling without too much fuss. (And right away we see the cost of abandoning Java.)

Jargon time: The acronym API stands for application program interface, which is just a fancy way of saying, “some other programmer wrote some code that does stuff, here is how you use it”. It’s the interface. Think of it like the controls of a car: Gas, brake, steering. You learn the API and you can use the thing without ever needing to worry yourself about what’s going on under the hood.

A good API will be easy to learn, easy to read, and not eat up a lot of lines of code. A bad API will be messy, unclear, or require you to worry about the inner workings of the system you’re trying to use.

Imagine you were writing a program and Zeus poofed in and cursed you with the inability to use the plus sign. He’s always doing annoying crap like that. So now you need some external library for adding two numbers together. Great.

Let’s say you get a nice API for adding numbers. You write some code to add 2 plus 5 and get the result.

answer = AddTwoNumbers (2, 5);

Now the same thing with a bad API:

LoadFirstNumber (2);
LoadSecondNumber (5);
PerformOperation (OP_SUM);
answer = FetchAnswer ();

It’s the difference between a car that works like we’re used to, and a car where you have a hundred unlabeled controls, and even starting the engine is a six-button operation.

A lot of APIs suck because, statistically, programmers are not very skilled at communication. They’re bad at organizing and simplifying information for others. A big deal is made of the puzzle questions given to potential programmers during a job interview. If I were screening potential candidates to work as part of a team, I wouldn’t try to bust their noggins with tricky special-case problems. I’d just ask them to explain some technical concept for the layman to understand.

“Explain a memory leak to the marketing team.”


“Every time a part of a program is run, a little bit of memory is used up. Over time the computer will run out of memory entirely.”

Less good:

“That’s when a program allocates memory and doesn’t free it up again later.”

Have this man killed:

“That’s when a program iterates over a particular function or execution path that doesn’t properly deallocate objects created on the heap.”

I’d rather have an average coder with excellent communication skills than a crackerjack ace who writes pages of code that only he can follow. Sure, Ace gets done a day earlier, but everyone who has to use Ace’s code loses a day to tears and cursing. Ace is going to design an API that will drive people up a wall, like my above example where it took four lines of code to add two numbers.

All of this is a roundabout way of saying that the API for Microsoft Windows is horrendous. This API is used for doing stuff like making windows, menus, buttons, scrollbars, sliders, and all the other window-ish type stuff you need in a modern desktop environment. To be fair, bits of it are over a quarter of a century old. (Windows 1.0 came out in 1985.) It’s full of backward thinking and systems designed with 16-bit computers in mind. It was a clunky design in the first place, and it has aged very poorly. As the years have gone on, that API has become more ludicrously byzantine compared to the other systems.

One such other system is SDL. It’s library for making windows and such, but unlike the Windows API it’s clean, simple, and totally cross-platform. Here’s an example of creating an empty do-nothing window in SDL:


And here is the same thing for a programmer using the Windows API:

  wcex.cbSize         = sizeof(WNDCLASSEX);			    = CS_HREDRAW | CS_VREDRAW;
  wcex.lpfnWndProc	  = (WNDPROC)WndProc;
  wcex.cbClsExtra		  = 0;
  wcex.cbWndExtra		  = 0;
  wcex.hInstance		  = AppInstance ();
  wcex.hIcon			    = LoadIcon (AppInstance (), MAKEINTRESOURCE (IDI_CPICON));
  wcex.hCursor		    = LoadCursor(NULL, IDC_ARROW);
  wcex.hbrBackground	= (HBRUSH)(COLOR_BTNFACE+1);
  wcex.lpszMenuName	  = MAKEINTRESOURCE (IDR_MAIN_MENU);
  wcex.lpszClassName	= APP_TITLE;
  wcex.hIconSm		    = NULL;
  if (!RegisterClassEx(&wcex)) {
    return false;
  return false;

Gah. And actually the Windows code might need a bit more to make it work. But you get the idea. The choice is long, clunky, dated, and Windows-specific vs. small, clear, and portable.

So SDL it is.

Great, now we have a system for making the program window. But we need a system for putting graphics in that window. This is an easy call for me to make. My alternatives are:

1) Go out and use some freeware graphics library. There are a lot of them available. Some for Final Fantasy IV style graphics. Some aimed at 2D platforming. Some aimed at full-featured 3D games. Pick one that suits your needs. Some are “graphics engines” that only concern themselves with drawing and leave the rest to you. Others are “game engines” and (theoretically) offer a framework into which you can drop your game logic. Unfortunately, most existing systems do not play well with procedural content. They generally have predetermined ways of loading pre-made content from disk. I might get the project off the ground faster, but I’d spend the whole time fighting to get the graphics engine to let me do simple things.

2) Use Direct X. (I hate the way Microsoft names things. They named their operating system “Windows”, which is like building a brand of car called “drive”. Oh, I was driving my drive yesterday. I also wrote a program to make windows in Windows. Madness! In this case, they gave the name “Direct X” to both the API and the graphics drivers that use the API. Arg. Note that when I say “Direct X”, I’m talking about the graphics API used by programmers to make polygons and such and not the drivers you use to make those games go.) The Direct X API isn’t as bad as the Windows API, but it still has many of the same problems: It’s not portable and it’s exceedingly verbose.

3) Use OpenGL. It’s clean, it’s portable. I’ve been using it for years. I’ve written a bunch of tools to go with it.

I agonize over this for three milliseconds before hitting copy » paste on all of my standard OpenGL code and creating a new project. A project which I will name Hex. For reasons that will become clear in the next post.


Huh? What do you think? Game of the year, right?


From The Archives:

147 thoughts on “Project Hex: Part 1

  1. Eddie says:

    Is there somewhere where I can pre-order this thing, because it is looking awesome?!

    1. 4th_Dimension says:

      Yeah MAN. Look at those Crysis level graphics. All that eye candy.

      1. Stupidguy12 says:

        It totally BLUE my mind. :D

        1. MrWhales says:

          It’s like a WINDOW into Shamus’ mind!

          1. Tzekelkan says:

            Shamus is now ready to SQUARE off against Crytek.

            1. Wonderduck says:

              It’s gonna be BETTER than the last game.

              Am I doing it right?

            2. Maldeus says:

              I think this project will MINIMIZE graphics whoring, RESTORE the ’02 era standards to the industry, and CLOSE the chapter on Generic Space Marines forever.

    2. Pickly says:

      I think this thing will beat World of Warcraft and Call of Duty combined.

  2. MelTorefas says:

    It’s so blue, and shiny, and blue… I must have it!

    Seriously though, very interesting post. I also have a comparatively small amount of Java experience compared to C++ (though it sounds like I have slightly more Java experience and significantly less C++, hehe). At any rate, I am looking forward to the next post(s) in this series! I love it when you write about technical stuff.

  3. poiumty says:

    BLUE! Shamus, you are a design god.

    EDIT: How the hell did it assign me that avatar? Does it link to yahoo avatars or something? I’m confused.
    Granted, this IS one of my old avatars.

    1. wtrmute says:

      That avatar is stored at; you can probably go there and change it.

    2. krellen says:

      When you stuck in your email address, it linked over to Gravatars where, at one point, you must have mapped that email to that avatar.

      1. poiumty says:

        Ah, must be that i’ve stored this on GRAvatar and forgot about it. Thanks.

  4. Primogenitor says:

    Can we speculate wildely about what your idea is?

    My bet is mime-chime, on a hex grid!

    1. Stupidguy12 says:

      Chime chime chime chime chime chime chime chime chime chime chime.

    2. Garden Ninja says:

      Please. Mime-Chime is a stupid name. He clearly should call it ChimeCraft.

      1. Pickly says:

        Na, that would cause copyright issues.

        He needs a name that combines a suggestion of new, futuristic technology, plus a sense of being special. Something like: Star-craft.

      2. Greg says:

        Crafter Craftington and the Crafty Craft of Craftyness. instant hit

    3. wootage says:

      I would guess – MINE-chime! :D

  5. kikito says:

    If you are doing 3D-stuff, probably you need to stay close-to-the-machine and do C++ and OpenGL.

    If what you are thinking is more like a 2D thing, then I must recommend you Là–VE (

    It uses Lua on top of a C/C++ stack that handles OpenGL. Next version, 0.7, is around the corner (bringing frabebuffers and threads to the extensive set of tools). It’s Win/Mac/Linux cross-compatible. And Lua is interesting and fun to learn.

    One little warning: your code will be quite accessible for anyone to see (Là–VE apps are just zip files with the extension changed).

  6. wtrmute says:

    SDL_SetWindowTitle(window, “Hex”);

    “SDL_App” there in the title window is extremely ugly.

    Other than that, I agree: If you want cross-platform compatibility, SDL is the way to go. Unfortunately, you bashed DirectX API while praising SDL’s: considering SDL is an implementation of a Simple DirectMedia Layer (that is, DirectX-like), they must either both be good or both be bad…

    1. McNutcase says:

      I’m going to have to disagree here. Let’s use the car analogy. Consider an unrestored Model T and a late-model Focus. They’re both cars, so they must both be good or both be bad, right? Not so much. You can do a lot of things with the Model T, some of them things you can’t do with the Focus, but in daily life the Focus will be a lot more useful and a lot less hassle.

    2. Stibbons says:

      Eeeh, even if they both do similar things, they do those things in slightly different ways, with SDL being a bit cleaner and more portable. So, they both are good, but one is better.

      (Ninja’d by McNutcase)

    3. Shamus says:

      Since I’m using OpenGL, I don’t really use the SDL calls beyond creating the window.

      And my gripes about DX are admittedly minor and mostly a matter of taste and style. I dislike the long function and variable names. Petty, I know.

      1. DrMcCoy says:

        Be glad you’re not forced to use GTK, then. :P
        Just a few examples:

    4. Factoid says:

      Shamus…mark this down as the first bug report. ;)

  7. Matt K says:

    Nice. I have a friend who works with API (among other things) for the DoD. It nice to understand why the API stuff just drives her up a wall.

    Keep up the good work (even if the project doesn’t work out) as I love these articles.

  8. Hex, huh? Well, assuming this isn’t an old programmer reference to number systems (which would, let’s face it, imply an incredibly boring game), it must instead be a brand new frontier: Computer interaction with the real world via witchcraft.
    There *are* a few people I’d like to put a hex on. I’ll be waiting for this with interest!

    1. Ingvar says:

      I suspect it’s all about building computing devices from virtual ants and (smnall) stone-circles.

      1. utzelgrutzel says:

        Ant-hill inside!

      2. Hugo Sanchez says:

        Oh My Precious Lord. Shamus making a the SimAnt of a new era. I’d weep openly. I’d confess all sins. I’d go sky diving. It would truly be the end of the world.

        1. Zagzag says:

          But will he require small religious pictures and the skulls of male sheep?

  9. Joel D says:

    As someone who has never coded at all, but sort of understands some code when he sees it, I found this post really cool and helpful.

    Shamus, have you ever considered that you might be the coder with communication skills? You seem like that guy to me – maybe not the paragon of programming, but certainly able to get the point across.

  10. Ben says:

    The SDL vs Windows code isn’t really fair since the Windows code is doing a lot more than the SDL code, you aren’t comparing like for like. For a fairer comparison you’d have to have code on the SDL example that explicitly sets the icon, menu, window title etc. In fact, it is possible to use the Windows API (DialogBox I believe) to create a window in one function call, with the caveat that you have to have created a resource template (basically a text file describing the window).

    It’s the same with your OpenGL vs DirectX argument. From what I read in the source of the brilliant PixelCity project, you’re using parts of the OpenGL api that don’t have an analogue in DirectX, so naturally it is more work to emulate that behaviour in that way.

    You make the real point eloquently “Pick one that suits your needs.” None are better than the other except when it comes to how you want to use them.

    1. Shamus says:

      The point is that you CAN leave out those details in SDL, setting only the options you need. In windows, you need to define everything. And the system of filling in a struct, THEN registering the class, THEN crating the window with a crapload of options, and THEN making a bunch of other calls to set the options that weren’t in the struct or the window create… well, it’s more obtuse than it needs to be.

      1. Duffy says:

        Doesn’t this tie into your C++ article a few days ago tho? Technically aren’t they doing the same thing, you’re just letting SDL handle some of it for you by default? One could argue that SDL might sometimes do things inefficiently due to this ‘shortcut’. Of course if the Windows code requires those things and they aren’t actually needed, then I agree we have a perfect example of a poor API.

        Languages and APIs (which could be argued as sides of the same coin) really just hide the machine code level from us, each one gives varying level of control over how our commands are interpreted. None of them are truly “special” in regards to what they can do, it’s only limited by design. The possible diversity and scope of what we can do with modern CPUs also illustrates why we don’t have one language to rule them all and why legacy languages and concepts sometimes bog us down.

        I think that’s roughly the point Ben is trying to illustrate.

        (Please note that I am not complaining about your choice or points, just trying to clarify the concepts at hand. As a primarily SQL Developer with .Net App experience I would hands down trust your opinion for graphics based development any day.)

        1. Ben says:

          My point was that comparing an API designed to configure all the options of the Windows GUI to one designed to give simple access to graphics hardware is a little meaningless at best and is going to confuse new comers to programming at worst. My younger brother is learning to program currently and I’ve had experience at unintentionally misleading learners recently :) The choice of SDL is justified in that it does what you need and hides what you don’t.

      2. Simon Buchan says:

        I actually don’t like platform independance libraries like SDL much, they often dont keep up much (It looks like both SDL and SFML dont support OpenGL 3+ contexts, for example), and SDL especially has WAY too much init cruft.

        BTW, OpenGL 3+ contexts are now far more of a pain to create than Direct3D 10 contexts. (nitpick! It’s “DirectX”, not “Direct X”, and you’re talking about Direct3D anyway :P). Considering how much code you have to write to get to the point where you’re drawing a triangle in either nowadays, complaining about the calls to create a window seems… silly. Even if you have to write platform specific window code three times, it would still be shorter than the initialization code for either GL3 or D3D10.

        Soooooo……. I guess I’m recommending not using GL3+ contexts? You loose a *heck* of a lot with them, even apart from how much of a pain they are to create – all the fixed function pipeline, immediate mode and matrix functions are gone, so you have to write vertex and fragment shaders, create and load vertex buffers, initialize your matricies (I recomend glm), all just to be able to draw a triangle. But it’s the way of the future!

        1. WJS says:

          Well, isn’t that basically the difference between (say) BASIC and Java or C#? You need a hell of a lot more code to even do hello world, but nobody would seriously use that as an argument in favour of working in BASIC.

  11. Deadfast says:

    Ah, WinAPI.
    There are those times I needed to work with it. Then there were those times I felt an almost irresistible urge to throw my computer out of the window. Now that I think about it, I think these two are somewhat related.

  12. Chen says:

    It is a bit odd to use C++ for prototyping and Java for production; I always do it the other way around. Windowing in java is a snap. OpenGL via JOGL, which is a straightforward GL binding. And for Math and 3D you can salvage code from the Java3D project. Then you enjoy all the benefits of a managed environment.

    The only downside to using Java (besides the inevitable slowness) is the depression one suffers from dealing with all these dead Sun projects (Java3D,JOGL,JMF…). The situation with community driven JOGL2 wasn’t very uplifting as well last time I checked. The JOGAMP project seems promising but is lacking when compared to C#’s fantastic OpenTK (if they had only made it for java…)

  13. Galenor says:

    Aah, I love the blank canvas. Every development tool has their own default background colour – every time I load up VS+XNA and start a new project, their colour choice of Cornflower Blue (RGBA 100, 149, 237, 255) is now the colour, in my mind, of a fresh, swear-laden start.

    And I agree, GOTY material. The mere fact you didn’t go with Realism Brown or Realism Dark Brown or Realism Black With A Smidge Of Realism Brown is an instawin!

    1. Nevermind says:

      ^ this.

      If you need to make a quick prototype, Unity is absolutely unbeatable.

      Granted, if you come from strict C++ background you’d have to spend some time to get to speed with Unity. BUT it’s really simple, and the resulting speed is astonishing.

      For example, hacking together a Minecraft Classic clone in Unity3d takes about a week, tops.

  14. neothoron says:

    I’ll agree with Chen that it is strange to use C++ for prototyping and Java for production – nearly everyone makes the transition the other way.

    If you take care to use only cross-platform libraries, the amount of work to get your work across all platforms should be tolerable. (I mean, many indie games I see use OpenGL, SDL and they have been able to produce cross-OS games). The libraries that seem to be most prominent (well-known and cross-platform) would be STL and Boost. Do not forget to at least check that your code compiles with a compiler for *nix.

    Anyway, good luck Shamus.

    1. silver says:

      It is never, ever strange to hear about someone using “the language they did 90% of their previous coding in” for prototyping :)

      However, the idea of intentionally transiting from working code in any language TO a rewrite in Java – that IS strange.

      1. Will says:

        Java has a level of portability that is pretty stunning, yes it’s not perfect, but if you’re an independant developer making a game that you want to be as accessible as possible to as many people as possible, like Notch with Minecraft, Java is an excellent choice to go with.

        1. WJS says:

          Or you could just write it in C and compile it three times. It requires a bit of extra work, sure, but compared to learning a whole new language?

  15. NeilD says:

    I am very much looking forward to this series.

    On a semi-unrelated note, if you ever find the time to compile another version of PixelCity with the randomization enabled, I would give you money.

  16. Erik says:

    Clearly the story in this game is gonna suck. I can tell from the non-existant trailer

  17. Shinjin says:

    Nuts. My idea for Hexcraft has been ninja-ed.

  18. Atarlost says:

    Hmm. Explain memory leaks to a marketing person.

    Okay, computers are really stupid and only do what they’re told and they have memories like goldfish and have to write down everything in something called RAM. A memory leak is when the programmer makes a mistake and fails to tell them to erase something when they’re done with it.

    Suppose you’ve got a bulletin board that you post the time of your next meeting on. If the guy that posts it is dumb as a computer he won’t post over an old time unless someone tells him it’s okay to post over it. Eventually he’ll have a completely full bulletin board and, being as stupid as a computer, will stare at it mindlessly holding a piece of paper with a meeting time that he doesn’t know what to do with.

    Do I get the job?

    1. Alan De Smet says:

      I really like the “RAM as bulletin board” analogy. It also provides a good basis for explaining different types of memory management strategies (explicit deallocation, reference counting, full garbage collection). I’ll have to remember that!

    2. Sumanai says:

      I would’ve just gone with “it’s when a program hoards memory for itself until all is taken”.

      But I also like the bulletin board analogy. Couldn’t you have just gone with “it’s like when a group of people use a bulletin board and someone doesn’t take their notes off of it when it’s not needed filling it up over time.”

  19. Jericho says:

    Yay, programming project series!

    I’ve been feeling the game-development bug myself recently but I know jack all about direct X, open GL, and all that stuff, so looking at that stuff makes my eyes gloss over. Besides, after 8 hours of programming at work I don’t feel like doing it when I get home.

    So I just gotta live with a sort of game-programmers Cassandra complex for teh time being.

  20. Kell says:

    Geodesic TBS?

    /vote gamename “Imperious Hex”

  21. Mark says:

    Good call. I’ve been using SDL and OpenGL for my Mac game projects for ages now and it’s worked out very nicely.

    Be careful, though, as the latest versions of OpenGL are sliding down the same slippery slopes as Direct3D with regards to removing any quick and easy way of getting things done. :-/

  22. Floomi says:

    The whole “C++ for prototyping, Java for commercial development” confused the hell out of me. I’d have thought it’d be the other way around – Java for rapid prototyping, and C++ for the finnicky, close-to-the-metal, need-all-the-speed-I-can-get stuff. Beyond the ability to deploy in-browser (which is, to be fair, a really nice bonus) I’d be unlikely to go near Java for a “serious” game project. It’s not even as if it’s particularly hard to code cross-platform C++, just a matter of choosing the right libraries to lend you a hand.

    On the topic of cross-platform libraries, it seems you’ve already settled on SDL but I thought I’d throw this out regardless: I’ve had a lot of success with SFML. It’s a more C++ified version of SDL and beyond a few issues that turned up due to me being incredibly anal about disabling MSVC language extensions, I’ve loved every minute I’ve spent using it.

  23. asterismW says:

    “I hate the way Microsoft names things.”

    Even Microsoft developers have admitted how they suck at that. Eric Fitzgerald, on Windows Auditing:

    “One of the most common questions that I get about Windows Auditing is, how come you guys were so @#%! stupid that you put in two logon categories?

    The answer is actually pretty simple- we’re bad at choosing names.”

    1. Nathon says:

      Choosing names is probably the hardest and most important part of writing good software. If your variable and function names are clear and concise, you’ll have fewer bugs, your code will run faster, and free ice cream will magically appear on your desk.

    2. bit says:

      Yo dawg we heard you like windows so we put windows in your windows so you can code while you code.

      1. kmc says:

        *tee hee* *giggle*

  24. silver says:

    Shamus – why does your SDL code not seem to have error checking, but your sample Lose API code does have error checking?
    I understand the CreateWindow() call relies on the RegisterClassEx() call succeeding, sure, but shouldn’t you at least apples-to-apples the last functional line of each sample?

    1. Deadfast says:

      There you go:

      if (screen == NULL)
      return false;

      Mind you I never worked with SDL before and it only took me a single Google search to figure this out.

      It was not my intention to say that you should have just looked it up (which is exactly how it sounded). You definitely raise a good point, the error checking should either be present in both or neither.

      1. silver says:

        right – I wasn’t interested in the code itself, just that the comparison be fair to both parties.

        1. silver says:

          I have no idea why I want the comparison to be “fair” – kinda silly of me.

          He didn’t make either program complete so who knows how much junk is hiding around those compared lines, and neither program does anything, and he wasn’t writing this as a balanced review of the two processes, just trying to give an sort of rough “this is how much worse it was” kind of idea – which he succeeded at.

          I just have a reflex when I see such comparisons – because a lot of people who DO claim to make balanced comparisons of things often make such adjustments to “balance” things more in favor of their favorite thing. This happens a TON in language comparisons where everything written in FavoredLanguage uses the cleanest syntax and has no error checking, and everything in DisfavoredLanguage is full of safety code and choices to use the longest of several methods to accomplish a solution.

          1. Shamus says:

            It’s a good point. Both samples were cut & pasted from current projects. I had to cut some unrelated stuff from both, and didn’t notice the error checking issue until you mentioned it.

  25. Robert says:

    I can’t get it to install, and the uninstall crashes. Also, the writing is very poor.

    This game sucks!

  26. Psivamp says:

    Yay, programming! Yay, Hex!

    I should really learn to use SDL and OGL.

  27. CTrees says:

    Real men code in Fortran. Yeah, I said it.

    (admittedly, I do this every time something like this comes up. mostly I think I’m just bitter about all my college programming courses being in Fortran. I enjoyed it, but… I’m honestly not sure why I chose that. Of note, programming makes up exactly zero percent of my job)

    1. Psivamp says:

      Apparently FORTRAN and COBOL are still used for scientific gear because scientists in some fields don’t upgrade gear until it can no longer possibly be of use.

      If it gets the job done, why go back and rework it, I guess.

      1. Guthie says:

        Heh, I worked for five years with a NASA subcontractor and learned two languages for the job: Fortran and Tcl. Guess which one I used the most. “>> I don’t know about scientists, but NASA engineers can’t seem to let go of that relic.

      2. Psivamp says:

        Yay! My smiling fatty acid avatar is up and working!

      3. Elm says:

        I think Cobol is still used in manufacturing too – or at least, its the main language my aunt, who is a programmer for for a major furniture company, uses.

      4. Supah_Ewok says:

        Well, scientists have limited budgets. If they can reuse something, I imagine they’ll run it to the ground until they HAVE to get something else, just to save a buck to use on the actual project.

      5. kmc says:

        GAWD, my boss is like this. The rest of us around the lab are gamers, so we’re always looking at PC hardware and making small upgrades and such–by contrast, about 6 months ago we finally convinced him that he should at least upgrade to a home PC that HAS a CD drive. Yes, I said CD drive, because if I said optical drive, some of you might think that maybe he just couldn’t watch Blu-Ray discs or something! No, the man was doing work at home in MATLAB on a computer from before zip disks.

    2. Robyrt says:

      I learned to program first in LISP. Now *that’s* a real man’s programming language. Nothing says needless complexity like auto-generated functions using their own name to store a return variable!

      1. wtrmute says:

        Do you know what else uses the function’s own name to store the return value? Visual Basic >:D

      2. silver says:

        “Nothing says needless complexity like auto-generated functions using their own name to store a return variable!”

        …store a return variable? what kind of LISP programmer “stores” things in “variables”? weird.

      3. Maldeus says:

        No, REAL programmers use butterflies.

  28. Jarenth says:

    Am I the only one that looked at Shamus’ empty screen and instantly saw a BSOD?

    1. Simply Simon says:

      I saw that too. And I was about to do a joke along the lines of “Shamus! You are using a Microsoft-copyrighted colour! Hide before the lawyers find you!” or “I see you are using the Windows standard colour Shamus” before I saw your reply and decided to instead affirm that you were, indeed, not alone in your observation.

      1. Jarenth says:

        Nice job still working those jokes into your reply, though.

  29. Aquin says:

    Gee, I even find SDL to be a bit of a confusing muddle sometimes. For example, it doesn’t really seem to keen on explaining the import of PNGs into a texture. Still, I used it for years.

    You may or may not care, just throwing it out there: Google SFML 1.6 and give it a try. You may really like what you see, or not.

  30. Shrikezero says:

    Shamus, I love these articles. I wouldn’t know if I was looking at C++, Java, or complete BS, but I (almost)always understand what you’re writing about. It’s kind of like watching a gourmet cooking show. No way in hell am I ever going to attempt a white truffle souffle, but I appreciate it that much more once I know how it trashes the heap.

    Bonus is being a fly-on-the-wall to the great discussions that follow.

    Double-extra-Bonus is being able to talk to my equally code-illiterate friends and make it seem as if I knew what the hell I was talking about.

    1. Maldeus says:

      I want to design a computer language that can be acronymized to “BS” now.

  31. Nathon says:

    Un-asked-for language advocacy:

    Python! Python python Python CPython Jython, Python?

    Really, spend a few hours tinkering with it sometime. Maybe write a prime sieve or an rpn calculator. It’s not known for its amazingly awesome performance characteristics, but pygame is a very nice SDL wrapper and a few weeks hacking with it will get you to the point where you’ll wonder why you’ve been wasting all this time prototyping things in C++.

    That said, your decision to pick a language you understand well for a new project is completely understandable. I like learning new languages (Erlang (new to me) is really cool) but it’s crazy frustrating to get stuff done in them.

    1. Guthie says:

      Yeah, this occurred to me, too. Python’s much easier to learn than Java IMO and sooo much easier to implement prototypes in than C++. You really should give it a look, Shamus. ^^

  32. wumpus says:

    Another alternative to the Windows API: JUCE.

    It’s cross-platform and fairly straightforward in my (six months or so – one major project) experience. Its biggest disadvantage is that its documentation is largely autogenerated, but the creator is on the forums all the time, and there’s a pretty helpful community, so it’s relatively easy to get pointers and have questions answered.


  33. Nick says:

    CLEARLY, the game simply responds to the user’s brain and displays an extended dream sequence based on what they were thinking at the time.

    Shamus was just thinking about blue really, REALLY hard

  34. Ken says:

    I would love to see Peter Molyneux hype up this game

    1. Irridium says:

      That man could hype a broken chair.

      OT: “extra free time”?

      You say that like you don’t have Minecraft.

  35. Sydney says:


    Your terrain project is still one of my favorite things on this site. Looking forward to this project!

  36. Andy says:

    Not much more to add, just genuinely looking forward to watching this project evolve.
    It was the pixel city project that first brought me here and whilst I love all the other content that caused me to stick around, I really do like geeking out over the under-the-hood stuff you sometimes write.

    Also wanted to point you at CEGUI (Crazy Eddie’s GUI) which is a reasonably mature library for drawing GUI controls under OpenGL.

  37. HarveyNick says:

    Okay, so I was really slow on the uptake at reading this post, so you’ll probably never read this. But if you do: This is a little spooky. I’m also starting up a side project I’ve had buzzing around my head for some time. I suspect I’m doing something quite similar to you, as well, based on your history with these things. I also just went through the same language choice thing, though considered a few more languages and came to almost comically oposite conclusions (as in “equal and oposite”). I also had a bit of a blog about it.

    Mine was a bit long winded, so I split it up. If you’re interested, you can find the first part of it here and the other parts are quite easy to reach.

  38. MrWhales says:

    Hm. This post makes me wonder something. How easy is it for the average person, with 0 coding experience, to read this article? Not harping on you at all Shamus. It’s just that I, and most here, have been coding in some form for long enough to be able to know what we are talking about.

    But i wonder what they think.

    1. I have very little coding experience; if I am ever interacting with code at all, it is because I want to solve a very specific problem through trial and error or through having looked up what I need. What are all those indents and brackets for, anyway? I’m not sure if that’s 0 xp or just 0.1, but I usually find Shamus’s articles on coding to be understandable and enlightening. I can’t read the code itself, but when Shamus is trying to illustrate a point about a particular piece of code I can usually understand it.

      1. ClearWater says:

        I don’t think anyone can read the Windows API code. I’ve been programming for 20 years and I have no clue as to what all that stuff does.

    2. Teldurn says:

      I feel fully qualified to answer this question.

      I’m an artist. I have 0 coding experience, and the way the article was presented made it very clear what he was trying to accomplish and how. The particulars of what the sample lines of code actually DO is of absolutely NO consequence. I had no problem whatsoever understanding any of it. :)

    3. Spatticus says:

      I have no coding experience. If a meteor was about to crash into the Earth and I had Bruce Willis yelling at me over the radio that all I had to do to shoot the meteor and make it blow up was tell the computer to print “Hello world”(That’s a common/easy programming thing, right? I think I saw that on this site before), and I didn’t have Google, I’d just sit there for five minutes and wait for the meteor to hit.

      And I can follow these discussions pretty well. Since it’s not actual detail, but more concept/comparison(Imagine if the line of code in question was this thing…) that goes on, laymen can follow along and nod like they know what they’re talking about. I actually look forward the to the edumacation!

  39. My prediction: Hex will be a combination of Minecraft and Civ V. Kill piggies for happiness! Mine uranium and surround a stack of 235 uraniums with TNT in the hex-based crafting grid to create a nuclear bomb to wipe out the Creeper Barbarian menace! Make fishing poles that do nothing!

    I, for one, cannot wait.

  40. Aldowyn says:

    So amazing that I actually kind of know what the heck you’re talking about! Both my mom and step-dad are programmers, but it all sounded like gibberish until I started my Java programming high school class, though, which is absolutely awesome! (that it doesn’t sound like gibberish, not the class. I have a book and an idiot teacher, so I’m basically trying to learn programming straight from the book, with no prior experience. Oh, and a bunch of other kids in the same boat.)

    … Occasionally I still get swamped by some of these posts, though.

  41. omicron says:

    Have you ever played Empire/Empire Deluxe? ‘Twas a sort of wargame back a couple decades ago; it was relatively simple, relatively fun, and is relatively old.

    …all that to say, is this related?

  42. Abnaxis says:

    “I think I'm more interested in prototyping at this point. I'm doing this because I want to play around with some ideas, not because I want to blow a couple of weeks reading docs, re-writing old code, and wrestling with a new development environment. So C++ it is.”

    You know, now every single time you start a new pet project you’re going to have to make this choice all over again until you stop procrastinating and just port your reusable code over…

    Not that I’m against C++, I just find the windows-marriage you refer to extremely annoying.

    Also: yay OpenGL!

  43. MichaelG says:

    Hey Shamus, do you answer your email? I sent you something (from [email protected]) the other week, and never got a reply. If you got it and aren’t interested, you could at least reply with “not interested”?


    1. Drew says:

      I blame Minecraft.

      1. MichaelG says:

        Could be! Let’s all make Notch rich!

        Could also be the layers of stupid spam filters on every link in the email chain. I’ve checked mine and don’t see any replies from Shamus, but who knows anymore?

    2. SolkaTruesilver says:

      I wouldn’t worry. I sent him an email too, and I think I expect the same kind of reply you do.

      I think he’s being swamped with proposition, and can afford to cherry-pick. AFAIK, Shamus is decent ennough to at least send a decline notification when he will have made his choice.

      If I had to guess, he’s simply showing the pace and his capabilities to everybody so we know where he stands for, also he wants to promote his own project idea and see if someone wants to pick it up with him, which isn’t a bad idea, IMHO.

      1. MichaelG says:

        Send me an email then, and we’ll plot against him…

        1. SolkaTruesilver says:

          To be honest, if he decides to try to combine the different financier/producer proposition into what would be a coherent whole, I wouldn’t have any problem, as long as it’s a thought-out organisation and not a mere patchwork :-)

          But why plot against him? He is the blogger we love and respect, no?

    3. Shamus says:

      Sorry, I’m WAY behind on my email. Hopefully I’ll catch up this weekend.

      1. SolkaTruesilver says:

        Can’t say I’m unhappy you hear you are busy.

        Even if the only thing built out of it is a fancy Minecraft structure


        I sent you the email last Wednesday, and another one (follow-up) this week on Wednesday, if you prefer to read the whole thing before replying.

        Hope you like it.

      2. krellen says:

        Stop playing Minecraft before Josh takes over your blog.

        1. SolkaTruesilver says:


          With that kind of comment, I am sure you thought it would have been a good idea to declare your intentions internationally before the attack on Pearl Harbor?

          1. krellen says:

            This is more akin to Canada warning the US of Pearl Harbour before the strike. I am not Josh.

  44. Teldurn says:

    And some are immense pipe dreams that would require…

    DRINK!– Oh wait, wrong game.

  45. ClearWater says:

    If you want to start doing stuff with Java, first download Eclipse. It’s a watchamacallit… like an editor, but it also compiles and does code completion and stuff. IDE! That’s the word.

    There’s tons of different versions of it and I don’t really know what the difference is between them. Just get the most recent stable default one (if you can figure out which one is the default).

    1. HarveyNick says:

      Helios is the latest release. I use Eclipse for pretty much all my programming, it’s brilliant*. I also find it to be a significantly better C++ editor than Visual Studio, if you install the C++ language support.

      *That’s the British definition of brilliant, FYI.

  46. Chaz says:

    Here’s me hoping that this some kind of bizarre and convoluted job application to work on MineCraft.

    Notch NEEDs your viewpoints, communication skills and internet savvy man. I’m sure he’ll be good with teleworking. Just do it, you know you want to.

  47. mike says:

    Oh man… and I was all excited about Craft of CraftCraft… :-(

    But seriously, this is awesome. I started reading this blog because of your terrain project. I also loved the PixelCity project.

    I look forward to part 2.

  48. Melf_Himself says:

    If you want to prototype, I’d really go with something like Unity. It’s just so much easier, a lot of the stuff that you’d spend weeks trying to solve has already been done for you. If you want some super bling optimized code after that then sure, port it into C++.

  49. Ingvar says:

    You know, some hardware had even worse APIs that that. There was one early FPU for the PCs (no, I can’t remember which one it was), where you did, essentially:

     *arg1 = value1;
     *add_op = value2;
     return *result;

    That is, one argument was memory-mapped in a specific position, the second argument should be stored in the memory position corresponding to the operation, with (essentially) the low bits of the address acting as an instruction selector.

    After a while, the result is then fetchable from memory (this MAY have been the same memory address as the first operand, but it is surprissingly hazy trying to recall exact specs from 20+ years ago).

    1. wtrmute says:

      It probably was, so operations could be chained. Having to copy *result back into *arg1 so you could add a third term would get boring a bit fast, so it’s an easy optimisation to make. Plus, the *arg1 address starts looking like an accumulator, which is something ASM guys hold dear in their hearts…

      1. Ingvar M says:

        Yep. I find “encode operation in low bits of address” both horrifying and elegant (so, maybe, “horrifyingly elegant”) and that’s more what I found to be worse than “load1”, “load2”, “do_op”.

  50. SolkaTruesilver says:

    And as far as “Project Hex” might be, I wish to be the first to hypothesise it’s party because of the makeover shown by CiV.

  51. pkt-zer0 says:

    If you hadn’t already decided on the language and graphics API, I would’ve recommended C# and XNA. Starting from only a basic knowledge of C#, it took me a week to put together a basic vertical shooter with basic physics, basic particle systems, and a bunch of not-quite-basic shaders. I’d say it’s pretty good for getting stuff done swiftly and easily.

  52. eides says:

    Awesome, a Hooloovoo sim!

  53. 2tm says:


    What IDE do you use for C++ on Windows? Also, do you usually write on XP, Vista or 7?

    1. Shamus says:

      I just recently migrated from Dev Studio 6 (late 90’s!) to Dev Studio 2008. In fact, I’m STILL migrating. Comic Press doesn’t work in 2008 yet and I haven’t sat down and sorted that out yet. (My money is on one of the many “silently replace a bunch of functions with Unicode versions” situations.)

      I run XP.

  54. DrHeinous says:

    I’d second what pkt-zer0 said. C# and XNA proved very smooth going; I threw together a bit of a multiplayer Dwarf Fortress inspired game over a few days. Plus, if you haven’t done any C#, that’s a good reason do do C#.

  55. Goggalor says:

    Hmmm. Looks like you’re writing a Bioshock prequel.

    Considering your last project has been my screensaver since you released the executable, I look forward with interest to see what this next one will be. No pressure though :-).

  56. thebigJ_A says:

    Ha! I knew you’d like my idea to teach me all of programming then start a software company together!

    The teaching should only take a few hours, right? When do my lessons start?

    1. SolkaTruesilver says:

      Yes you are.

      An hilarious dork, which is the worst kind of dork.

    2. Shamus says:

      I’m still laughing.

      1. GTB says:

        I’m glad you think it’s funny because I can’t seem to stop. I should have been asleep four hours ago but instead i’m rendering landscape for fake trailers.

        Teaser 2

        1. SolkaTruesilver says:

          Shamus, you really gonna have Meatloaf on this project, and you didn’t told any of us?

          I thought we were your friends… :-(

          edit: MY DOOOG!! :-(

          1. GTB says:

            I am of the opinion that Meatloaf should have a role in everything.

            1. krellen says:

              Well, he is the KOOL-AID MAN.

  57. Kdansky says:

    Of course this is a game of the year! Any game nowadays gets a second release including superfluous DLC and they call it “game of the year” instead of “complete edition”.

  58. Seeker Of The Path says:

    I, as a Java programmer, would recommend using C++ for this project :)

    IMO learning while coding is usually a bad idea. And while the
    performance of enterprise Java is really good, when it gets to graphics stuff, not so much.

    However, should you still consider Java, definitely have a look at the Processing project. Also, I’m hearing stuff about the new Java FX, but it’s one more (scripting) language to learn.

  59. destinysWalrus says:

    I am moderately amused that my primary association with “Hex” as a name for something is the magic-powered computer from Discworld books.

    And on a slightly more relevant tangent, I am finding these programming projects very interesting and I intend to read through all of them.

Thanks for joining the discussion. Be nice, don't post angry, and enjoy yourself. This is supposed to be fun. Your email address will not be published. Required fields are marked*

You can enclose spoilers in <strike> tags like so:
<strike>Darth Vader is Luke's father!</strike>

You can make things italics like this:
Can you imagine having Darth Vader as your <i>father</i>?

You can make things bold like this:
I'm <b>very</b> glad Darth Vader isn't my father.

You can make links like this:
I'm reading about <a href="">Darth Vader</a> on Wikipedia!

You can quote someone like this:
Darth Vader said <blockquote>Luke, I am your father.</blockquote>

Leave a Reply

Your email address will not be published.