We must reach the Tower of the Moon by tomorrow

It’s been 15 score and 7 days since I last posted about The Lords of Midnight. Things have changed a little since I decided to make the games available for free on GoG and to remove them from the Apple and Play stores. Firstly my working situation didn’t change. This was mainly because the government shelved its implementation of the new IR35 rules that were coming in to effect in April 2020. The reason for this was the same reason that has turned 2020 topsy-turvy; Covid19.

During this time I still haven’t done much work on LoM deciding to keep to my self imposed exile. I did visit the land of Midnight time-to-time and managed to break the back of a number of issues, and I enjoyed my time there for the first time in a long while.

I have have finally pretty much completed the Cocos2dx port. I only say “pretty much” because until I produce a release with it, then I’m not sure of any issues that remain. There are some known Desktop problems and I haven’t looked at Android at all (other than it’s under Cocos so should work mostly).

I have also satisfactorily resolved the resolution independence problem that has increasingly gotten worse with Apple in particular going hell bent for leather to release as many different resolution phones as they can managed over the eight years since I original brought the new LoM to mobile. Some of you may have already see the wide screen screenshots that I have posted on Twitter.

With those two issues at hand, I believe I am very close to being able to bring The Lords of Midnight back to the Apple Stores soon. My intention (but don’t hold me to it) is to get the game in to TestFlight testing in January and get it in to the stores proper as soon as possible after that. There are a lot more Apple devices to test on this time around!

After that, I will look at resolving any desktop issues so that I can get the game into TestFlight for OSX in February.

If these two milestones can be achieved, then Android and Windows release will follow very shortly after.

This is the last few remaining issues that I would like to tackle before I push to TestFlight. Not all of them are required to push to TestFlight so I suspect I will attempt an early smaller test release just to go through the process.

Shading the night sky…

One thing that got carried over from the original Midnight Engine was the shading of the landscape depending on the time of day. The original Lords of Midnight, has a different colour for night which is basically that all the white becomes black, but the blue remains the same.

In TME and therefore the remake, I have a tint colour for each time of the day, and the images are tinted toward that colour. That colour is generally a shade of grey and it is used to darken the dawn, brighten up to normal colours around midday, and then dark off fully to night. In reality, this is one area of the remake that I left in that I don’t like. Only because, it doesn’t really look like the original. The night view has a very distinctive look, and as you can see though, the remake doesn’t look the same. It’s fine as things goes, but I would have much rather made it look more like the original.

Doomdark’s Revenge however has a completely different approach. There is a dawn visual, and day visual, and a night visual.

I knew therefore that when I got around to releasing Doomdark’s Revenge, I was going to have to deal with this issue. The tinting method just didn’t cut it. Because I could tint to red, or tint to yellow, but not combine them.

To give you a little background. The colour changing was relatively easy on the ZX Spectrum. Partly because the images were very simple and were constructed, but also because of the way that the spectrum only had two colours in a 8×8 grid – known as the paper and ink. So all the effects were done by just changing the paper and the ink. These colours were not stored with the bitmap either, it was a different memory area. So in fact, what Lords of Midnight does is, clear the screen with paper and ink both white, draw all the pixels to the screen, which you can’t see, and then fills in the paper and ink colours which makes the screen appear.

Now, the choice I made when porting the game was to use full 24bit alpha’d bitmap images. I can discuss the merits, and the whys, and possibly the mistakes, of this decision. But, it’s not been one I can change easily.

The upshot is: changing colours on the fly isn’t easy. It’s much easier with 8bit palletised images. But believe it or not, despite the fact that the terrain images only use two colours, they actually use at least 255 colours in order to get smooth edges, as well as being alpha’d. Changing to palletised images just made it look awful.

Once solution that I knew could work would be to write a custom shader. Shaders are dark voodoo magic that happen on the graphics card. And I’ve never written one in my life. Had Mike been around, he would have knocked one out very quickly. But obviously he wasn’t, and as I was heading toward the original release of The Lords of Midnight, I didn’t have time to look into them.

