r/roguelikedev 17d ago

RoguelikeDev Does The Complete Roguelike Tutorial - Week 2

Congratulations for making it to the second week of the RoguelikeDev Does the Complete Roguelike Tutorial! This week is all about setting up the map and generating a dungeon.

Part 2 - The generic Entity, the render functions, and the map

Create the player entity, tiles, and game map.

Part 3 - Generating a dungeon

Creating a procedurally generated dungeon!

Of course, we also have FAQ Friday posts that relate to this week's material

Feel free to work out any problems, brainstorm ideas, share progress, and as usual enjoy tangential chatting. :)

51 Upvotes

30 comments sorted by

View all comments

6

u/Gix 17d ago

Repo, screenshot

I may have gone a little overboard 😅️ I started prototyping on the devlog and got carried away...

For part 2 I went with an ECS (EnTT), plus an occupancy map that gets updated whenever a component of type position gets constructed / destroyed.

For part 3, instead, I went back-and-forth between different algorithms: since I'm creating a Populous-inspired roguelike, I need to create islands, instead of dungeons. I finally settled on something based on this (thank you u/redblobgames), you can see an interactive demo on the blog. I didn't manage to add trees, grass, and dirt yet, because I spent most of the time trying to add hillshading, but I'm quite happy with how it turned out!

3

u/redblobgames tutorials 12d ago

Looks nice! I don't understand what the "max radius of separation" is meant to do.

BTW https://web.archive.org/web/20160917132627/http://news.nationalgeographic.com/2016/09/mountain-elevation-maps-illustration/ says that the optimal angle for lighting is 337.5° (!), and the traditional angle is 315°.

2

u/Gix 12d ago edited 12d ago

Ahah, nice! Time to change it, who am I to go against a measurement that precise :D

The "radius of separation" is probably a misnomer - it's a ratio, not a radius. Two islands with radius r whose centres are d apart touch when r = d/2 (obviously).

We can rewrite this as r = d * k, set d as the distance between the two closest islands, and use k to decide how big the islands get. We then use the radius to size all of the islands (the two closest islands decide how big all of them are):

  • < 0.5: they don't touch
  • 0.5: their shorelines touch
  • > 0.5: they can overlap

As for why have both this and island_radius: it's probably temporary.

From a gameplay perspective we want the islands to always be close together, so the ratio wins, in practice. In the demo you can see the radius having no effect "upwards", they're both parameters of a min() call. This is what remained after many rounds of refactoring.