[14] Lunar Lander Release [9/9]
- Conlan Walker

- Dec 31, 2021
- 5 min read
Since this is supposed to be the last post I make on this game I spent a little over 2 months on, so I'll try to write this quickly, while still doing the work put into the game some justice.
Before the start of the week, I had some conviction about focusing on the thruster volume interpolation, before realizing that I could put my time to better use (and mitigate boredom) by creating some sort of choreographed win/lose condition first. It didn't need to be the entire win/lose handler with every bell and whistle, I just wanted it to explode or not to explode before resetting the layout. For the lander to explode, however, I need something to visualize that explosion in the first place. I did this by copying half of the process I used in Spacewar.
I'll show/skip progress in quick succession because it was technically a 9-step process.
Firstly, I got the original, which was some random greenscreen explosion I found on Youtube:
I then converted the video to a GIF, before cropping it to fit a 1x1 aspect ratio:

I wanted to trim down the length of the explosion to ~1 second, so I went and culled a few unnecessary frames, after which I turned the delay between frames to 3/100ths of a second, which works out to be ~33 FPS:

I then removed the background, which took some time to get the chroma key acceptable for.
I didn't need it to be perfect, as I was going to effectively convert it to grayscale:

Then I shrank and dithered it using a palette consisting of green and black, to match the game's very simple art style.

To finish it off, I culled even more unnecessary frames, while trying to align each frame to the center as much as I could:

I shrunk this to a small scale for the purpose of the sprite, but I was curious as to how it would look at a higher resolution. Here's an example of one 128x128 in size:

(I had to remove transparency for it to work with the dithering script, and I was too lazy to add it back in for this example.)

In total, this is the final size of the folder I was working in for the explosion sprite.
Since I now had an explosion animation, I had to come up with a solution for how a successful landing is handled. The one I came up with was in the form of 5 points:

When any part of the lander touches the Moon's surface, a check is used to determine if the landing is valid or not.
If any one of the red points are touching the moon, it means that the vessel either tried landing upside-down, or drop-kicked the Moon so hard that the entire lander got submerged in one frame. I think this might go without saying, but the game doesn't consider that a safe landing. Due to the topology of this Moon, a simple check to see if the lander is pointing up enough won't cut it. So, to make sure both landing struts connect with the moon, the game sees if both blue dots are overlapping the Moon's current collision polygon. If not, then also trigger a crash. (The blue dots are below the struts themselves to account for inaccuracies in the Moon's collision.)
None of these 5 points should be visible during normal play.
Going back to the thruster volume interpolation, pretty much everything to do with it and its implementation is not worth explaining, save for the only few notable things.
One of which being how it undergoes another change on top of the interpolation.
Since sound is logarithmic in terms of how loud it is, I wanted the volume's change to be perceptibly consistent with throttle. In other words, I wanted to make sure that a thruster set to 50% power sounded 50% quieter than 100% power (as closely as I could get it, anyway).
For this purpose, I was to use a sort of gamma-correction modifier.
For the sake of simplicity, let's say that the input volume is a number between 0-1, and its output shares the same range. In this case, the output will be equal to input^(1/2.5).
The below graph treats the x-axis as input volume, and the y-axis as its output:

The highlighted point shows that, for an input volume of 50%, its output will actually be ~76%.
I used gamma correction on two other occasions; one of which being the dynamic zoom. This is because most landing zones are at, or above the radius of the reference circle used to make the Moon. So I wanted to, for lack of better words, have diminishing returns for the zoom coefficient. The following is the brand-new formula to handle that:

Moving onto the rest of the win/lose handling, I ran into some trouble involving a specific and relatively simple mechanic that was supposed to take effect at the end of each landing/crash.
I wanted a little animation that showed the resulting score that round gradually negate, while the total score is added to at the same time. It would've made it seem like the points you just got were being poured into the larger, total score pool.

I spent about 40 minutes trying to get this thing to work, and this is what it looked like at the time of me giving up.
The problem stems from my difficulty controlling when events happen in relation to other events, at least when you try to add a delay, which suddenly makes that event in question asynchronous.
The only good thing that came out of that time is getting the idea to add your round score to your fuel. This addition of fuel shouldn't (and hopefully can't) be enough to sustain a net positive from, though.
The last main thing that involves gamma correction, is a part of the "Skyrim Horse Mode" that I talked about a few posts ago. I figured I'd add this to the main mode, as simply having a set score for each zone would get boring really quick. I'd go about this by seeing just how much the lander deviates from 270 degrees, for a maximum of 180 degrees of deviation.
I didn't want this bonus to be linear, because it gets disproportionately harder to land the weirder of an angle you try to land at. I get the gamma value to 2, which looks like so:

From the highlighted point on the graph, you can see that it only takes a landing of 20 degrees from being upright to have a 133% score multiplier.
And this is where I stopped bothering to document things, as I still wanted to be more or less finished with this by the end of Friday. I forget when exactly I clocked in and out on Wednesday, but from my notes it says I worked about 10-11 hours straight that day.
I can't tell you whether all of that time was put to good use or not, but what I can tell you is that this thing I called a game is now, by definition a game. It definitely has a lose condition, and its win condition is dependent on what high score you're trying to beat.
I've spent too much time writing this, and I know both this and the previous post need to be read in one day, so I won't waste much more of your time.
Here's the game link:
Here's some gameplay (when the two lines appear next to your velocity, it means you're within safe landing speed, <=0.3):
Here's some of the todo list that contains things ranging from 'would be nice to have' to 'game broken, fix it you idiot' (which I likely won't):

And finally, here's proof that you can land at a >90 degree angle (ignore the zone points and angle multiplier, as they were changed after this screenshot was taken):

I'm more than a bit tired, so I will sleep. I'll see you next year.

![[158] Most Important Brick in the Least Important Wall](https://static.wixstatic.com/media/df100d_f70be6ae4318455fbbc605cd1069c6ee~mv2.jpg/v1/fill/w_980,h_410,al_c,q_85,usm_0.66_1.00_0.01,enc_avif,quality_auto/df100d_f70be6ae4318455fbbc605cd1069c6ee~mv2.jpg)
![[157] Mail Order Sacrifice](https://static.wixstatic.com/media/df100d_e284fa6c51b04524bab9d3cf9f1f6441~mv2.png/v1/fill/w_980,h_382,al_c,q_90,usm_0.66_1.00_0.01,enc_avif,quality_auto/df100d_e284fa6c51b04524bab9d3cf9f1f6441~mv2.png)
![[156] Moat of Babble](https://static.wixstatic.com/media/df100d_091e451794b14aecb494a16c15c966c3~mv2.png/v1/fill/w_980,h_705,al_c,q_90,usm_0.66_1.00_0.01,enc_avif,quality_auto/df100d_091e451794b14aecb494a16c15c966c3~mv2.png)
Comments