Now however, I couldn’t ignore it any longer. With the latest update of The Lords of Midnight sat awaiting approval from the platform holders, I turned my attention back to Doomdark’s Revenge, and the next thing to address, was making the dawn landscape look proper. I was going to have to learn to write shaders. And that’s what I spent yesterday doing.

The end result is that I now create all my terrain images as being black and white. These two colours will be replaced by the shader as the image is being drawn to screen. However, I can’t just replace the two colours, I need to make sure that I where the two colours meet they get blended.

mountain_fragmentIf you click on the Mountain fragment you will see a blow up of the image, and see how this would work. Affectively the image can be considered thus; all black, all white, mixed. The mixed part always being where the two meet. So if we consider that we will replace all black (0,0,0) with new colour_a and replace all white (255,255,255) with new colour_b, the other colours will be a shade of grey from (1,1,1) to (254,254,254). What we actually do is  use the value of one of the colour components to work out the mix of our two new colours. so 0 is 100% colour_a and 255 is 100% colour_b. A value of 153 for example would be 40% colour_a and 60% colour_b.

Now, it’s not rocket surgery, there’s nothing particularly clever going on here, but for me I had to turn this into a shader, and that was new territory.  However, working within the Marmalade SDK and using the OpenGL ES shader reference manual, and a little bit of google… the process turned out a little easier than I expected.

Here is the landscape without the shader active.

Screen Shot 2013-10-27 at 02.07.47

 

But with the shader active, and the two colours adjusted depending on the time of day, we  get the following.

And, if we now revisit The Lords of Midnight, we get the resulting night landscape that I always wanted.

Screen Shot 2013-10-27 at 01.10.33

 

Not sure when this will make it back into the current release, probably after Doomdark’s Revenge is released and I’ve been able to fully test the shader across multiple platforms. But it will make it back.

Version 1.11

lom_advert_for_mobilesI finally managed to push out the update to Lords of Midnight. All platforms have been updated to 1.11

This is the first time that all platforms have shared the same code base, and it’s the first time I have updated all platforms on the same day. It’s quite a big day as I’ve been trying to get this update out for a while, and I feel this marks the proper hand over to Doomdark’s Revenge. So, I really hope I haven’t missed something massive somewhere!

This will likely be the last update this year, unless of course I’ve messed something up. For the next 6 months I suspect all my focus will be on Doomdark’s Revenge. Not only getting it released, but those first few updates that will happen to it early next year after the initial release.

I full list of changes can be found here….

But I thought I might pickup and summarise a few of the items.

Big change was adding new grouping controls. You can now scroll around lords that are grouped making it easier to select lords from the select screen when they are grouped. You can also merge groups, disband with one click, change the leader of the group, and drag a lord from one group to another. You can also disband a group or leave a group from the think screen. Video of it working here…

There is more keyboard support on screens. This is for the desktop version and hopefully Android where it has keyboard support.

Mouse wheel support is there for the desktop version.

The scaling on the map is now available to the mobile versions. You can scale with pinch and spread, but I have also left in the scaling gadget on the mobile versions too.

Selecting lords on the Map screen has had a little work. You can now select the multiple lord icon in order to gain access to all the lords.

For iOS I have added an option to toggle between an ebook novella and pdf novella. I hadn’t considered that people might not have iBooks installed. But I have also added ebook support to the OSX version now that Mavericks is shipping with iBooks.

Two biggies that will make a difference to the game. You can no longer select a lord from the map screen when Luxor is dead and Morkin does not have the Moon Ring. This was a bug that would have allowed you to still control your lords even though you didn’t have the Moon Ring – sorry that exploit has now been plugged!

lom_advert_for_desktopsAnd, armies were fighting double at night. Which means battles would have been quicker than they should have been because double damage was being dealt out. This would have meant that you could have lost a fight without the chance of escaping, because you should have had a turn between the two battles. Or the armies on both sides are unable to get reinforcements between the two battles.

I hope you enjoy…