Giter Site home page Giter Site logo

rustrogueliketutorial's Introduction

rustrogueliketutorial's People

Contributors

adamnemecek avatar benreyn avatar chornsby avatar ddalcino avatar dependabot[bot] avatar dominicd avatar gbmor avatar iolivia avatar koura avatar lonami avatar markmccaskey avatar matteoggl avatar mgedmin avatar mystal avatar nielsrenard avatar pkrasam avatar remimstr avatar richchurcher avatar skierpage avatar snkaupe avatar thebracket avatar thibautre avatar tillarnold avatar tyrelsouza avatar viima-xyz avatar vojta7 avatar workingjubilee avatar zerocity avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rustrogueliketutorial's Issues

Chapter 1.5 issues

You forgot to mention that we need to #[derive(PartialEq)] to compare this enum.

pub enum RunState { Paused, Running }

Also this code block just below the enum shows the wrong text i think, as it is shown twice. It should show the State struct i guess?

impl State {
    fn run_systems(&mut self) {
        let mut vis = VisibilitySystem{};
        vis.run_now(&self.ecs);
        let mut mob = MonsterAI{};
        mob.run_now(&self.ecs);
        self.ecs.maintain();
    }
}

Duplicate objects since chapter 3.14

Hello,
I have seen since chapter 3.14 to at least the chapter 4.3 that all objects and monsters are duplicated upon spawn.
Trying to narrow down the problem, i found it coming from the function "apply_previous_iteration" in "src\map_builders\prefab_builder\mod.rs" : the part if filter(x, y, e) { build_data.spawn_list.push( (idx, e.1.to_string()) ) } totally duplicate the spawn list.

When using !filter, it seems back to normal, exept if there is a sectionnal fort where items are in two copies, but i don't have a good enough grasp on the filter function to know what to do or if what i have done is the right solution.

Wave function collapse loses depth data

Fix is in:

