Closed anthonyarusso closed 3 years ago
Thanks for being so thorough! I've fixed these issues now.
Last one is due to the update from Bevy 0.3 to 0.4, which changed how Children
work, but since in the end we don't use them, I did not realize while updating!
The Issue
Throughout the Bevy engine chess tutorial there are a number of places where the program will not function as described by the tutorial because code required for error-free execution (i.e. variable declarations) was not introduced at the step it should have been.
Specifics
Cannot find type
Piece
in this scope.In the tutorial after the paragraph: "We now need to implement something to change the unit positions. We'll change the select_square system to also move the pieces for now, and we'll refactor it into something neater later:" the following code is displayed:
At this point, you will receive the error "Cannot find type
Piece
in this scope.".Solution: change the PieceColor, PieceType, and Piece structs to all be public and add
use crate::pieces::*
to the top of board.rs. The tutorial shows neither of these steps, but the final code does.Cannot find value
pieces_vec
in this scope.In the tutorial after the paragraph: "Finally, we just need to call the function before moving a piece to check that the move is valid:" the following code is displayed:
At this point, you will receive the error "Cannot find value
pieces_vec
in this scope.".Solution: add
let pieces_vec = pieces_query.iter_mut().map(|(_, piece)| *piece).collect();
under the lineif let Ok((_piece_entity, mut piece)) = pieces_query.get_mut(selected_piece_entity)
.Note: The tuple inside the
.map(| |)
closure andOk(())
lines only contains two arguments as thechildren
argument has not been introduced by this point in the tutorial.Field
0
of structbevy::prelude::Children
is privateIn the tutorial after the paragraph: "Here's the new function that also takes care of despawning a piece after it's taken:" the following code is displayed:
At this point, you will receive the error "field
0
of structbevy::prelude::Children
is private" on thechildren.0.iter()...
line.Solution: Change
children.0.iter()
tochildren.iter()
. This solution I don't understand as much since I just got it from tubotinatub on the Discord.That is all. Let me know if I was mistaken or if you need help understanding any of these issues.
Thanks again for the great tutorial. It's really helped me grasp Bevy.