Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Show HN: Voxel Lunar Lander in the Browser (github.com/engineersneedart)
149 points by JKCalhoun on April 25, 2022 | hide | past | favorite | 64 comments


Cool game, but it has a pretty egregious physics error. It seems like the velocity vector of the craft always points in the direction you're facing. If you rotate the craft, then the velocity vector also rotates. It's like it's cornering on rails. This makes the game much easier than it should be.

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.


You're kind of right. I didn't want to make the game even harder than it already is but there is a fuel penalty involved for moving forward and turning.

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.


Would be amazing if you could turn this maneuvering assistance off!

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.


Ah, good to know it is correct internally!


"I'm also learning Javascript"

"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.


Fun! Made it from CRI to CAP with 2% fuel remaining :-)

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.


My thoughts are, going too high is a waste of fuel (in addition to getting up there, you have to brake coming down).

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.


Theoretically the best is to use max thrusters at the very beginning and very end. In practice you'll want to be a bit conservative.


This one is fun, the original Atari Lunar Lander in browser http://moonlander.seb.ly/


Thank you. Very badass. Probably the "simulator" that got lured me into writing computer games. I remember playing this in an arcade with the big throttle lever and rumble of the engines.


I like the style, design and sound effects, but as someone who is not especially great at computer games, and trying this out as a coffee break game, I found it pretty unforgiving:

- 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?


I had worried this would be a difficult game. I had a few people try it and they were happy to land at all! But to your point, yes, you cannot really be sliding sideways and land successfully.

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.


OK, so the landing short thing was due to two things

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.


Cool, thanks. Brave was not one I tested (HN crowd, I should have known right?). I'll try Brave and see if there is anything I can do for 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."


Having played older Lunar Lander type programs, I found this very forgiving. It autocorrects yaw for you and you can have a significant vertical speed before crashing. It did take me a minute to figure out the crosses were bases though.


1985 video games: defend earth from space invaders

2025 video games: deliver pizzas to the far side of the moon

Space Truckin' by Deep Purple

https://www.youtube.com/watch?v=hHOrpFeXUao




Minor nitpick: when asked to press Enter, only the main enter key is accepted ("Enter"), not the enter key from the numeric pad ("NumpadEnter"). Both keys share the same key code 13.


I'll fix that. I am using some sort Javascript key bindings that are using key codes rather than ASCII (so NumpadEnter is of course something else).


If anyone is actually able to land at a base (and is lowered down to be refueled etc.) let me know. The game is looking to be either too hard or has a serious bug. (And I'm not sure which is preferable.)

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 just get a welcome message about a smooth landing and nothing further.


Hopefully I just fixed this. Maybe try to refresh.


It worked fine for me.


On GitHub they mention that this issue has been fixed just now.


You wouldn't happen to be the John Calhoun who created the absolutely charming classic Mac game Glider[1]? I got many hours of enjoyment from that game.

[1] https://en.wikipedia.org/wiki/Glider_(video_game)


Didn't work well at all for me in Firefox, worked a lot faster in chrome. Wonderful game in Chrome though!


Same experience with the most recent versions of both on Kubuntu.


Same, but was fast at first and slowed to 1fps before reaching nearest base. Both in firefox and chrome.


I have no idea why. I have seen that on Chrome (not as bad as 1 FPS though). If I refresh upon landing, it's back to 60 FPS.

I don't see this on Safari.


When I tried to profile it, everything went too fast. Previously, going from PRB to PTO was several minutes, after I enabled profiling in firefox, it took several seconds (first 2 times I've crashed, because it was too fast for me). It was fast up to end, but when I was near PTO and about to land, everything slowed down and I had consistent 830ms per frame. I'll try to check later when I'm back from work.


Meh, now it works too fast, almost unplayable, I can't even steer properly, one keypress and speed is already +4. I believe it's after some change in code.


Cool!

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. :-)


Very KSP-esque, except there you usually have only one engine to work with har har.

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?


I used made-up units (and they are not even internally consistent). I was more concerned about providing enough resolution to help the player but limited by 2 or 3 digits (Nixie tubes) — I was less worried about being consistent.

You caught me, though.


I was confused by the units too. I like to mentally estimate how long it's going to take me to reach a certain altitude, for example, and the units displayed on the console didn't make sense to me. :)


I'll fix it, find a consistent scalar. I really didn't expect people to be "doing math" playing the game, ha ha.


I think your problem is that some people want to view it as a casual fun video game, and some people want to view it as a LEM simulator. The first group find it too hard and the second group find it too easy.

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.


I get better framerate by zooming in and out with ctrl-/+

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.


Minor UX bug: I did not realize holding the spacebar was how to thrust. I tapped it once to launch, it lifted and sat back down, and sent me to the "Welcome back!" screen!


This is very cool. I was able to take off and get to another base... but it doesn't seem to be the right one. How do you see what your destination is supposed to be?


When debriefed, you are given a rough heading for the near bases. You can decide on which base you want to head to, remember the heading.

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 landed at a different base but all that happened was I got a welcome message.~~ I guess I just wasn't landing precisely enough on the target. I set down on the glowing lights and got the welcome message, so I assumed I had done it correctly, but if I land very exactly on the shape in the center of the lights then I get taken in for refueling.


Very very nice vibe! Kind of Elite-esque.

I carried the first cargo to PTO and landed there but nothing happened. Was there I was supposed to do?


My guess is you didn't touch down in the base center. Care to make a screen shot and open an issue?

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).


Same here. In MoonDebriefState.js, the marked line errored out, because departedLocation was null.

     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)


I should have just fixed this if you refresh.

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.


Works!


Another way to handle this is to count every landing outside a pad a crash landing.


The Moon is not that harsh a mistress.

I do allow you to land anywhere — if your fuel is below some threshold I put up an alert allowing you to be rescued.


I seem to have gotten the rescue message even though I landed at a base. In the following screenshot I've landed at Maginus and it can be seen in the scope that I'm on the pad. Chrome 100.0 on Kubuntu 20.04.

https://imgur.com/qTdCtBM


Works great! Please make this (a paid) game on iPad!


The touch screen controls worked better than I expected from a browser game, very nice! Too bad I'm no good at the game.


Ok a fun challenge: make the first jump to PTO and land with as much fuel left over. 222 record so far.


2022 and a game with a handful of polygons makes my new laptop spin its fans at full speed.


Yeah, compare that to optimised version for Amiga 1200, what could be done with 14MHz processor, 2MB of ram, watch first minute:

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!


In fairness, demos are exceptionally optimized so I would not use them as a comparison.

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)


Software stack is not that bad, you can write naive algorithms in all languages. Typically just eliminating some inner loop calculations (like VoxelCanvas.js line 189 should just be a single addition) can give you double digit percent speed boost. I believe there are many more optimisations just waiting to be employed, but like I said, this is a toy project in a "hey look, it works" stage, it's very nice already.


Wow! I was very pleasantly transported back to the voxels of 1992 playing Comanche 3D.


Looks nice! I’ll give it a try on my desktop, since it’s not iPad ready.


Bummer, I should have tried it on an iPad. I one packed away somewhere. If someone doesn't beat me to it, I'll get a fix in for that.


Where shall I go though?


Hidden feature — scroll down, there is a map and brief directions below the game.




Consider applying for YC's Winter 2026 batch! Applications are open till Nov 10

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: