Settings

Theme

Show HN: A CSS-Only Terrain Generator

terra.layoutit.com

371 points by rofko 2 months ago · 87 comments

Reader

senfiaj 2 months ago

When I turn off JS, it shows a loader instead of the terrain. Is this really CSS-Only? I mean it's still a high achievement even with JS, but was expecting it would also work without JS. This one, for example, truly works without JS https://benjaminaster.com/css-minecraft/ .

  • arbll 2 months ago

    I'm assuming it's the render engine that is in pure CSS. You could display a static map in CSS but things like the tools to modify the terrain definitely need JS.

    • psygn89 2 months ago

      You might not need it using the new :has() and different inputs as modifiers. Though that's a lot of :has() and probably would kill performance.

    • thih9 2 months ago

      I wanted to check if your assumption is correct but I couldn’t find the source code.

      Why do you think the renderer is pure css and not e.g. mostly css?

      • embedding-shape 2 months ago

        The top right button has a "Download code" which gives you a .zip file. That .zip file doesn't have any JS in it, and renders the terrain just like in the online editor, except you can turn off JS and it still works.

        Edit: someone else wrote basically the same an hour ago: https://news.ycombinator.com/item?id=45814791

        • thih9 2 months ago

          Looks like it’s a “(css-only terrain) generator” - a generator that lets the user create and download a css only terrain.

          As opposed to a “css-only (terrain generator)” - a terrain creation studio built with css only.

    • nightpool 2 months ago

      GP linked an example of a similar project that allowed you to modify the terrain without any JS at all

  • decimaldesign 2 months ago

    I think what's intended is that the completed and downloaded solution doesn't require any javascript.

    Build something then hit the Download Code button - that packaged HTML solution doesn't require any javascript to render locally.

    • senfiaj 2 months ago

      Yeah, it worked, it seems to be a static rendered html with no interactivity though.

forthwall 2 months ago

Wow this really feels like roller coaster tycoon!!! (I can see lots of people refer to this to their favorite sim game though)

Great work!

  • yreg 2 months ago

    I really miss these building games that used an isometric grid. RC Tycoon, Zoo Tycoon, Sim City, TTD, …

    Yes, it's less realistic, but it is so pleasant to work with. Everything you build aligns perfectly and if you want, you can neatly fill the entire map.

    In comparison, (even with many mods) my Cities Skylines or Planet Coaster creations never look quite right. Building the roads and paths is always awkward and frustrating.

    (I've commented this before.)

    • qingcharles 2 months ago

      As someone who wrote one of those 2D-ish isometric games in the 90s, it was hell. All the problems with trying to render the tiles properly and figure out what tile the user was clicking on when some tiles are semi-transparent etc. The artists need medals though for creating amazing levels with tiny palettes of pieces to work from.

      We made it especially hard on ourselves by having 3D characters interact with the 2D tiles:

      https://www.youtube.com/watch?v=9UOYps_3eM0

      I absolutely adore the look of isometric, though.

    • accrual 2 months ago

      Starcraft and The Sims 1 as well! Games that would let one rotate the isometric view once blew my mind, it was like going from 2D to 3D.

  • devmor 2 months ago

    Reminded me quite a bit of Populous[1] as well.

    1. https://en.wikipedia.org/wiki/Populous_(video_game)

  • andruc 2 months ago

    Funny, my mind went to OpenTTD

    • mig39 2 months ago

      Both Rollercoaster Tycoon and Transport Tycoon Deluxe (which lives on in openTTD) are by the same author, and use the same engine :-)

      • lawlessone 2 months ago

        Chris Sawyer, he made them with a tiny magnet that he used to write the games directly to a hard drive.

        • brendoelfrendo 2 months ago

          I once heard he tickled a butterfly in Brazil to cause a cloud in the UK that diverted a cosmic ray onto his hard drive in the exact right spot to flip the required bit.

    • hulium 2 months ago

      The biome button graphics are taken from the OpenTTD main menu.

  • Igrom 2 months ago

    For me, "Briefing" from Ace Combat 2 played back in my head straight away.

    https://youtu.be/5uPVGs7bq3s?t=8

  • lawlessone 2 months ago

    I like it's also really 3d, while looking like older 2.5d games.

  • worldai 2 months ago

    This is exactly what I thought of

cmiller1 2 months ago

Lots of javascript for a "css-only" tool. Looks like just the rendering is css-only.

  • jonahx 2 months ago

    You can open up your terrain in codepen with nothing but CSS/HTML, and it renders fine. It's just not interactive / draggable anymore.

    So the JS is only being used, essentially, as a nice UI for configuring your terrain and the camera angle from which it's viewed.

    This is still an incredible feat.

  • bogwog 2 months ago

    I guess it'd be more accurate to call it a "Generator for CSS-Only Terrain", as the generator itself is not CSS-only.

  • embedding-shape 2 months ago

    Not to mention of all of those pesky HTML tags and images, clearly not CSS-only, what a fraud.

    • cmiller1 2 months ago

      "CSS-only" colloquially tends to mean HTML and CSS without Javascript, sometimes without images.

      • DonaldPShimoda 2 months ago

        The tone of the parent comment suggests they were writing in jest and are aware that "CSS-only" includes HTML.

  • MarsIronPI 2 months ago

    Yep. Can confirm this does not work with JS disabled. I'm disappointed by the misleading title.

    • shermantanktop 2 months ago

      is it a Generator for CSS-Only Terrain? or a CSS-Only Generator which creates Terrain?

      We need PEMDAS for English.

      • Elfener 2 months ago

        Let's use sexpr?

        actual meaning -> ((CSS-Only Terrain) Generator)

        incorrect interpretation -> (CSS-Only (Terrain Generator))

        • shermantanktop 2 months ago

          maybe RPN?

          actual meaning -> CSS-Only Terrain + Generator +

          incorrect interpretation -> CSS-Only + Terrain Generator +

          Really we may need BNF here

      • MarsIronPI 2 months ago

        Loglan anyone?

