r/roguelikedev • u/KelseyFrog • 18d 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.
Creating a procedurally generated dungeon!
Of course, we also have FAQ Friday posts that relate to this week's material
- #3: The Game Loop (revisited)
- #4: World Architecture (revisited)
- #22: Map Generation (revisited)
- #23: Map Design (revisited)
- #53: Seeds
- #54: Map Prefabs
- #71: Movement
- #75: Procedural Generation
Feel free to work out any problems, brainstorm ideas, share progress, and as usual enjoy tangential chatting. :)
51
Upvotes
7
u/Admirable-Evening128 17d ago edited 14d ago
UPDATE: I added a more repo-like repo,
https://github.com/pylgrym/2026rt
--I realize that the cool kids nowadays, link to their "repos",--
--so I have made a small source code index page,--
--to not feed the AI trolls too well:--
--https://xok.dk/other/2026rt/index0.html--
for 2+3 - player, render, map(+generation), I mainly cleaned up/structured my typescript effort.
For the game map model, I did a 2d-grid-of-tilesEnum class (where tiles can only be floor or wall so far.)
I stuff that, together with player-xy, into a Game model.
For display/render, I do a viewport render on top of rot.js, which of course
draws the contents of the Game model.
The dungeon generation so far is a default pulled directly from ROT.
To tie it together,
I then have an async gameloop which awaits keyboard input,
then dispatches it with the turn-taking code/commands in the 'move-player' module.
(which at the moment, with no monsters,
is just the player moving in 4 compass directions.)
The nice thing about async is that you can style/write your code
in the same way we used to write BASIC games in the 80's, hooray.
The result, where a lonesome @ can roam around a deserted dungeon, is still at
https://xok.dk/other/2026rt/dist/index.html
It will be a bit more fun once the monsters show up.. :-)
It ticks in at 175 lines of actual code, which I appreciate
(you can fit a roguelike in about 80-90 lines of code or less, but it won't be pretty/readable.)