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

At last… Production Line is in beta

I updated the version of the game today to build 1.66, on Steam, GoG and the humble store / direct. The latest update is 1.66, a build whose major feature is the introduction of the late-game ‘world events’ feature. That was THE feature that I was determined to get in before I could describe the game as feature complete. it may need some tweaking and balancing, but now its in, i’m calling the game ‘beta’. You can read the full list of changes in this version on the forum here.

There will still be a good few weeks of tweaking, adjusting, balancing and checking before we actually take the game out of Early Access and declare it ‘released’. And even when that is done, its very likely that I will continue to spend a decent amount of time of improving and balancing the game. I don’t have any firm plans for expansions yet, but I’ll have time to think about it, and to ask people what they might like to see.

Production Line is the first game I’ve every released in early access on steam, although I’ve done low-key betas before (Big Pharma was one). I definitely have enjoyed the EA experience, but I think it could possibly be facilitated better within the steam platform…

I used my own system to gather data from players within the game to find out what the player-base thought my dev-priorities should be. I also had to use the ‘artwork’ upload part of steam a lot to share screenshots of stuff that was a work-in-progress or ideas for improvement. TBH it felt clunky, and not fleshed out.

There is also no way to tell (without collecting your own data) how many people have played a beta build on steam, making it a bit tricky to know that the ‘unstable’ branch had got enough testing before rolling out changes to everyone else.

Anyway… Its been great fun, and a lot of effort (and time!) has gone in. I even got into the habit of doing almost-every-week video blogs to document work on the game, here is the latest one:

I’ve really enjoyed doing those too, and will probably do a few more to highlight any post-release tweaks and ideas for expansions that might crop up after the game leaves early access. After that, it would theoretically be time to think about what game I would work on next (or consider ports of PL to other platforms). The thing is, we already have Democracy 4 in production, and as that gets closer to its initial Early Access (or even pre-EA), I’ll need to devote more time to producing that.

Finally its worth mentioning that the price of Production Line will go UP before release from its current $19.95 to $24.95. I’ve pencilled that in for 12th February, so if you were considering buying the game at some point, don’t wait too long :D And yup, we get the biggest cut of the money when you buy direct:

Maybe democracy as a system, cannot work any more

I’m from the UK, and if you are following the news, you may know that following a vote (referendum) to stay or leave the EU, we are soon about to Leave, unless there is a new vote, or its overturned in some other way.

I spent years really disliking the EU as an institution, although I have nothing against Europe or Europeans. It boggled my mind that the EU was run so badly, with a legislature and an executive in different cities, and a parliament that actually MOVED regularly to maximise its own inefficiency. The accountability of MEPs for expenses was laughable, their pay was tax-free (wtf?) and there were numerous examples of corruption, stupidity, and unfairness. I found the whole institution to be an embarrassment.

When the Brexit campaign started up, I found myself persuaded by the economic arguments for remaining. I was a ‘reluctant remain voter’, and voted to stay in. I thought it best to stay, and fight for a reformed EU.

Since then, there has been widespread coverage of the issues, and a lot of news about it, and I’ve read extensively. I am now a fairly passionate remainer, almost entirely for Economic reasons. I understand (and could argue convincingly) the argument for leaving, but firmly believe it would be a bad idea. I could talk for quite a while on the topic.

But here is where it all goes badly wrong…

To be totally honest, I am not informed, educated, or impartial enough to make this decision. I have my own prejudices to be aware of, as someone who is economically not concerned by either skilled or unskilled immigration. I do not fear for my job. Where I live, immigration is practically zero, and unemployment is incredibly low. This part of the UK is barely affected either way. Also if brexit resulted in higher food prices, I could afford it. If the £/$ tanked, I’d actually be BETTER off, as I’m paid in dollars. I have a skewed POV.

Add to this my incredible ignorance on the topic:

