amethyst / bracket-lib

The Roguelike Toolkit (RLTK), implemented for Rust.
MIT License
1.51k stars 108 forks source link

FOV algorithm checks Y against map.width instead of map.height when scanning w2sw #204

Closed mcccclean closed 3 years ago

mcccclean commented 3 years ago

Hello! I've been going through the roguelike tutorial and have been having an absolute blast, thank you so much for putting this all together! It's absolutely incredible.

I've noticed that on a map that is taller than it is wide, the FOV algorithm is checking the wrong dimensions for W2SW.

image

I've located the offending line - will have a PR up shortly.

LEGOL2 commented 3 years ago

Hello! I know this should not be discussed in pull request, but how did you use a sprite in your game?

mcccclean commented 3 years ago

@LEGOL2 I haven't used sprites really 😅 - I have just edited the font to replace some of the glyphs. So where it's showing the little guy, he is really an É, and the parcel is actually a ≡.

To use a custom font, it looks something like this (you will have to edit it to use the right dimensions and tile size for your game):

rltk::embedded_resource!(FONT, "../resources/cp437.png");

fn main() -> rltk::BError {
    let mut gs = State::new();
    gs.register_components();
    raws::load_raws();
    gs.insert_resources();

    let (w, h) = (80, 60);
    rltk::link_resource!(FONT, "resources/cp437.png");
    let context = rltk::RltkBuilder::new()
        .with_dimensions(w, h)
        .with_tile_dimensions(16, 16)
        .with_font("cp437.png", 16, 16)
        .with_simple_console(w, h, "cp437.png")
        .build()?;

    rltk::main_loop(context, gs)
}
thebracket commented 3 years ago

Sorry about the delay in looking at this; I've been snowed under with book release stuff (Hands-on Rust final ebook/paper release is coming up in June, and there's an amazing amount of work that goes into the launch) and quite unwell for a bit. I'll take a look at the PR - thanks!

@LEGOL2 There's actually a few ways to go about putting sprites in:

Writing a bit more sprite support is definitely on the menu, but I'm having to move a little slowly right now due to all my other commitments.