julius-fx 2 months ago

This is incredible - looks like SimCity 2000.

RugnirViking 2 months ago

Really reminds me of openttd, especially the sandy border around the water

Looks really cool and runs great on my phone.

Seems like there's some kind of rendering bug in the corners sometimes causing the walls to intersect the grass

mpeg 2 months ago

Reminds me of Populous!

Very cool

  • rofkoOP 2 months ago

    Thank you! Populous and Transport Tycoon were two big inspirations for sure :)

  • johnh-hn 2 months ago

    I just came here to say the same thing. The raise and lower tools in particular reminded me of it.

    For anyone who hasn't heard of it before: https://en.wikipedia.org/wiki/Populous_(video_game)

    • dylan604 2 months ago

      You guys have sent me down memory lane. Hopefully, I don't forget when I have free time to search, but hopefully I can find this to play in an emulator somewhere. This was the very first game I ever bought even though I didn't have an Amiga but had one that was very accessible.

      edit: couldn't wait. did the search. it's very much available to play online. hello rabbit hole...

bodge5000 2 months ago

I've used a few terrain generators before but I think this one might be my favourite. Obviously the fact its a "CSS only" demo project restricts things a bit, but its got enough going for it regardless.

It actually comes at a really good time for me, I'm currently trying to make the transition from 2d game dev to 3d and things like this are really helpful.

ModernMech 2 months ago

This thing is killing my CPU, what's the actual bottleneck here for CSS? Is it the number of elements visible and rendered at once? Is it the calculation engine backing CSS is super slow? Or just that most of the work is being done on the CPU it seems (on my machine, rotating around the map, my integrated GPU goes to 20% but CPU stays around 40-50%).

paulbjensen 2 months ago

Really cool, especially when I realised you could rotate the terrain and do some zooming as well.

em3rgent0rdr 2 months ago

Impressive, but there is a noticeable lag after modifying the terrain or moving the camera. Is there a way to know if the browser is using the GPU or CPU for rendering, and is there are way to see the milliseconds per frame?

  • bob1029 2 months ago

    It looks like a layout/style/composition issue with the browser engine.

    In Safari I'm seeing 91% CPU time on paint, 6% on layout, 2% on styles. It looks like it's taking somewhere between 100-200ms on my machine to chunk through a state change each time.

    > Is there a way to know if the browser is using the GPU or CPU for rendering, and is there are way to see the milliseconds per frame?

    For Safari, you would go to the Web Inspector and navigate to the Timelines tab. Chrome has a similar thing.

EGreg 2 months ago

Can someone please reimplement something like Warcraft 2 on a mobile web device?

It would be a hit, I’m telling you. Even from 1995.

Some people are still playing it 30 years later, obsessively.

And myth ii by Bungie is a classic too

  • mock-possum 2 months ago

    The controls would take some serious reworking to make it work on mobile - I could see adding a ‘pause’ feature to give you time to scrub your fingers all over the screen to issue all your unit and build orders, performant pinch to zoom would nearly negate the need for a mini map, lots of reworked GUI for building stuff and managing workers

    • EGreg 2 months ago

      Anyone made a real-time-strategy engine for tiled games on mobile?

  • o11c 2 months ago

    Stratagus has an android port at least ...

nefarious_ends 2 months ago

Very cool! Do you think it’s possible to do lakes and waterfalls?

  • rofkoOP 2 months ago

    Definitely! I'm planning for more landscape features for next versions. I think rivers will be a great addition, and waterfalls/rapids sound really interesting too. In the end it's a matter of adding a few classes and designing some sprites.

kataqatsi 2 months ago

for those interested in more CSS-Only art, Lynn Fisher makes some neat stuff

https://a.singlediv.com/

w4yai 2 months ago

I got some rendering issues, but otherwise very cool !

https://i.imgur.com/qT6ozyh.png

Firefox 144.0.2, Windows

  • rofkoOP 2 months ago

    Thanks for the report! Are you using a dark mode extension by any chance? I’ve seen that happen with Dark Reader in Chrome.

throwaway2037 2 months ago

It is giving Sega Genesis "Populous" vibes.

ryukoposting 2 months ago

Dark Reader mutilates the rendered output, but only certain tiles. No clear pattern as to what tiles get mangled. Peculiar.

docmars 2 months ago

The next obvious step will be SimCity 2000 completely implemented using web tech. One can hope!

stefs 2 months ago

1. what's a layou tit?

2. does it sometimes raise / lower by 2 units?

3. the "flatten" tool is missing.

ForgetItJake 2 months ago

Reminds me of RCT, very nice!

hersko 2 months ago

This is super cool! Wonder how hard it would be to use with an RTS game.

iagorodriguez 2 months ago

Amazing job by an amazing developer!

cluckindan 2 months ago

Nice! Now do collision checks ;)

robertheadley 2 months ago

This is really cool.

worldai 2 months ago

Impressive work

jimmydin7 2 months ago

looks sick! great job :)

OldGreenYodaGPT 2 months ago

Crazy that vibe coding can make things like this now! 2026 going to be crazy! There is no AI bubble

Keyboard Shortcuts

j
Next item
k
Previous item
o / Enter
Open selected item
?
Show this help
Esc
Close modal / clear selection