I could not (from memory) tell you if immigration went up or down last year, or what that level was. I have no idea if there is more (or less) skilled vs unskilled immigration, or what the unemployment rate is in those industries that attracted those immigrants. I cannot immediately tell you the rate of net tax/welfare contribution from immigrants vs residents, or vs EU/non-EU immigrants. I cannot state with any accuracy the rate of crime in areas more or less affected by immigration.

I did a degree in economics, but I cannot state for sure whether the UK needs more, or less immigration right now, or what effect this will have on interest rates, unemployment, wages or house prices. I cannot make any informed predictions about how any of those values will change over the next decade or two, or how they compare with the equivalent rates in any other comparable economies.

Additionally, I have no real grasp of how leaving the EU will affect UK law, whether it be corporate law, health and safety legislation, monopoly and competition law, tax rates, libel, criminal law or the rights of minorities. I do not know for sure what laws in the UK are dependent on, or bypass / overrule or are overruled by EU legislation, or how than can/will change in either the remain or brexit situation.

From a business POV I have a fairly strong understanding of how brexit would affect the UK games industry at my level, or the UK car industry (through my research for my latest game). I have zero idea the effect on fisheries (which could be hugely beneficial), medical (or other) research, education (esp universities), the financial sector or manufacturing.

In other words.. I have no fucking clue whatsoever about what the impact will be of Brexit or the impact of remain. Unless you can speak with experience, accuracy, and from memory on all of the above topics (and many more), to be honest, you have absolutely no fucking clue either. None of us do. I’m a game developer, full time (more than full time…) I don’t have time to research all of this stuff in the detail required to truly make an informed decision.

I am going with my gut feeling when I GUESS that remain is best, and so are you, regardless if you are pro or anti brexit. Unless you are a full time researcher, academic or civil servant working in a multi-discipline committee that looks into this stuff, you are as clueless about the real details as me.

And yet we vote.

How can this work?

By all means give me a vote on broad priorities, based on gut feeling and general emotion. I am a liberal kind of guy, who favours LGBT rights, personal freedom, equal pay, right-to-choose and so on. I am also an economic freedom guy, who is pro-business, generally small(ish) state, progressive but reasonable taxation, etc. I am an environmentalist.

But ask me to make finer-grained decisions on the technical policy making? ha! no! I have no idea. Like many of you, I *think* i know how to do it, and have great fun making and playing award-winning video games about this very topic! But i’m increasingly worried that I cannot be relied upon to make informed, sensible decisions about intensely complicated political or economic issues like Brexit.

If playing Democracy teaches you anything other than ‘compromise is often good’, it should teach you that ‘holy crap this stuff is complex, and very hard to predict’. Why are we trusting mere voters to make this sort of decision? I am arrogant enough to consider myself educated, informed, interested, analytical, and a good person. I don’t trust ME to have opinions on this, let alone someone whom none of those words apply to.

And it will get worse. Climate change, and our response to it, is not a ‘gut feeling’ issue. Its hugely complex. Should we allow GM food and support nuclear power? How should we legislate to protect our privacy in an internet-of-things age? what can we do to prevent automation creating vast inequality? how do we legislate 3D-printed guns? how do we defend society from malicious use of drones? how do we balance security vs freedom in air travel? and the big insane ones like ‘what do we do when true AI is created’? and ‘what if nanotech makes the current economic system collapse’ or ‘should we ban human cloning’? What do we do if antibiotics stop working (possible) or quantum computing renders cryptography obsolete overnight? These issues are HUGE.

Imagine the shitstorm if we actually make contact with alien life? How the fuck will we handle decisions in a situation like that?

They say Democracy is the worst form of government, apart from all of the others. I reckon we need to make sure that when we talk about democracy we don’t get lured into thinking direct democracy and referendums are as good as representative democracy. I don’t think direct democracy works now, and I think its only going to get way way worse…

The really scary thing to me is that everybody THINKS they are informed enough. None of us are. This is dangerous.

