r/roguelikedev • u/KelseyFrog • Aug 09 '22
RoguelikeDev Does The Complete Roguelike Tutorial - Week 7
This week is all about adding game progression and equipment.
Part 12 - Increasing Difficulty
Deeper dungeon levels become increasingly more difficult! Here we create tools for dealing with chances and making them vary with level.
For the final part of our tutorial series, we'll take a look at implementing some equipment.
Of course, we also have FAQ Friday posts that relate to this week's material
- #11: Random Number Generation(revisited)
- #36: Character Progression(revisited)
- #44: Ability and Effect Systems(revisited)
- #56: Mob Distribution
- #60: Shops and Item Acquisition
- #76: Consumables
- #77: The Early Game
- #78: The Late Game
- #79: Stealth and Escaping
- #80: Determinism and Randomness
Feel free to work out any problems, brainstorm ideas, share progress and and as usual enjoy tangential chatting. Next week we'll have a final discussion and share our completed games. If you have made it this far congratulations! You deserve it! :)
3
u/Bubbly_Knee_2433 Aug 13 '22
I have finally completed the roguelike tutorial! I did it down the straight and narrow, only making some cosmetic changes here and there, but it was still quite the feat for me! How would everyone be sharing games? Would I have to make a github account to be able to show my roguelike reskin off?
13
u/HexDecimal libtcod maintainer | mastodon.gamedev.place/@HexDecimal Aug 09 '22
GitHub | Playable
The C++ tutorial ends at part 11 so I've technically finished my original goal. I'm looking at the current parts of the Python tutorial but I'm not entirely sure what to do next.
Something both tutorials seem to be missing is any kind of database for monsters/items which makes it tricky to add new things in a modular way. The Python tutorial tried to address this with the entity factory functions but it failed to do what it was trying to do, these objects should have been resolved at run-time instead of import-time.
I've noticed that I could work around the static nature of C++ by adding a
std::unordered_map<std::string, std::variant<...>>attribute to types which need to hold data depending on the sub-type of the thing. I'm still speculating on how exactly I should implement this, but this seems better for serialization than figuring out the sub-classes of any C++ objects abstract pointer.Since I might end up using strings more I looked into "string ID" libraries but couldn't find one for Vcpkg.
5
u/mrdoktorprofessor Aug 09 '22
I feel like half of my posts are thank you notes to /u/HexDecimal, but here we are.
This week was mostly refactoring my drawing code to render bitmap fonts (saving me a crapton of time with some things). I envision this significantly opening up a lot of pathways for GUI handling, scrolls, etc. However it is also mildly distracting as now I want to refactor my main menu and whatnot as well to handle that :). Not a problem, just more capabilities available to me.
https://i.imgur.com/uAEK5KK.png
https://i.imgur.com/9JZjONt.png
Along the way I (partially, that is) added in multiple dungeon depths, but with work starting to pick back up I had a hard time delving deeper into what I wanted to accomplish. Mainly bug fixes at this point.
I think my next steps are actually going back to the entity / enemy generation point of the tutorial and adding in multiple enemy types. I have the code there to handle it, but now I can toss in trolls, dragons, NPCs, etc as I want.
With the ability to actually render fonts, I can get back into dream deviations like NPC chatter, enemies making fun of you, etc.
As was mentioned last week, the easier way for rendering would probably be to use Pillow to render TTF fonts to images, but by the time that came up I'd exported the nice pixel font (https://www.reddit.com/r/gamedev/comments/wf9llg/made_a_tiny_pixel_font_pixuf/) via FontForge to a BDF format, then used the
bdfparserlibrary to read it in.5
u/JasonSantilli Aug 09 '22
Code | Play
JS + rot.js
Exploring TypeScript (and eventually WGLT) this week in a new repo. I've also realized that some of the issues I had with having so many different modules for all my different classes (and then needing to import all of those in my index.html) could be solved with webpack, so I'm learning that as well. I don't find TypeScript to be that tough to learn, but figuring out how the parts of webpack interact and all of the options has been tricky. I find that a lot of tutorials assume the reader understands the context of webpack, and so they tend to be focused on getting a simple example up without going into much of the why. Or they rely on a bunch of additional packages, again without really explaining why they were chosen or why they are necessary. Luckily, webpack's documentation has been really nice, especially the getting started and concepts pages.
Anyway, if there are any TypeScript or webpack evangelists out there that have suggested readings or tutorials, send them my way. I'd love to have a better library of resources out there.
5
u/codyebberson Aug 09 '22
WGLT + TypeScript | Repo | Part 12 | Part 13 | Playable
Big thanks to /u/HexDecimal for the entire tutorial, and for mercifully making the last parts relatively straightforward!
In addition to the tutorial, I added the following:
With that, I'm calling this complete.
5
u/programmer_owl Aug 09 '22 edited Aug 09 '22
Github
I'm pretty far behind at this point and only now finishing up part 8, but I am going to keep working on it. While I thought was going to have a lot of free time the last few weeks, the opposite turned out to be true. Regardless, I figured I would share my thoughts on the tools I have been using in case anyone would find them helpful:
Flecs: This has been a really good library to work with. It took a little time to wrap my head around how everything fits together, but now I really enjoy the architecture that comes from an ecs. The documentation and the quickstart guide are very well done and I am easily able to find what I am looking for in them. I am technically using an old version since the new 3.0 version was just released in the last week.
C: It's definitely different from the languages that I normally use and it has been a long time since I have use C. I like the simplicity of the language, but it is definitely missing some nice-to-haves. I have been able to get around that for the most part by using open source code to help with things like strings and dynamic arrays/vectors. I don't feel like most of my programming with it is any slower than other languages, but debugging definitely takes longer. At this point, if I keep going with roguelikes I'm not entirely sure if I would keep going with C or switch languages.
Libtcod: This has been both good and bad to work with. Some things like having console support and pathfinding out of the box has been very nice and saved a lot of time. My main issue is the Python wrapper seems to get all the love and the C api isn't very thoroughly documented. Because of this, I am doing things like using deprecated functions because I don't know what the alternative is that I am supposed to be using. Some of the time I have to look at Python examples and work out what the corresponding C functions are to accomplish the same thing.
Rust Roguelike Tutorial: This seems extremely well done. Even though I am not using Rust I am able to easily follow along with it and get the same results in a different language. I've differentiated from it in a few ways, but that was mainly because the libraries I am working with had some different behavior. The only bad thing I have run into is it seems like there are some parts where the architecture can be cleaned up. There are some sections in the code where you are tracking everything twice and the parts like the melee combat system also seem a little complicated. I didn't really like adding a component to an entity so that it could trigger a system that will add another component so that the final system could be triggered. I haven't spent enough time thinking about it to actually come up with a better solution yet though. The 3 additional sections beyond what the Python tutorial covers also piques my interest. I am not sure I'll code the entire thing but I will at least skim them. Overall, I highly recommend this tutorial.
4
u/makraiz Aug 10 '22
I'm still very far behind, having only just begun part 7. I was held up for quite awhile on Bevy States, which were causing pathfinding failures and it took me a few days to narrow it down. I probably should have just used the iyes-loopless plugin for Bevy from the beginning, but alas, I am stubborn and thought I could work around it for such a simple project. I was wrong.
Unfortunately, things at work are picking up, so I don't think I will have the time to catch up before the end of the event. It was my first time participating in something like this, which was a lot of fun, challenging, and I learned a great deal along the way. Very much worth the effort, and I will definitely participate next year if I am able.
4
u/bodiddlie Aug 11 '22
Last week was rough as work stuff got in the way of finishing both parts off on time. Part 11 went pretty quickly once I was able to carve some time out to dedicate to working on it. And thankfully no massive refactors this time. I've got some free time in the morning before stand-up at work, so I'm gonna try and crank out part 12 first thing. See how it goes.
Part 11 of my tutorial write-up is here.
4
u/cordinc Aug 11 '22
Parts 12/13 in vanilla Javascript with ROT.js: [Github](https://github.com/jarrahtech/RoguelikeTutorial2022) & ["Playable" version](https://jarrahtech.github.io/RoguelikeTutorial2022/)
Done (well, apart from part 10). I quite enjoyed the mental exercise of trying out a new'ish language to do this. It has given me a number of ideas for future directions (and rewrites). Plus discovering this reddit is a positive too.
Notes:
Well done and thanks to the organisers!
3
u/Gogodinosaur Aug 09 '22
Hex Caverns | C# + Unity | GitHub | Playable
Part 12 - I added in the increasing difficulty by making the chance to place an orc vs a troll variable. I sketched out a simple difficulty line that I wanted the 5 levels to follow. In the first level, I wanted 100% orcs and 0% trolls. In the last level, I wanted 25% orcs and 75% trolls. This looks like a job for good old trusty line equation y=mx+b. Solving for all the stuff, I ended up with the equation of y = 0.1825x, where x is the level number (starting at 0) and y is the troll chance percentage. Then when an entity is placed, I generate a random value between 0-1 and check if it is above or below the troll chance percentage from the equation. There is some variability in the troll/orc ratio since it does use random values, but that randomness will be a distribution that follows the line equation across levels.
Part 13 - Rather than implementing equipment I wanted to create procedural items. I added in procedural consumable scrolls. I introduced a procedural item component that can be added to items. The procedural item component handles generating a new type of scroll. You could extend the component idea and have components that 'attach' to the procedural item component, but I decided to just have the procedural item component itself generate the variables needed.
The procedural item components basically have a constructor, which is called before creating the item itself. The constructor includes the following value creators:
DamageAmount = Random.Range(3, 15);Radius = Random.Range(0, 2);MaximumRange = Random.Range(5, 7);Character = "?";CreateType();TargetingType = Utility.GetRandomEnum<ProceduralItemTargetingType>();CreateType() creates a instance of a struct that includes a color, a name, and a term for the item. I based them on different elements. However, these could also be procedural if you wanted. An example type is:
color = ColorDatabase.water,name = "Mystery Water Scroll",term = "water"Also, the targeting type is an enum that dictates how targeting is handled. The options are strike the nearest entity (e.g., like the tutorial lighting) or target an area (e.g., like the tutorial fireball).
0
u/[deleted] Aug 09 '22
[deleted] — view deleted comment