[13] Lunar Lander WIP [8/9]
- Conlan Walker

- Dec 24, 2021
- 3 min read
Updated: Jan 3, 2022
I'm trying to get a prototype done before New Years, so this post will show even more than the last. This comes at the cost of my free time, and I'm unsurprisingly quite exhausted.
I don't think there will be many major setbacks from now on, as most of the menial, framework stuff (barring some specific things) is done with. I say this because pretty much everything to do with the Moon and its physical behavior has been taken care of, along with tying up loose ends involving the lander's starting orbit.
The first step to completing that moon behavior is making sure the lander's distance to the Moon equates to the Moon's y position.

Since the lander is always centered on the screen, this can be done by just adding the lander's off-screen distance from (0,0) to the screen's midpoint to get the Moon's y position.
To avoid complications, I was now treating the lander's off-screen position as being 1-1 with the screen's pixels. While doing tests working with whole numbers to account for the Moon's massive resolution, I saw a problem emerge whenever the lander's position reached exactly 0 on an axis. I forget which axis, and precisely what problem, but it's probably because atan() doesn't like being fed numbers that were divided by 0.

A nice little Band-Aid should do the trick.
And do the trick it did, because it marked the end of any problem specifically relating to the Moon's y position and rotation:
(x&y in the top-left = the lander's off-screen position.)
Next up was to be add the lander's ability to use its thruster for moving around.
This video demonstrates the lander changing its velocity by the its thrust amount*throttle:
(x&y = the lander's current x and y velocity, while the green line shows direction of velocity.)
Now to deal with gravity, and the thruster sound effect.
I've pretty much given up on the whole usage of realistic gravity thing, as I don't really care enough to translate any real measurements and formulas to use for this. It also, unsurprisingly, simplifies things, seeing as how I can apply any arbitrary force vector from the lander to the moon every frame or so.
For the thruster SE, I wanted to use some minute-long, bitcrushed noise that doesn't change over time, which can be looped without much clipping.
Apparently that's a little too much to ask for, as whenever I googled something like "white noise generator" it just links a bunch of sleep aid sites.
I then tried Bfxr, only to be disappointed when I failed to make something that didn't noticeably change over time.
I ended up getting an Audacity bitcrusher plug-in that I found on a forum, and applied that to a minute of white noise. I then applied an EQ on it to remove some top-end hiss and the annoying parts and artifacts that stuck out the most.
This next video shows gravity (with a circular-ish starting orbit), and the thruster sound:
(The thruster's volume in db is on the top-right.)
You might notice a small problem with how the thruster volume changes based on throttle, because whenever there's a big change in volume suddenly, you hear a click.
The reason I could change the throttle so fast is that I added three buttons which set the throttle to off, medium, and full. I might make an option to turn the medium thrust button off for an extra challenge, as it was made to exactly match the Moon's gravity.
When I was only using the gradual thrust controls, this clicking was a nonissue, but with an instantaneous change in throttle comes an instantaneous change in volume.
To mitigate this, I added what I'm pretty sure is a low-pass filter:

And a demonstration of that low-pass filter:
(This video was taken after the cubic Bezier curve thing, which should explain the top-left)
This mostly affected rising-edge changes, but it also worked to reduce falling-edge changes by, like, half. I think this is due to the fact that I have the minimum allowed volume set past the point of reasonable audibility, and is therefore less affected by the 'ease out' behavior of this low-pass filter. In this next image, the graphs are visualizations of how I want the volume to behave, with the current low-pass filter on the left, and the desired behavior on the right:
(Source: https://darvideo.tv/dictionary/ease/)

(Specifically, It shows a rise of volume (y) over time (x).)
I realized that I might be able to use a cubic Bezier curve for this:
(magenta = ease-in-out; cyan = ease-out)

And what's a good Construct function without the feeling of guilt for having too many parameters/local variables:
(I hope that there's a better way to do this.)

I don't really have the time to complete the Bezier curve thing this week, as I'm writing this on Christmas eve, and It's getting late enough already.


As you can see, writing is slow for me, though these posts take less than three hours to complete on a normal week.

![[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