Writing your own engine for 2D games in C++: basic considerations

So with all the current stuff in the news about Unity/Improbable and the counter offers from unreal, and the big epic vs steam thing going on… I think there are probably a few developers out there who think to themselves… ‘I wish I *did* have my own engine, then I wouldn’t have to worry about ANYBODY else’s code. The problem is… if you are used to unity or similar systems, you might have no idea where to start right?

The windows basics:

To have an app that runs under windows you basically need just two functions, WinMain and a Windows ‘procedure’ function that handles windows message. A stripped down winmain looks like this:

int APIENTRY WinMain(
                     HINSTANCE hInstance,
                     HINSTANCE hPrevInstance,
                     LPSTR pszCmdLine,
                     int nCmdShow)
MSG msg;

gInstance = hInstance;
GetGame()->InitApp();

//main program message pump loop//////////////////////////////////
while(1)
{
if( PeekMessage( &msg, NULL, 0, 0, PM_NOREMOVE ) )//any for us?
    {
    if( !GetMessage( &msg, NULL, 0, 0 ) )//if so get em
        {
          return msg.wParam;
        }
    else
        {
            TranslateMessage(&msg);
            DispatchMessage(&msg);
        }
    }
else
    {
        if(BActive)
        {
            GetGame()->GameProc();
        }
        else
        {
            Sleep(1);
        }
    }
}
return msg.wParam;
}

The only two exiting parts are InitApp() where I create all the Directx3D stuff, and load in any data I need, and GameProc() which is basically the games main loop. The window proc looks like this:

LRESULT CALLBACK WindowProc(HWND hWnd,
                                 UINT uMsgId,
                                 WPARAM wParam,
                                 LPARAM lParam
                                 )
 {
 switch (uMsgId)
     {
     //main switch statement for handling messages
     case WM_DESTROY:    //end the application
         PostQuitMessage(0);
         GetGame()->ReleaseResources();
         return 0;
         break;
default://default behaviour
        return DefWindowProc(hWnd,uMsgId,wParam,lParam);    
      }
}

Again the only exciting thing there is ReleaseResources() which basically closes down all that directx stuff and releases all the textures and any memory I allocated.

meanwhile inside that InitApp() thing I need to do this:

int width = GetSystemMetrics(SM_CXSCREEN);
int height = GetSystemMetrics(SM_CYSCREEN);

Which gets the desktop res for me to create a window, and show it to the world:

gWnd = CreateMainWindow("Production Line", gInstance, IDI_ICON1, IDI_ICON1, WindowProc, width, height, bwindowed, bborderless, 0, 0);
UpdateWindow(gWnd);
ShowWindow(gWnd,1); 

After that I initialise all the directx stuff, which I have written about a decade ago, its pretty easy to grab all that from the directxSDK. BTW that CreateMainWindow function is mine too, and looks like this:

HWND CreateMainWindow(char* appname,HINSTANCE hInstance,int IDI_SMALL_ICON,int IDI_TINY_ICON,
                       WNDPROC proc,int width,int height,bool bwindowed,bool borderless,int left,int top)
 {
     WNDCLASSEX wcex;
HICON icon = NULL;
HICON iconsmall = NULL;
if(IDI_SMALL_ICON == NULL)
{
    icon = (HICON)LoadImage(NULL,"data/icon.ico",IMAGE_ICON,0,0,LR_LOADFROMFILE);
}
else
{
    icon = (HICON)LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_SMALL_ICON), IMAGE_ICON, 64, 64, 0);
    iconsmall = (HICON)LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_TINY_ICON), IMAGE_ICON, 32, 32, 0);
}

