from Hacker News

Show HN: Lander, a lunar lander style web game

by ehmorris on 3/5/23, 6:35 PM with 170 comments

I’ve been working on this game for the past few weeks. It’s written in plain JavaScript, mostly with canvas, with no dependencies.

The code is here: https://github.com/ehmorris/lunar-lander

  • by keyle on 3/5/23, 10:57 PM

    Good fun. A couple of ideas, zoom in as you approach the landing site, it's hard to see the difference between 4mph and 1mph; and consider having no landing spots, like craters or sharp edges; finally, some slow flying asteroids to avoid every once and a while. Consider planting a little flag from previous landing or tombs on crash sites on restart, to have some continuity. :)
  • by placatedmayhem on 3/5/23, 8:56 PM

    This feels like an achievement:

      Unbelievable, the crater is visible from Earth
      
      Score: 190.2 point crash
      Speed: 1612.3mph
      Angle: 98.6°
      Time: 220 seconds
      Flips: 0
      Max speed: 1612.3mph
      Max height: 4534ft
      Engine used: 15 times
      Boosters used: 129 times
      https://ehmorris.com/lander/
  • by lagrange77 on 3/5/23, 10:24 PM

      Perfect landing, incredible, you can’t get better than this
    
      Score: 99.2 point landing
      Speed: 1.0mph
      Angle: 0.2°
      Time: 52 seconds
      Flips: 0
      Max speed: 31.5mph
      Max height: 389ft
      Engine used: 99 times
      Boosters used: 7 times
      https://ehmorris.com/lander/
    
    I think my initial conditions were advantageous..

    Great game!

  • by djmips on 3/5/23, 10:53 PM

    The amazing thing is all these lunar lander games are harder than actually landing the lunar lander that landed on the moon. That's right it used a computer stabilized system and featured a fully automatic landing program however every lander was actually landed in the semi automatic mode where the pilot controlled the descent but the attitude was still maintained by computer.
  • by playingalong on 3/5/23, 8:06 PM

    Nice one.

    The left-right feel swapped to me, but I fail to give a factual reason.

    Also reminds me of two 90s era DOS games: Ugh and some other about landing on Moon. Similar to yours, but the lander looked like a small tower/crate (for lack of better description).

  • by kdawson on 3/18/23, 3:07 PM

    To counter those occasional asteroids that bizarrely, coincidentally seem to blast through the exact spot where the lander lands — how about adding the ability to take off again once having landed?
  • by ChicagoBoy11 on 3/6/23, 7:50 PM

    For folks for whom this is scratching an itch, highly recommend you check out Reentry: An Orbital Simulator. It is a beautiful indie passion project trying to faithfully recreate all aspects of the 1960s space era, in which you'd go through the actual steps necessary to operate the aircraft, including the lunar lander. It's awesome in it that it tries to be faithful, like NSSP and things of the nature, while also not cutting corners in the "game-like" parts of the experience, like textures, audio design, missions, VR capability, etc. If you enjoyed this for more than a few minutes, you'll enjoy poking around in it!
  • by joveian on 3/6/23, 3:32 AM

    You'll never improve on Astro Chicken :). Seriously, I loved that game when Space Quest III came out, although it seems others had quite a different experience.

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

  • by 7373737373 on 3/6/23, 1:57 AM

    I created a discrete (and less realistic) version of this concept here: https://qewasd.com/ ("Lunar Landing" challenge) - try to get a score as close to 0 as possible!

    Some people have managed to use MILP solvers to optimally solve some of the other problems

    Code here: https://github.com/void4/qewasd

  • by kdawson on 3/17/23, 6:55 PM

    Still addicted. Two suggestions: 1. Factor in time to landing in the score; faster times score higher. 2. Add an option to make the meteor debris damaging.
  • by drewg123 on 3/6/23, 2:02 AM

    Doesn't work for me. I can't get past "2 arrows at the same time". I press them, and see flame from both side thrusters, but the game doesn't register that I've done 2 arrows, and does not let me play. Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/110.0
  • by TeddyDD on 3/6/23, 10:12 AM

    Landed on first try, years of playing Kerbal Space Program have come in handy :D
  • by warent on 3/5/23, 8:37 PM

    Pretty fun! I like trying to make as many flips as possible:

      Basically a fender bender, but you landed
      Score: 45.4 point landing
      Speed: 3.5mph
      Angle: 9.5°
      Time: 62 seconds
      Flips: 18
      Max speed: 86.8mph
      Max height: 1276ft
      Engine used: 32 times
      Boosters used: 55 times
  • by dsego on 3/5/23, 9:43 PM

    How is this a crash, because of the angle?

        So, so close to a landing, but still a crash
    
        Score: 1.6 point crash
        Speed: 2.5mph
        Angle: 12.2°
        Time: 20 seconds
        Flips: 0
        Max speed: 34.5mph
        Max height: 221ft
        Engine used: 20 times
        Boosters used: 14 times
        https://ehmorris.com/lander/
    
    
    This is my best attempt for now:

        A good landing, keep trying
    
        Score: 84.1 point landing
        Speed: 4.5mph
        Angle: 0.0°
        Time: 23 seconds
        Flips: 0
        Max speed: 32.5mph
        Max height: 221ft
        Engine used: 26 times
        Boosters used: 13 times
        https://ehmorris.com/lander/
  • by Dave_Rosenthal on 3/6/23, 12:21 AM

    Tried to get a good landing with as few control actions as possible. For a simple new scoring system, subtract your number of control actions from your landing score:

      Very nice landing, amazing
    
      Score: 90.5 point landing
      Speed: 2.9mph
      Angle: 0.2°
      Time: 18 seconds
      Flips: 0
      Max speed: 53.7mph
      Max height: 425ft
      Engine used: 1 times
      Boosters used: 3 times
    
    So, a score of 86.5 in the new system.
  • by boomlinde on 3/5/23, 9:32 PM

    I like this kind of game, and this is perfect for a short diversion! This is the best I can muster for now:

        Very nice landing, amazing
    
        Score: 90.1 point landing
        Speed: 2.8mph
        Angle: 0.4°
        Time: 9 seconds
        Flips: 0
        Max speed: 38.7mph
        Max height: 240ft
        Engine used: 10 times
        Boosters used: 10 times
        https://ehmorris.com/lander/
  • by sporadicallyjoe on 3/5/23, 9:21 PM

    Tons of fun aiming for the different types of high scores. Here are mine:

    131 point crash - https://i.ibb.co/YdJ1c8B/131.png 426 max speed landing - https://i.ibb.co/5k5Csjt/Max-Speed426.png

  • by pmx on 3/5/23, 8:42 PM

    Had a great time seeing how fast I could make it go!

    Impressive speed, impressive angle - you crashed with style

    Score: 89.2 point crash Speed: 761.4mph Angle: 41.4° Time: 82 seconds Flips: 0 Max speed: 761.4mph Max height: 344ft Engine used: 97 times Boosters used: 45 times https://ehmorris.com/lander/

  • by chipsld on 3/6/23, 4:16 PM

    Near-perfect landing, super smooth

    Score: 97.5 point landing Speed: 1.4mph Angle: 0.2° Time: 17 seconds Flips: 0 Max speed: 53.3mph Max height: 377ft Engine used: 15 times Boosters used: 12 times https://ehmorris.com/lander/

  • by timbeccue on 3/5/23, 9:15 PM

    Love this! Very simple and creative.

      A solid “C” landing
    
      Score: 71.9 point landing
      Speed: 4.7mph
      Angle: 2.5°
      Time: 276 seconds
      Flips: 27
      Max speed: 114.4mph
      Max height: 1323ft
      Engine used: 58 times
      Boosters used: 63 times
      https://ehmorris.com/lander/
  • by marcodiego on 3/5/23, 9:08 PM

    Suggestion of improvement: landing should only be successful if lateral velocity is inside a limit.
  • by nfriend on 3/6/23, 12:31 AM

    Think I found a bug! Left the tab (on Firefox mobile on Android) and then revisited it, and now it says: "Perfect landing, incredible, you can't get better than this" with a score of 102.3 (I'm assuming 100 is supposed to be the max score?).
  • by madamelic on 3/7/23, 1:44 AM

      I don’t think we’re getting back to Earth
    
      Score: 34.4 point crash
      Speed: 187.5mph
      Angle: 122.8°
      Time: 88 seconds
      Flips: 7
      Max speed: 187.5mph
      Max height: 2336ft
      Engine used: 11 times
      Boosters used: 49 times
      https://ehmorris.com/lander/
    
    Amazing.

      A fast crash, but it could be faster
    
      Score: 82.9 point crash
      Speed: 689.8mph
      Angle: 56.2°
      Time: 79 seconds
      Flips: 0
      Max speed: 689.8mph
      Max height: 725ft
      Engine used: 3 times
      Boosters used: 46 times
      https://ehmorris.com/lander/
  • by DonsDiscountGas on 3/6/23, 6:04 PM

    Neat!

    Couple thoughts:

    * I first played this on my phone and the controls are basically backwards, touching right side of screen activates left booster. May be a subjective preference but when I went to a desktop and used the arrow keys (right key -> right booster) that was way more intuitive.

    * Does it consider sideways velocity in judgment? Like 5MPH up and down vs a little bit sideways.

    * For the love of Smoot please let me change to metric. Angles in radians would be fun too.

    Dunno how much complexity you want to add, but limited fuel would be a nice challenge to add. Or landing spot which is moving (up and down or sideways).

  • by Psychoshy_bc1q on 3/10/23, 9:34 AM

    Unbelievable, the crater is visible from Earth

    Score: 198.9 point crash Speed: 1,600.2mph Angle: 179.0° Time: 336 seconds Flips: 2 Max speed: 1,600.2mph Max height: 55,433ft Engine used: 7 times Boosters used: 97 times https://ehmorris.com/lander/

  • by anshumankmr on 3/6/23, 5:28 AM

    Just landed safely, so think I am sending my resume to NASA for the upcoming Moon mission.

    https://imgur.com/a/Qq5lqOm

  • by Sn0wCoder on 3/6/23, 1:31 AM

    Nice job on the game! Fully usable on my iPhone and only took me like 7 tries to actually land. Bookmarked to study the code and learn how you achieved such a nice end result. Thanks for posting.
  • by visika on 3/6/23, 12:07 AM

    Unbelievable, the crater is visible from Earth

    Score: 465.6 point crash

    Speed: 4010.5mph

    Angle: 178.0°

    Time: 986 seconds

    Flips: 509

    Max speed: 4010.5mph

    Max height: 409430ft

    Engine used: 4 times

    Boosters used: 126 times

    https://ehmorris.com/lander/

    It's 1 AM, I need to go to sleep...

  • by tillcarlos on 3/6/23, 12:40 AM

    Couple of great UX things I’ve found

    - the game doesn’t let you play without knowing how to use the controls, and it shows them in real time - whenever you tap, the tap area lights up.

    Small Details that make a difference!

  • by gavmor on 3/5/23, 8:16 PM

    Apparently, it's all about feathering the throttle. Very nice!

    Near-perfect landing, super smooth

    Score: 96.5 point landing Speed: 1.1mph Angle: 0.7° Time: 45 seconds Flips: 0 Max speed: 43.7mph Max height: 256ft Engine used: 73 times Boosters used: 37 times https://ehmorris.com/lander/

    ---

    I see it took you about seven months from "Initial Commit" to its current state. How did you stay on track all that time?

  • by helpfulmandrill on 3/10/23, 3:45 PM

    Very addictive.

    One thing that would be interesting would be a mode where you have limited fuel.

    Also, the ability to set different buttons would be good. Towards the end of the landing I want to use one hand for left-right, and the other for the booster rocket, and this is awkward.

  • by yesenadam on 3/6/23, 7:48 AM

    I found the font saying the speed and angle were much too small to read, and hard to read against the background anyway, so it was unplayable. No one else seems to have had that problem! macOS 12.5, firefox, 24 inch 1920x1080 display - pretty normal sized. Maybe it works on a phone. I tried zooming in but then I couldn't see the ground, and the font didn't get bigger.
  • by tla2 on 3/7/23, 8:29 PM

    Nice Game.

      Perfect landing, incredible, you can’t get better than this
    
      Score: 99.3 point landing
      Speed: 0.2mph
      Angle: 1.0°
      Time: 22 seconds
      Flips: 0
      Max speed: 33.6mph
      Max height: 227ft
      Engine used: 12 times
      Boosters used: 11 times
      https://ehmorris.com/lander/
  • by TheMagicHorsey on 3/7/23, 1:22 PM

    Great fun!

    Terrible landing, you need to land slow and straight

    Score: 18.6 point landing Speed: 10.0mph Angle: 8.9° Time: 23 seconds Flips: 0 Max speed: 22.5mph Max height: 248ft Engine used: 25 times Boosters used: 16 times https://ehmorris.com/lander/

  • by joshuaheard on 3/5/23, 11:42 PM

    Great game. It took me a while to figure out how to start the game. I'd put a "Press space bar to start" somewhere.
  • by mebble on 3/6/23, 2:33 PM

    I think you meant to do that

    Score: 75.8 point crash Speed: 509.3mph Angle: 172.9° Time: 101 seconds Flips: 0 Max speed: 509.3mph Max height: 6618ft Engine used: 8 times Boosters used: 42 times https://ehmorris.com/lander/

  • by zoklet-enjoyer on 3/6/23, 12:03 AM

    It took a lot of tries, but I just barely made it eventually! Btw I'm on my Pixel 7 and it works better than I'd like expected on a phone. Seems like it'd be easier with a keyboard though?

    A near-crash, way too fast

    Score: 35.0 point landing

    Speed: 9.7mph

    Angle: 5.6°

    Time: 8 seconds

    Flips: 0

    Max speed: 35.9mph

    Max height: 197ft

    Engine used: 2 times

    Boosters used: 6 times

    https://ehmorris.com/lander/

  • by bluedonuts on 3/5/23, 9:45 PM

    Basically a fender bender, but you landed

    Score: 53.6 point landing Speed: 9.8mph Angle: 1.4° Time: 566 seconds Flips: 182 Max speed: 635.2mph Max height: 62510ft Engine used: 109 times Boosters used: 145 times https://ehmorris.com/lander/

  • by frutiger on 3/5/23, 9:30 PM

    Unbelievable, the crater is visible from Earth

        Score: 345.1 point crash
        Speed: 2928.9mph
        Angle: 175.6°
        Time: 696 seconds
        Flips: 28
        Max speed: 2928.9mph
        Max height: 299886ft
        Engine used: 37 times
        Boosters used: 194 times
        https://ehmorris.com/lander/
  • by fatneckbeard on 3/6/23, 1:27 AM

    A near-crash, way too fast

    Score: 34.7 point landing Speed: 5.2mph Angle: 10.1° Time: 28 seconds Flips: 1 Max speed: 25.5mph Max height: 138ft Engine used: 16 times Boosters used: 19 times https://ehmorris.com/lander/

  • by CyborgCabbage on 3/5/23, 11:15 PM

    Fun game! It would add more to the game imo if there was a fuel efficiency target as well as angle and speed.
  • by throwanem on 3/6/23, 12:07 AM

    As ever, this is the kind of problem I find more fun in programming a computer to solve than in solving myself, by hand. But this is a fun implementation! Good controls, too - it only took me two tries to land, which is better than I ever managed with an Apple II and a keyboard as a kid.
  • by watmough on 3/6/23, 12:05 AM

    Sweet game!

      Near-perfect landing, super smooth
    
      Score: 95.5 point landing
      Speed: 1.9mph
      Angle: 0.1°
      Time: 57 seconds
      Flips: 0
      Max speed: 31.6mph
      Max height: 147ft
      Engine used: 82 times
      Boosters used: 33 times
      https://ehmorris.com/lander/
  • by keraf on 3/5/23, 11:07 PM

    Awesome game! Really addictive :-)

      Perfect landing, incredible, you can’t get better than this
    
      Score: 101.1 point landing
      Speed: 0.7mph
      Angle: 0.1°
      Time: 26 seconds 
      Flips: 0
      Max speed: 32.4mph
      Max height: 194ft
      Engine used: 53 times
      Boosters used: 30 times
  • by wbillingsley on 3/6/23, 3:53 AM

    Give this one a go, you know you want to...

    https://theintelligentbook.com/thinkingaboutprogramming/#/de...

    (programmable lander)

  • by bxparks on 3/5/23, 8:39 PM

    Awesome, the highest crash landing speed I was able to achieve was 97.7 MPH after about 20-30 attempts.
  • by gkfasdfasdf on 3/6/23, 12:28 PM

    This game is gorgeous! It would be nice if the left and right thrust controls could be swapped.
  • by thewebcount on 3/5/23, 11:46 PM

    On an iPad, it’s very hard to hit the left/center/right targets accurately. I got some successful landings, but there was a lot of, “No I said center, not left… no, center, not right… ah crap!” If there were keyboard controls, that would help, I think.
  • by gwd on 3/6/23, 12:19 PM

    I seem to be running into a bug where the velocity gets mis-matched somehow -- the velocity will be listed as above -12 m/s even though the rocket is actually going up, which obviously makes it impossible to land.
  • by exebook on 3/5/23, 8:11 PM

    Wanted to play, but after the tutorial a first touch makes the ship disappear. When I reload the page, I can see the ship again, and the landing curve, then again if I touch the screen everything disappear except for the stars.
  • by LorenDB on 3/5/23, 8:33 PM

    I'd love to see an indicator showing how quickly you are rotating. That would make the final touchdown a lot easier to get straight, IMO.

    Also, could the trajectory stay visible at all times? That would help plan burns better.

  • by squarefoot on 3/6/23, 2:55 PM

    Crashed only once, but for a good one had to practice a dozen times at least.

    A good landing, keep trying

    Score: 82.2 point landing

    Speed: 4.3mph

    Angle: 0.7°

    Time: 17 seconds

    Flips: 0

    Max speed: 34.7mph

    Max height: 210ft

    Engine used: 7 times

    Boosters used: 7 times

    https://ehmorris.com/lander/

  • by elwell on 3/5/23, 11:34 PM

    Here's a lunar landing copy I made 15+ years ago, Java *applet*: https://github.com/celwell/space-landing
  • by MiskaMaki on 3/5/23, 11:24 PM

    Great game! For me, controlling the rocket was not that handy, somehow I always wanted to press the opposite button. Will be a option to swap the left and right buttons? That would be great! :)
  • by swyx on 3/10/23, 7:25 AM

    love it!

        A good landing, keep trying
        
        Score: 83.5 point landing
        Speed: 3.8mph
        Angle: 0.8°
        Time: 44 seconds
        Flips: 0
        Max speed: 32.1mph
        Max height: 257ft
        Engine used: 25 times
        Boosters used: 19 times
        https://ehmorris.com/lander/
  • by ziedaniel1 on 3/5/23, 8:41 PM

    I enjoyed the easter eggs!
  • by therein on 3/6/23, 10:28 PM

    I played this game on OSX, Windows and Linux using Chrome.

    The game is a lot easier and a lot more enjoyable to play on OSX. I reckon it has something to do with the input handling.

  • by poopsmithe on 3/9/23, 5:37 AM

    Love it. Want more. I would love to see different scenarios and, challenges. Obstacles? different gravity/planets?
  • by LastTrain on 3/6/23, 4:14 AM

    I'm going to give you some feedback like your game did me: pretty bad lunar lander game, but it could be worse! Just kidding, I played it a bunch of times pretty fun.
  • by pugworthy on 3/6/23, 12:41 AM

    It would be nice if the "how to play" screen gave keyboard equivalents. I was about to give up trying to play until I saw someone's comment about arrow keys.
  • by mjw_byrne on 3/6/23, 12:19 AM

    I feel like the lunar landing aspect is incidental, and this is fundamentally a "impossible-to-please parent for whom nothing is ever good enough" simulator :-)
  • by perilunar on 3/5/23, 11:56 PM

    Nice work!

    I think speed should be in ft/s to match height in ft. IIRC on Apollo they used ft/s for descent speeds. (an option for metric would be nice also)

  • by nfriend on 3/5/23, 8:19 PM

    Love it! It's like a cross between Flappy Bird and Asteroids. Nice tutorial at the beginning, too.

    Just managed to get a 98.5, which I think was mostly luck.

  • by zamadatix on 3/5/23, 10:59 PM

    Crashing sideways is fun, the exploded parts continue to wrap around the screen if you "land" sideways fast enough :D.
  • by tumidpandora on 3/5/23, 11:26 PM

    Terrible landing, you need to land slow and straight

    Time: 8 seconds

    Flips: 0 Max speed: 39.0mph Max height: 173ft Engine used: 2 times Boosters used: 5 times

  • by _tom_ on 3/5/23, 11:01 PM

    Left and right are backwards on a phone. I'm sure I'd adapt after a few more games, but it's annoying.
  • by mousetree on 3/5/23, 8:01 PM

    Had a lot of fun
  • by jzer0cool on 3/6/23, 12:07 AM

    Enjoyed playing! Controls are smooth. Would you mind sharing tech used to design the game and exported to html?
  • by maxverse on 3/6/23, 12:51 AM

    Loved the soundtrack, too! Very fitting.
  • by Evidlo on 3/5/23, 9:39 PM

    The lander disappears as soon as I touch the controls and never crashes. Iceraven 1.14.0/Android 11
  • by siliconsorcerer on 3/5/23, 8:37 PM

    Had a ton of fun with this :) thanks!
  • by davidw on 3/6/23, 1:48 AM

    Playing the lunar lander game on a Commodore PET is one of my earliest computer memories.
  • by markm248 on 3/5/23, 9:30 PM

    Way more fun if you try to see high you can get your crash score. 26.3 personal best
  • by xeornet on 3/6/23, 7:22 AM

    It seems that higher refresh rate screens make this game significantly harder..
  • by the42thdoctor on 3/6/23, 12:10 AM

    Great game, why can't it go on all directions ? lef, right, down AND UP ?
  • by abhaynayar on 3/6/23, 2:39 PM

    Reminded me of a game I used to play on Miniclip called UFO Joe!
  • by jefc1111 on 3/5/23, 9:42 PM

    Fun! I'd like to get a bonus for rotations in both directions.
  • by johnklos on 3/6/23, 3:48 AM

    Neat, and fun!

    But why does it consume 100% CPU when sitting at the results screen?

  • by geuis on 3/6/23, 3:39 AM

    Fun. Weird that controls are reversed (left/right).
  • by aizyuval on 3/6/23, 1:15 PM

    very good one! Though it wasn't completely clear to me how rating was calculated.
  • by chrisweekly on 3/5/23, 10:37 PM

    Awesoem job! Thanks for sharing!!
  • by amsterdorn on 3/6/23, 11:20 AM

    Love it, great work!
  • by QuiCasseRien on 3/5/23, 10:59 PM

    Extremly addictive p
  • by TurkishPoptart on 3/6/23, 11:45 PM

    i love the confetti/fireworks! great game
  • by georgehill on 3/5/23, 11:51 PM

    well spent 10min, this is a good game!
  • by FigmentEngine on 3/5/23, 10:11 PM

    671 flips, lol
  • by ian0 on 3/6/23, 8:20 AM

    Good fun!
  • by outside1234 on 3/6/23, 1:43 AM

    VERY FUN
  • by funtoos on 3/6/23, 9:57 AM

    great game thx
  • by antiquark on 3/5/23, 8:00 PM

    This is like KSP but without the fun.