fn render_tile_gallery(&mut self, constraints: &[MapChunk], chunk_size: i32, build_data : &mut BuilderMap) {
        build_data.map = Map::new(build_data.map.depth, build_data.width, build_data.height, &build_data.map.name);

Needs to be added to prior chapters.

Targeting in chapter 3.19 has a BIG problem at higher player x,y coords

(It is possible to trigger a problem within standard 80,50 map bounds, so it's not a case of people wanting really big maps. It seems to happen at roughly y = 40ish and x = 35ish.
I removed the range check on targeting (just to see if it was the culprit), so ALL tiles in view should be highlighted blue (=available for targeting). I used the right-hand panel to print out some stuff for debugging (player position is labeled as such, X and Y are the camera min and max bounds for the relevant coordinate, and they all look to be correct)

Some screenshots to illustrate:
Screenshot 2019-11-15 14:00:09

Screenshot 2019-11-15 13:59:39
Note the tiles above the player aren't lit anymore.

Screenshot 2019-11-15 13:58:50
Even more tiles in view aren't lit.

Screenshot 2019-11-15 13:58:13
Past a certain point, no tiles are lit and therefore your grenade/fireball scroll is useless.

Everything points to
let screen_x = idx.x - min_x; let screen_y = idx.y - min_y; if screen_x > min_x && screen_x < max_x && screen_y > min_y && screen_y < max_y part of the targeting code being the culprit.

Unfortunately I haven't figured out a solution yet. I would probably try cribbing from camera.rs, doing for ty in min_y .. max_y { for tx in min_x .. max_x kinda thing?

Index out of bounds during map generation

The fix for issue #41 introduced an index out of bounds error in new_map_rooms_and_corridors() in chapter 04.

Since some rooms are likely to be marked as !ok, rooms.len() will most likely be less than i.

Commit that introduced the issue: a1bd5cb

After 4.14 Better AI, switching positions with the same bystander twice in a row puts your camera in the new correct spot but doesn't move the player

Reproduce by finding a peasant or something in town and walk into him, then walk into him again immediately afterwards to swap both of you back to your original positions. What instead happens is that your camera gets put into what should be your new position, but your player character remains and is disconnected from the camera. Passing a turn doesn't change anything, but if you move again your camera jumps back to the player.

After 4.14 Better AI, enemies sometimes get "stuck" trying to approach you and simply stand still

Tried in webassembly version. Reproduce easily by finding the rat house and getting a pair of them to follow you. Start running away from them and you'll find they stop(even without you moving out of their vision range, this is not a chasing issue and for me at least still doesn't get fixed after the chapter where we add a chase timer), in this stopped state they seem to simply stand still forever or until someone rubs their bugged state by walking next to them or another NPC approaching to enter combat. While I can't reproduce this in your webassembly version, for me on my computer the performance drastically drops while enemies are in this bugged approach state.

Chapter 3.15, DoglegCorridors creation

While we create the corridors function in DoglegCorridors, we have if rng.range(0,1) == 1 or the first parameter of range is inclusive, while the second parameters is exclusive : the resulte of rng.range(0,1) is always 1. It should be modified by rng.range(0,2).

And in the same function, shouldn't let (prev_x, prev_y) = rooms[rooms.len()-1].center(); be let (prev_x, prev_y) = rooms[i-1].center();, because "rooms" is now fixed size, so the previous room will always be wrong ?

Thanks for your work !

Section 1.6 duplicate code

I'm not sure if you would like to consider this an issue or not, but I noticed that in the chapter on taking damage, in the first code example we have the code:

let idx = (y * self.width) + x;
self.tiles[idx as usize] != TileType::Wall

which works. However we actually already have a function for this with self.xy_idx,
so this could be:

let idx = self.xy_idx(x, y);
self.tiles[idx] != TileType::Wall

which is nice because we wouldn't have to cast to usize in the second line and we would be connecting the code to that helper function from earlier chapters. Again, not really sure this is an issue or not, I just thought I'd mention it.

bug in field_of_view?

https://github.com/thebracket/rustrogueliketutorial/blob/23368c2b6dcc73353eb0cdbf512fde43cdbcf49b/chapter-10-ranged/src/inventory_system.rs#L78

I noticed that the game log was printing duplicate lines whenever I used the Fireball Scroll. At first I thought it had to do with my implemention (because I've made a few tweaks along the way), but upon further investigation, I found out that blasted_tiles.len() was longer than it should be, i.e. field_of_view was returning too many results. More precisely, there were many duplicate indices (the vector is usually 88 long). This happens when I compile your original code too, in both rltk_rs 0.5.2 and 0.5.3.

As I'm new to Rust, I haven't yet been able to trace the error. Maybe you can take a look at it? I'm currently using the latest version of Rust (1.39) with all crates updated.

Thanks!

Chapter 7: player can move over monsters

Half way through Chapter 7 (dealing damage) the player can move over monsters!! This is because I think of the order we run systems in:

  • the player move
  • we run map_indexing
  • we run monster_ai
  • the player moves again

So when the player moves, map_indexing has not been refreshed with the new monster positions. I've solved it by changing the order in run_systems:

fn run_systems(&mut self) {
        let mut vis = VisibilitySystem{};
        vis.run_now(&self.ecs);
        let mut mob = MonsterAI{};
        mob.run_now(&self.ecs);
        let mut mapindex = MapIndexingSystem{};
        mapindex.run_now(&self.ecs);
        self.ecs.maintain();
    }

Originally posted by @Zireael07 in #28 (comment)

Seciton 1.6 example - description mismatch

In section 1.6 towards the end of this sub-section on blocking access there is a line that reads: "We do however add it to the dependency list for MonsterAI - the AI relies on its results, so it has to be done.", but none of the examples in the section seem to add MapIndexingSystem as a dependency of MonsterAI, it's possible I just missed it though.

Suggestion - maps bigger than the screen

As the topic says. IIRC scrolling maps / camera was one of the bonus parts of the original Roguebasin tutorial.

Also, great job on the Waveform Collapse algorithm! I've been seeing it around various procedural generation sites, but I never could wrap my head around it - and I believe your tutorial cleared it up amazingly!

build fails on macos

first attempt with master latest, I get:

 ➜  chapter-33-wfc git:(master) cargo build
    Updating crates.io index
    Updating crates.io index
error: no matching package named `rusttype_next` found
location searched: registry `https://github.com/rust-lang/crates.io-index`
required by package `rusttype v0.7.9`
    ... which is depended on by `andrew v0.2.1`
    ... which is depended on by `smithay-client-toolkit v0.6.4`
    ... which is depended on by `winit v0.20.0-alpha3`
    ... which is depended on by `glutin v0.22.0-alpha3`
    ... which is depended on by `rltk v0.5.1 (https://github.com/thebracket/rltk_rs#30ef14b8)`
    ... which is depended on by `chapter-39-halls v0.1.0 (/Users/brian.guarraci/code/rustrogueliketutorial/chapter-39-halls)`

after running

cargo update
cargo build

I get

error: unable to get packages from source

Caused by:
  failed to parse manifest at `/Users/brian.guarraci/.cargo/registry/src/github.com-1ecc6299db9ec823/hashbrown-0.6.3/Cargo.toml`

Caused by:
  feature `rename-dependency` is required

this Cargo does not support nightly features, but if you
switch to nightly channel you can add
`cargo-features = ["rename-dependency"]` to enable this feature

cargo --version

➜  chapter-33-wfc git:(master) ✗ cargo --version
cargo 1.30.0 (36d96825d 2018-10-24)

Chapter 7 - Code references unknown member

In chapter 7, (Dealing damage) you introduce clear_content_index as a function using the tile_content member way before it's added to the struct. At this point in the code, if I test, there is a bug that the player can move over a monster, because both think the cell is free and move into the same one. I think that's because the various systems run concurrently, but I don't know how to implement the dependencies you mention in the text.

Convert JSON to RON format

RON format is much more Rusty, would be nice to use it instead. Thanks to /u/Boietheos for pointing this out.

Chapter 4.8 has many issues with ordering of information

  • no mention of the fact that one needs to add regex crate to Cargo.toml (this will catch out people less experienced in Rust)
  • weapons with hit dice are introduced a long way before the combat system catches up (it only does so after we've made the Rusty Longsword for your starting inventory)
  • no mention of where the string_to_slot function comes from ... waiit, the function is introduced a long way down the chapter, roughly where the wearables come in
  • find_slot_for_equippable_item is using wearables before the concept is introduced

Chapter2 - Ticks/Rendering only happens when input is given

Hi first of all very nice tutorial!

So I followed your tutorial and I have a strange problem. Im in Chapter 2 and the symbols only move if I give input, eg. mouse movement, clicks or even scrolling with the mouse.

You can check the code here :https://github.com/DominicD/rustyrogue however it is the same as yours.

I am using:

  • Windows 10
  • rustc 1.38.0-nightly (435236b88 2019-08-01)
  • cargo 1.38.0-nightly (26092da33 2019-07-31)

Clarify licensing - source code MIT, book code ???

Thanks to /U/Koavf for asking:

Thanks for writing it: it's a great resource. The intro says that the text is open source and the code is explicitly licensed MIT but could you clarify the license of the non-code text? Would you be willing to publicly declare it CC BY 4.0? If so, I'd love to port it to Wikibooks and Wikiversity.

Chapter 1.5 - unused code referenced

In https://bfnightly.bracketproductions.com/rustbook/chapter_6.html#making-the-monsters-think there is a note regarding &["visibility_system"] which isn't actually used in the code example up to that point, unless I've somehow missed it, which is possible.

Also, in https://bfnightly.bracketproductions.com/rustbook/chapter_6.html#turn-based-ga me-in-a-tick-based-world there is a reference to using the RunState enum in our run_systems function, but that isn't reflected in the code example.

Great tutorial series!

Chapter 3.3 Particles Effects : Old Dispatcher code

Hi !
Your guide is really nice ! =)
I just wanted to say that in chapter 3.3 for the particles system, there is still code with DispatcherBuilder, but you don't use anywhere else. It must be some artifacts ?
Thanks !

1.1 - change structure name

Copied from Discord:
fuddles Today at 12:19 PM
1.1)
#[derive(Component)]
struct Pos {
x: i32,
y: i32,
}
should be Position

Cannot go downstairs (keyboard input problem on Linux)

I'm unable to go downstairs in e.g. cargo run inside chapter-21-rexmenu.

My experiments with glutin's cargo run --example window show that when I press the period key on my keyboard, the events look like this:

WindowEvent { window_id: WindowId(Wayland(WindowId(94351912379904))), event: KeyboardInput { device_id: DeviceId(Wayland(DeviceId)), input: KeyboardInput { scancode: 52, state: Pressed, virtual_keycode: None, modifiers: ModifiersState { shift: false, ctrl: false, alt: false, logo: false } } } }
WindowEvent { window_id: WindowId(Wayland(WindowId(94351912379904))), event: ReceivedCharacter('.') }

I've no idea why virtual_keycode is None. Bug in glutin maybe?

I'm wondering if maybe ReceivedCharacter would be a better event to use for character-based input commands? Might it work better for people using non-QWERTY keyboard layouts? (I wonder how Dvorak users like to play roguelikes?)

Copy code funtion always includes fn main

Hi,

when I use the copy code button on the code snippets in the tutorial it always includes an fn main.
For example Chapter 3 first snippet when I copy I get:


#![allow(unused_variables)]
fn main() {
/// Makes a map with solid boundaries and 400 randomly placed walls. No guarantees that it won't
/// look awful.
pub fn new_map_test() -> Vec<TileType> {
    ...
}
}

Typos

There's a couple of persistent typos in code across the whole tutorial.

  • "voroni_distance" when talking about the Voronoi Hive Map (chapter 3.10 and onwards)
  • "cellular_autom_o_ta" (chapter 3.5 and onwards) - both the file name (!) and the class name, while the tutorial header correctly spells it as automAta

wave function collapse solver issue

Great work so far.
While trying to create a game in c++ using the tutorial as a basis I noticed that
at line 204 and 205 it is picking a random index between zero and possible_options.len() exclusive as the new chunk index.
Shouldn't this take the value from that random index instead?

Chapter 9 undefined constants

In the section Spawn All the Things There's a reference to MAX_MONSTERS but this hasn't been defined as far as I know, and it's not mentioned yet in the tutorial. Same for MAX_ITEMS which is introduced in Health Potion Entities. Obviously it's easy to fill in the blanks, just thought I'd mention it. Great tutorial Series!

Ch 2, 9, 22 - dead links (Book of Specs)

Hi there, still very much enjoying the tutorial!

I noticed some links to the (slide-rs) specs website are broken:

https://github.com/thebracket/rustrogueliketutorial/blob/master/book/src/chapter_2.md
You can learn more about these stores in The Specs Book.

https://github.com/thebracket/rustrogueliketutorial/blob/master/book/src/chapter_3.md
You can learn more about this in the Specs Book.

https://github.com/thebracket/rustrogueliketutorial/blob/master/book/src/chapter_9.md
"We referenced the Book of Specs for how to do this!"

https://github.com/thebracket/rustrogueliketutorial/blob/master/book/src/chapter_22.md
The Specs Book provides a great clue as to how to exclude a component from a join, so we do that (in main.rs)

Some resources has wrong extensions

Hi ,

in the implementation of Rltk::init_simple8x8

let font_path = format!("{}/terminal8x8.png", &path_to_shaders.to_string());

but in the resources, the files have extensions of .jpg

i dont get any error and the game dont crashes.

Typo in WFC tutorial

Thank you for your well-written tutorial!

  • Typo in the waveform collapse tutorial: pub fn patterns_to_constaints should be pub fn patterns_to_constraints.

  • Just my curious, but why do you refer to it as "waveform collapse", not "wave function collapse"?

  • Also, this code in the function (patterns_to_constaints)

                    let opposite;
                    match direction {
                        0 => opposite = 1, // Our North, Their South
                        1 => opposite = 0, // Our South, Their North
                        2 => opposite = 3, // Our West, Their East
                        _ => opposite = 2 // Our East, Their West
                    }

may be written as

                    let opposite = match direction {
                        0 => 1, // Our North, Their South
                        1 => 0, // Our South, Their North
                        2 => 3, // Our West, Their East
                        _ => 2, // Our East, Their West
                    };

Advice from Redditor - /U/AnarchyIsOrder1312

If i can offer some advice about chapter 1.2 you give the classical over inheritance OOP and then suggest ECS because you should favor composition over inheritance. However I think it might be pointing out that composition is a part of OOP too (following SOLID-C principles) and that ECS is one method of achieving composition over inheritance. As it reads currently, and a lot of beginners get this interpretation from a lot of ECS tutorials, ECS is the way you avoid inheritance messes, rather than just not abusing inheritance wrong. https://www.gamedev.net/blogs/entry/2265481-oop-is-dead-long-live-oop/ is a great article dismantling that point. Anyways, for the sake of "completeness" it might be worth mentioning in that chapter.

&s.to_string() is pointless

Thanks to andolanra on HN for pointing this out: there's a few places where I convert a char slice to a string and then reference it as a slice - which is really pointless, since just "s" would work!

Chapter 11 sometimes crashes on while loading

The Saveload system introduced in chapter 11 sometimes creates corrupt savegames that cause a crash on deserialization, like this one. I can't reproduce it all the time, but starting a new game, quitting, restarting, and then loading a few times often does it.

The actual crash occurs on line 118 of saveload_system.rs:

ecs.delete_entity(deleteme.unwrap()).expect("Unable to delete helper");

It crashes because deleteme is never set. deleteme stays None because the marker id of the SerializationHelper is duplicated in the savegame ({"marker":[10],"components":[{"map":{"tiles":... in the linked savegame, note that there is also {"marker":[10],"components":[null]},

I still don't fully understand the serialization/deserialization of entities, but I think the issue is that the existing marker allocator is not used on deserialization, which leads to duplicate entity ids on serialization. Instead, a new allocator is created in line 90:

&mut SimpleMarkerAllocator::<SerializeMe>::new()

Reusing the existing allocator with &mut ecs.write_resource::<SimpleMarkerAllocator<SerializeMe>>() seems to fix the issue.

"Out of bounds" walking freezes the game

Short description

Exiting the map is possible, and provokes a freeze

Where

It is present in Chapter 61 / 4.18. I believe this was introduced in Chapter 47 / 4.4. I have not tried previous Sections.

Steps to reproduce:

Start the game. Exit the initial tavern, and go to the beach (usually to the left). Once at the beach, it's possible to exit the map by walking north or south. When this happens, the game freezes.

Expected result:

I suspect this particular case could be solved by tweaking the algorithm which generates the beach (just ensure north and south endings are surrounded by deep water). But this problem will surely appear again in other places. I suggest fixing the walking subroutine so that the player isn't able to step out of the map.

Bonus point to adding a message like if the player attempts it. Super-bonus points if the quote is context-aware. For example in the beach it could say: "Hey, do you know the way to Shell Beach?".

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.