wcex.cbSize           =    sizeof(WNDCLASSEX);
wcex.hInstance        =    hInstance;
wcex.lpszClassName    =    appname;
wcex.lpfnWndProc      =    proc;
wcex.style            =    CS_CLASSDC | CS_DBLCLKS;
wcex.hIcon            =    icon;
wcex.hIconSm          =    iconsmall;
wcex.hCursor          =    NULL;
wcex.lpszMenuName     =    NULL;
wcex.cbClsExtra       =    0 ;
wcex.cbWndExtra       =    0 ;
wcex.hbrBackground    =    (HBRUSH) GetStockObject (BLACK_BRUSH);

RegisterClassEx(&wcex); 

int flags = 0;
if(bwindowed)
{
    if(borderless)
    {
        flags  = WS_POPUP;
    }
    else
    {
        flags = WS_OVERLAPPED |  WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX | WS_BORDER;
    }
}
else
{
    flags  = WS_POPUP;
}

HWND gWnd = CreateWindow(appname,appname,flags,
    left,top, width, height,
    NULL,//GetDesktopWindow(),
    NULL, hInstance, NULL);

return gWnd;
}

TBH the only fiddly bit is finding a program to actually create a decent windows ico .ico file in all of its myriad different sizes. Plenty of them exist, but its something you probably did not realise you need. I also have to use a batch file and a little command line thing to stuff the finished icon into the exe, so that it shows up in windows explorer as well as when the window is launched (weirdly these are different things…).

Thats pretty much all of the ‘initialisation’ code you need to create a windows app. Obviously you then need an actual graphics engine, but thats not *too bad* to write yourself if you are not coding something that is huge and requires amazing performance or tons of shaders.

In 2D, everything is pretty simple. You just need a sprite class (I have a Base Sprite, which is just 4 vertexes and a way to manipulate them by scaling, changing UV values, positioning them etc), maybe a textured sprite (the same but with a directx/opengl texture pointer), and if you want to optimise stuff you need a system that handles vertex buffers.

In general I just have one (big) vertex buffer that I stuff with sprites during the main game render loop, and then call draw() on it every time I need to change the texture or one of the render states.

Input stuff is pretty simple. You should just hook into the windows WM_LBUTTONDOWN messages and others like WM_CHAR, and do some processing on them. Way simpler than using middleware for all that. If you need to know the current state of a key you can use this:

bool CBaseInputManager::KeyDown(int key)
{
bool down = (bool)(GetAsyncKeyState(key)& 0xFF00);
return down;
}

I *do* use middleware for sound, but you can get pretty affordable, pretty simple sound middleware from lots of places these days. I have not updated my sound middleware for a LONG time. I don’t do any fancy sound processing so why would I? Playing an ogg file or streaming one…is not complex.

Now obviously if you have never coded outside unity, then there is a LOT of stuff you take for granted that you would have to now write some code for, but you only need to learn these things once. Loading in a file, or browsing a folder for files, is just a few lines of code. Even writing an absolutely bullet proof ini file loader that operates efficiently and correctly and without bugs is only 913 lines of code by my count, and thats a LOT of whitespace, helper functions and wrappers around it.

If you start writing an engine early, when you are still doing hobby games, preferably simple ones, you will find it quite easy to scale it up as you make more complex games. The code samples in this blog post have been stripped of their error checking, and some game-specific checks and extra processing to make them clear on first reading.

Basically every game I make involves me adding some new functionality to my engine. Production Line was the first game where I had to create an isometric object class, and isometric renderer (basically just a system to sort by Z and then render…), an animation compression system and some metric reporting and user-survey stuff, but that was probably just adding an extra 3-4% to the size of the total engine.

I wrote the multi-threading stuff ages ago (Democracy 3 if I recall), although I seriously improved it this time. The original windowed GUI system was coded for Starship Tycoon (OMG). Most of the directx stuff comes from Gratuitous Space Battles 2. The current text renderer dates back to Democracy 2 for its initial version. The vertex buffer code started in GSB 1.

