Hands-on Rust: typo in monster spawns for empty

Title: Hands-On Rust (Chapter 11 (creating empty.rs)

pretty sure that

        for _ in 0..50 {
            mb.monster_spawns.push(Point::new(
                rng.range(1, SCREEN_WIDTH),
                rng.range(1, SCREEN_WIDTH),
            ))
        }

should be

        for _ in 0..50 {
            mb.monster_spawns.push(Point::new(
                rng.range(1, SCREEN_WIDTH),
                rng.range(1, SCREEN_HEIGHT),
            ))
        }

Thanks for the report. I may have been staring at code too long today, but those two look identical? In the book source I found that the comma was missing after the 2nd rng.range - which works, but is inconsistent. I’ll fix that in the next beta. Just wanted to make sure I haven’t missed something else?

Second parameter to Point::new is SCREEN_HEIGHT (not WIDTH both times)

so… yeah… looks like you’ve stared at too much code :slight_smile:

1 Like

Gotcha - thank you! It’s been a long day (day-job work). I’ll definitely get that fixed in the next roll-out.