rustrogueliketutorial icon indicating copy to clipboard operation
rustrogueliketutorial copied to clipboard

Chapter 1.5 :when the room is made to x = 0 or y = 0, the Fov is not delivered.

Open esehara opened this issue 4 years ago • 5 comments

As you can see in the image below, when the room is made to (x = 0 or y = 0) (example: let test_room = Rect::new(0, 0, 30, 30);), Fov is not reached. It seems to me that the top left wall should be visible.

2

I saw the source code of thebracket-lib, and the function of field_of_view was originally supposed to start from x>0 or y>0. Is there any reason for that?

P,S.

I'm using machine translation, so please forgive me for the weird English :( .

esehara avatar Apr 07 '20 17:04 esehara

Thank you! I've fixed this in a branch on my local PC - it'll be merged soon.

thebracket avatar Apr 08 '20 17:04 thebracket

I downloaded the latest source and did cargo run, but the same problem still seems to occur, I checked commit , but it seems to be a problem of the library itself (if there is no time, I will check library source).

test room

let new_room = Rect::new(0, 0, 20, 20);
map.apply_room_to_map(&new_room);

Screen shot

bag-fov6

esehara avatar Apr 19 '20 14:04 esehara

I've been trying to figure out this one as well. In the rltk repo, there's already an issue and a PR that appears to fix this problem:

https://github.com/thebracket/bracket-lib/issues/116 https://github.com/thebracket/bracket-lib/pull/126

Hopefully, if that PR gets merged it will fix this issue as well.

ddalcino avatar May 10 '20 18:05 ddalcino

Just so if someone finds this in the future and is looking for a solution for the rltk version 8.1.0, I solved the problem by implementing in_bounds() for the Algorithm2D trait for the Map object as follows:

//map.rs
impl Algorithm2D for Map {
    //snip
    fn in_bounds(&self, pos: Point) -> bool {
        pos.x < self.width && pos.y < self.height && pos.x >= 0 && pos.y >= 0
    }
}

Zij-IT avatar Jan 26 '21 07:01 Zij-IT

//map.rs
impl Algorithm2D for Map {
    //snip
    fn in_bounds(&self, pos: Point) -> bool {
        pos.x < self.width && pos.y < self.height && pos.x >= 0 && pos.y >= 0
    }
}

This solved it for me. Been looking for the cause for hours and tracked it down to the field_of_view(Point::new(pos.x, pos.y), viewshed.range, &*map); line of the visibility_system.rs (I'm on chapter 2.4)

Tried setting all the tiles to revealed and they're all there, they just don't get put into the "visible tiles" list

harofax avatar Feb 02 '21 23:02 harofax