Don’t get me wrong, there is a LOT of code in an engine, and it DOES take a fair bit of time, but its a big, long term investment that definitely pays dividends. I don’t have to worry if unity supports X or Y, or if it conflicts with Z, or if they are going to remove it without warning next week (or break it). All the code works in a style I like, and with absolutely zero bloat.

The source folder for my engine is 100 files and 620k total. Its not *that* big. Obviously it compiles pretty quickly and easily.

…and don’t forget you can still code using an IDE (Like Visual Studio) with built in code syntax highlighting and intellisense (I recommend visual assist!). Do not fall into the trap of thinking its unity OR just typing in a command line window without any help!

Is 2019 positech website redesign year?

I have been selling games a LONG time now (twenty years!). My first game to ever sell a copy was called ‘asteroid miner’ (later renamed star miner). Because in 1998 selling games online was all very ‘new’ I just used the root directory of positech.co.uk to store the shareware .zip file for my game demo, together with images not even in a folder, called ‘image1.jpg’ and other such unscalable stupidity. There was a ‘hit counter’ to show how many people had visited the website. A single screenshot, I think even a banner ad for someone else?

Anyway… the site has had a bunch of redesigns over those twenty years. it now supports https and even has a mobile version of the main page! it scales how much data it displays based on your screen resolution. (omgz). It now looks way better than it ever has, and currently looks like this:

Which is fine, and I like it, but there is a definite lack of consistency from an aesthetic POV the minute you leave the front page. Each game got a website designed ‘at the time’ with whatever cool ideas I had, or whoever I had hired to do the design. They all link back to the main page, and some of them even have ‘other games by positech’ hacked manually into the bottom of the page like this:

That approach never scales, because its just showing fixed games to people regardless how many years later it is, or the genre, or anything like that. Frankly I don’t shift many copies of Planetary Defence these days, so why even mention it. The approach is static HMTL, and its dated. Theoretically what I need is some sort of database driven website that shows my games, and cross links them properly.

Its not like I’ve never done it before, showmethegames.com was a vague attempt at that (although it never gained any real traffic). I could in theory code such a system myself, but I don’t want to spend the time (I am 100% busy developing Production Line & producing Democracy 4). The only motivation I would have for doing it myself would be that I HATE working with CSS/HTML code written by others, which is normally some over-templated bloated mess with at least 50x the code required to do the job.

So the question is…should I even be considering it? No doubt there are some great off-the-shelf products to build an online web store that would make it possible without a lot of hassle, but would I be losing the ‘feel’ of each individual games web page? Some of them have cool backgrounds, or videos surrounded by excellent artwork. Do I really want to reduce them all to the bland consistency of a steam store page style layout just for the sake of my own OCD and obsession with order?

Normally I would say no, but then i can’t help but think that steam, GoG etc all have standardised store pages, and nobody cares? Is the obsession with creating some sort of tailored ‘experience’ for visitors to your gaming website something that died out in the 1990s and we just are not accepting it yet. Its not like videos and lets plays and trailers are not a thing, do people really need a ‘shadowhand’ font on one page and the ‘democracy 3 CSS’ to give a different tone on a different game page?

I think there is an argument that the ‘big AAA studios’ who do this still are only doing it because its effectively 0.1% of their PR budget anyway, and they may as well cover all bases. In the end, isn’t a game really selling based on a screenshot, a short video, a review score, and the name?

The other way of looking at it, is what would be the upside? How many people buy big pharma direct from my website who don’t know we make production line, and would otherwise buy it right then (who would not have bought it at another point). Even if the number is 1% of total big pharma customers (and vice versa of course), is that really enough money to justify the cost and time to totally revamp the website?

I suspect, sadly it is not, and this may be relegated to a ‘wishlist’ thing. My own OCD and the fact that I think the current mishmash looks ‘amateurish’ are what is really driving me here, not any sort of business case. Its not like I’m looking for outside investors who may be put off by the aesthetics of my web page, and I really don’t care what people who are not customers think anyway.

Maybe I’ll reconsider it again sometime in 2029?