Show HN: Voxel Lunar Lander in the Browser
github.com
github.com
In reality, if you are travelling forwards at some speed and then rotate the craft to one side, you'll still be travelling in the same direction as before. The world you see out the window will appear to be flying past sideways, because you still need to cancel out your previous forwards velocity.
The moon craft is applying the correct horizontal thrust to allow you to "corner on rails" but subtracting that thrust from your fuel.
You notice if you have no horizontal movement, yaw takes negligible fuel: a short burst rotates you and you can indefinitely rotate without additional fuel.
The instant you have a horizontal component, there is a continuous fuel penalty as you rotate — because, as you point out, an additional velocity vector is required to keep you both moving forward and turning.
It's much more fuel efficient to establish the direction you want to fly the craft before applying forward thrust.
On kerbal space program, I can lower my periapsis until my orbital trajectory intercepts my target and then allow gravity to take me there. I always keep the ship pointed retrograde in order to control its speed.
"There is nothing terribly complex about this algorithm — an understanding of basic trig is all that is required."
"After a 30-year hiatus, back to writing shareware, ha ha."
I LOVE seeing stuff like this. Keep hacking till the lights go out.
I fly like this, any suggestions?
- decide which base you want to fly to and rotate your craft in that direction.
- blast off until V-speed of +40ish, while simultaneously going full forward (unless you have a mountain just in front, obviously, as for example when you fly from PTO to PAR, or MAG to PRB). H-speed cuts of at 30 automatically.
- that should take you up to around 70 [units], cruising full forward. That seems to be high enough to avoid obstacles.
- when V-speed drops to -5, take it back up to +5, in other words, 0 +/- 5.
- observe the map, and when the base approaches, correct the heading.
- at some point now, you should see the base lights in the window. Aim there.
- don't decrease horizontal speed prematurely, it'll cost you fuel to stay up. And don't decrease altitude prematurely, it'll make it harder to see the base in the scope.
- consider the cross on the map as a distance measure. When you are two crosses away, start taking H-speed down slowly. When you're one cross away, H-speed 10 works.
- once you see the base in the scope, you can do fine-tuning, arrest H-speed, and descend. As JKC mentioned, avoid any horizontal speed when touching down. Try to keep V-speed > -5, at the latest when the ALT light turns on. (Touch down V-speed > -3 is very smooth, > -6 is ok, < -9 is a crash.)
- rule of thumb: keep V-speed > -altitude.
Full forward velocity as soon as you can — slow only when closing on the base. (Faster you can get to your destination, again, less fuel needed to stay aloft.)
It is not unusual for me to land with empty tanks. As long as you have stopped horizontal velocity, it is somewhat forgiving vertically (I suppose the landing shocks are well engineered).
BTW, the landing gear on the Apollo LM employed a collapsible honeycomb that absorbed energy by being crushed. Of course, works only once.
The X-20 Dynasoar was to have a similar shock absorber for landing — some sort of metal tensioning wires that took up energy by being stretched.
I was trying to straighten copper wire (the kind you run in your home) by holding one end very firmly in a vise and then putting my strength into pulling on several feet of the wire with a pair of vise grips. It was hard to pull, but there was a fascinating moment when the wire "gave" and I was able to stretch it an inch or so at which point I was unable to stretch it any further.
Straightened the wire for sure. But what an odd molecular dance there must have been going on within that copper.
> going too high is a waste of fuel
The height is not only to avoid terrain, it is also to buy you time to move horizontally. It is more efficient to go higher at the beginning of the flight and taking a parabolic path than to try to maintain altitude any lower. Even with the braking burn, which for the same reason should occur as low as possible. Your engine is most efficient when your craft is moving quickly - the Oberth effect.- it initially took me maybe a minute just to work out that the things on the display were craters, not bases
- having worked out how to find a base, I made several journeys (each a couple of minutes) to get to one, but each time either crashed or landed short. When I landed short I then always crashed in my attempt to shuffle along a bit further.
- I'm not sure exactly which bit counts as the landing zone? initially I was hampered by not realising you have a separate display of the area directly beneath your craft, maybe it's more obvious if you use that.
- I then practiced landing on the starting base for a bit to try to work out the max allowed vertical + horizontal speed. I think maybe the vertical speed is approx max -8 or something, or at least seems pretty forgiving. Meanwhile I think possibly the horizontal speed maybe needs to be exactly 000, and that arrow next to 00 isn't allowed? Ran out of time for further experimentation.
- If you land on the starting pad you get a message congratulating you on landing but I can't work out how to close the message (other than refreshing)
- I then had several more attempts at flying to another base, and crashed several more times, as well as landing short several more times.
- when I eventually landed on another base, nothing happened and I wasn't quite sure what to do next. Did that count as delivery? Do I just keep flying between bases?
The controls will stop thrusting when you reach a horizontal velocity of zero though, so it is easy to "stop".
When you land right in the middle of the landing pad (cross, square, whatever shape) you'll be lowered down to the base.
My best guess is you're not within the landing zone. (Or there's a bug I have not seen.)
There should always be a closing box for the alerts though. If you can take a screen grab and open an "issue" I'll see what I can do.
EDIT: Seeing a bug show up in my code on Firefox. I'll see if I can quickly patch. Looked like I was assuming I would get a value from LOCAL STORAGE. I should have tested by blowing away my storage. See if it works for you now.
1. I was using Brave, and the voxels for the landing zones seem to be messed up for some reason, with coloured blobs scattered everywhere. I switched to Chrome and the centre is more obvious.
2. As mentioned before, I didn't realise there was a downward facing camera to use.
But the the issue with not being able to close dialog boxes happens for me in both Brave and Chrome. Seems someone else already raised this an issue, same error as me: I looked in the console and found an error, and seems someone else has already raised the same issue: https://github.com/EngineersNeedArt/Mooncraft2000/issues/1
Also looks like there's already a commit that might fix it.
Yeah, see if my fix fixed it. I pushed it up to my server so you might just try refreshing.
Should have titled this post: "HN, Help me debug my web game."
2025 video games: deliver pizzas to the far side of the moon
Space Truckin' by Deep Purple
EDIT: looks like it was a bug (fixed now?). Of course, it occurs to me that it might also be too hard of a game — that both the above could be true.
I don't see this on Safari.
Note that (on the map) it should be Mare Serenitatis, not Mare Serenitatus.
Even though we have a stereotype of Latin words ending in -us, they can also end in -as, -es, -is, or -us, depending on the grammatical context. :-)
Is the vertical velocity in the same units as altitude? Seems like I can get like 5 m/s downward speed and altitude barely changes. Or is it set up as one or two decimals less?
You caught me, though.
In case it helps: I would expect the rate display to be in units/second or units/minute, in order to estimate an amount of time in a useful way.
Looks nice very cool flying over that terrain. I wonder if it would be better with higher resolution I'm guessing if the graphics is better you get the uncanny valley problem.
But you can cheat too: scroll the document window to reveal a handy map of the bases. I can hold my finger out to approximate the angle to where I want to go — scroll back to the main screen to set my heading to be at the same angle.
(In fact though, it doesn't matter which base you go to. I guess everyone is happy with whatever you happen to land with.)
I carried the first cargo to PTO and landed there but nothing happened. Was there I was supposed to do?
At the very least I should let the player know they are off by a hair on the landing (if that turns out to the the case and not just a bug).
var departedLocation = LunarFeatures.locationForBase (baseDeparted);
> var deltaX = departedLocation[0] - _base.loc_x; <
var deltaY = departedLocation[1] - _base.loc_y;
_distanceTraveled = Math.floor (Math.sqrt ((deltaX * deltaX) + (deltaY * deltaY)));
(Safari 15.4 on macOS 12.3.1)There is a value I expect to find in LOCAL STORAGE that is null when you first try play the game — I was not allowing for that.
I should have know to blow away local storage when testing. Since I have been developing it, of course, at some point that value was added to my local storage and I was free to write all manner of bugs that assume it is there.
I do allow you to land anywhere — if your fuel is below some threshold I put up an alert allowing you to be rescued.
https://www.youtube.com/watch?v=q0QonT359uI
This version could of course also be optimised, but don't expect top-notch optimisation from a learning project. It's still pretty nice and it works!
Yet, we are talking of 30 years of hardware evolution here (The Amiga was from 1992) to get the same performance. This is comically bad.
(I'm not blaming the game itself, but the software stack)