Giter Site home page Giter Site logo

bevy_chess's People

Contributors

aevyrie avatar guimcaballero 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

Watchers

 avatar  avatar  avatar  avatar

bevy_chess's Issues

One more issue for Tutorial Code compilation

While following along, I had to do these updates to have the code working:
Section: Displaying the current turn
code block: first
function: init_next_move_text
description: When creating the TextStyle, it now takes another property: alignment: TextAlignment, I fixed mine by adding ..Default::default() to the block

After this, I went until the end of the tutorial and it is all working nicely.

Rust compilation error in tutorial

While follow the tutorial, when doing the "Implementing available squares" section I came across a compilation error.
cannot borrow `pieces_query` as mutable more than once at a time

This happens in the last code block in the section above. In there, it says to add the pieces_vec inside the if let Ok section, but you actually have to add it before that section.

Why do the resources not implement Properties?

Easy as that! We're deriving Default so that when the plugin is initialized it starts with a None value, but we could provide an initial value in case we wanted by implementing FromResources. You can see how it works in this Bevy example.

The liked example in the last sentence states

Registered components must implement the Properties and FromResources traits.`

Aren't our resources missing Properties? Do we need it? If not, why not?

Movement broken after 1st capture

After capturing a single pawn, pieces can no longer move. The sequence of moves shown in the readme GIF is no longer possible.

This seems to have been triggered by the upgrade to Bevy 0.4 (324b6dc), as the commit just before (22f65da) works fine.

Using Windows 10 64-bit.

Missing / Out-of-Order Code in Tutorial

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:

fn select_square(
    pick_state: Res<PickState>,
    mouse_button_inputs: Res<Input<MouseButton>>,
    mut selected_square: ResMut<SelectedSquare>,
    mut selected_piece: ResMut<SelectedPiece>,
    squares_query: Query<&Square>,
    mut pieces_query: Query<(Entity, &mut Piece)>,
) {

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:

fn select_square(
                [...]

                // Move the selected piece to the selected square
                if let Ok((_piece_entity, mut piece)) = pieces_query.get_mut(selected_piece_entity)
                {
                    if piece.is_move_valid((square.x, square.y), pieces_vec) {
                        piece.x = square.x;
                        piece.y = square.y;
                    }
                }

                [...]
}

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 line if let Ok((_piece_entity, mut piece)) = pieces_query.get_mut(selected_piece_entity).

Note: The tuple inside the .map(| |) closure and Ok(()) lines only contains two arguments as the children argument has not been introduced by this point in the tutorial.

Field 0 of struct bevy::prelude::Children is private

In 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:

...
 let pieces_entity_vec: Vec<(Entity, Piece, Vec<Entity>)> = pieces_query
                    .iter_mut()
                    .map(|(entity, piece, children)| {
                        (
                            entity,
                            *piece,
                            children.0.iter().map(|entity| *entity).collect(),
                        )
                    })
                    .collect();
...

At this point, you will receive the error "field 0 of struct bevy::prelude::Children is private" on the children.0.iter()... line.

Solution: Change children.0.iter() to children.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.

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.