LessNoise.Sh some signal

Roguelike Dev Day 2: Chapters 2-4

(2 minutes) programming, rust, game, roguelike

Entities & Components

(In chapter 2 of the tutorial now.)

I re-watched a great keynote about ECSs earlier today, to prep for chapter 2 today. (There's also a blog post that covers the same content as the video and then some.) So hopefully this goes well.

Yep, the intro to this chapter is pretty similar to that video/blog post.

Okay, I'm going to go dive into some code.

My editor isn't set up really great for Rust, and I'm struggling to stay on task and not go into the weeds configuring my setup.

I've finished Chapter 2. I'm happy to have finished it, but I'm struggling with impatience to finish... Not good.

Okeedokee, I've taken some deep breaths. Zen mode. "Journey before destination." Onwards to chapter 3!

Walking a Map

(Over in chapter 3 now.)

Looks like I'll be generating a world in this chapter. Sweet.

This code is all very procedural. Lots of loops indices to keep track of. It's important to note that I'm using this tutorial as a way to learn; the game it's building will not be the game I'd like to make. Here's an example of the procedural code I'm talking about; the logic of what I want to happen (make a bordered map with 400 randomly scattered walls) is obfuscated by the code that manages the loops & variables and all the "magic numbers" that manage the limits of the viewport.

fn new_map() -> Vec<TileType> {
    let mut map = vec![TileType::Floor; 80 * 50];
    for x in 0..80 {
        map[xy_idx(x, 0)] = TileType::Wall;
        map[xy_idx(x, 49)] = TileType::Wall;
    }
    for y in 0..50 {
        map[xy_idx(0, y)] = TileType::Wall;
        map[xy_idx(79, y)] = TileType::Wall;
    }

    let mut rng = rltk::RandomNumberGenerator::new();

    for _i in 0..400 {
        let x = rng.roll_dice(1, 79);
        let y = rng.roll_dice(1, 49);
        let idx = xy_idx(x, y);
        if idx != xy_idx(40, 25) { // Don't cover the player
            map[idx] = TileType::Wall;
        }
    }

    map
}

Ok, so chapter 3 was also very simple. I made a simple map with a perimeter and scattered "wall" blocks, and prevented the player character from walking through walls.

A More Interesting Map

(And now in chapter 4)

Let's see how much of this chapter I can get through. I only have about 20 more minutes...

Oh, we're going to clean the code up into separate file. Nice!

Okay, I've finished. I've gone about 17 minutes over my planned limit, but cleaning up/organizing that code took longer than I expected.

What Kind of Game do I Want Anyway?

I've finished going through the tutorial today, and I started thinking: What I have so far doesn't feel very game-like to me. But then, I don't think "real" roguelikes appeal to me very much (gasp!). I think Dwarf Fortress is amazing, but the learning curve is brutal. I've tried NetHack as well, but I have a hard time getting into it.

I really like resource management games and exploratory games. I'm thinking it'd be cool to somehow combine Zelda: Breath of the Wild with a simplified version of Dwarf Fortress. I don't really know how to do that (yet!), but it sounds cool. :D