fn initialise_paddles(world: &mut World, spritesheet: TextureHandle) {
    use {PADDLE_HEIGHT, PADDLE_VELOCITY, PADDLE_WIDTH};

    let mut left_transform = Transform::default();
    let mut right_transform = Transform::default();

    // Correctly position the paddles.
    let y = (ARENA_HEIGHT - PADDLE_HEIGHT) / 2.0;
    left_transform.translation = Vector3::new(PADDLE_WIDTH * 0.5, y, 0.0);
    right_transform.translation = Vector3::new(ARENA_WIDTH - PADDLE_WIDTH * 0.5, y, 0.0);

    // Create a left plank entity.
    let paddle_left = world
        .create_entity()
        .with(Paddle {
            side: Side::Left,
            width: PADDLE_WIDTH,
            height: PADDLE_HEIGHT,
            velocity: PADDLE_VELOCITY,
        })
        .with(GlobalTransform::default())
        .with(left_transform)
        .build();

    // Create right plank entity.
    let paddle_right = world
        .create_entity()
        .with(Paddle {
            side: Side::Right,
            width: PADDLE_WIDTH,
            height: PADDLE_HEIGHT,
            velocity: PADDLE_VELOCITY,
        })
        .with(GlobalTransform::default())
        .with(right_transform)
        .build();

    // Build the sprite for the paddles.
    let sprite = Sprite {
        left: 0.0,
        right: PADDLE_WIDTH,
        top: 0.0,
        bottom: PADDLE_HEIGHT,
    };

    // Add the sprite to the paddles.
    // This is done in a separate step here because as they are identical sprites,
    // adding them both at once allows for better performance. Check out the ball
    // sprite to see how to add a sprite to only one entity.
    world
        .exec(|mut data: SpriteRenderData| {
            data.add_multiple(
                vec![paddle_left, paddle_right],
                &sprite,
                spritesheet,
                SPRITESHEET_SIZE,
            )
        })
        .expect("Error creating SpriteRender for paddles");
}
/// Initialises one paddle on the left, and one paddle on the right.
Initialises one paddle on the left, and one paddle on the right.
Initialises one paddle on the left and one paddle on the right .
fn initialise_paddles(world: &mut World, spritesheet: TextureHandle) {
    use {PADDLE_HEIGHT, PADDLE_VELOCITY, PADDLE_WIDTH};
    let mut left_transform = Transform::default();
    let mut right_transform = Transform::default();
    // Correctly position the paddles.
    let y = (ARENA_HEIGHT - PADDLE_HEIGHT) / 2.0;
    left_transform.translation = Vector3::new(PADDLE_WIDTH * 0.5, y, 0.0);
    right_transform.translation = Vector3::new(ARENA_WIDTH - PADDLE_WIDTH * 0.5, y, 0.0);
    // Create a left plank entity.
    let paddle_left = world
        .create_entity()
        .with(Paddle {
            side: Side::Left,
            width: PADDLE_WIDTH,
            height: PADDLE_HEIGHT,
            velocity: PADDLE_VELOCITY,
        })
        .with(GlobalTransform::default())
        .with(left_transform)
        .build();
    // Create right plank entity.
    let paddle_right = world
        .create_entity()
        .with(Paddle {
            side: Side::Right,
            width: PADDLE_WIDTH,
            height: PADDLE_HEIGHT,
            velocity: PADDLE_VELOCITY,
        })
        .with(GlobalTransform::default())
        .with(right_transform)
        .build();
    // Build the sprite for the paddles.
    let sprite = Sprite {
        left: 0.0,
        right: PADDLE_WIDTH,
        top: 0.0,
        bottom: PADDLE_HEIGHT,
    };
    // Add the sprite to the paddles.
    // This is done in a separate step here because as they are identical sprites,
    // adding them both at once allows for better performance. Check out the ball
    // sprite to see how to add a sprite to only one entity.
    world
        .exec(|mut data: SpriteRenderData| {
            data.add_multiple(
                vec![paddle_left, paddle_right],
                &sprite,
                spritesheet,
                SPRITESHEET_SIZE,
            )
        })
        .expect("Error creating SpriteRender for paddles");
}
fn initialise_paddles ( world : & mut World , spritesheet : TextureHandle ) { use { PADDLE_HEIGHT , PADDLE_VELOCITY , PADDLE_WIDTH } ; let mut left_transform = Transform :: default ( ) ; let mut right_transform = Transform :: default ( ) ; // Correctly position the paddles. let y = ( ARENA_HEIGHT - PADDLE_HEIGHT ) / 2.0 ; left_transform . translation = Vector3 :: new ( PADDLE_WIDTH * 0.5 , y , 0.0 ) ; right_transform . translation = Vector3 :: new ( ARENA_WIDTH - PADDLE_WIDTH * 0.5 , y , 0.0 ) ; // Create a left plank entity. let paddle_left = world . create_entity ( ) . with ( Paddle { side : Side :: Left , width : PADDLE_WIDTH , height : PADDLE_HEIGHT , velocity : PADDLE_VELOCITY , } ) . with ( GlobalTransform :: default ( ) ) . with ( left_transform ) . build ( ) ; // Create right plank entity. let paddle_right = world . create_entity ( ) . with ( Paddle { side : Side :: Right , width : PADDLE_WIDTH , height : PADDLE_HEIGHT , velocity : PADDLE_VELOCITY , } ) . with ( GlobalTransform :: default ( ) ) . with ( right_transform ) . build ( ) ; // Build the sprite for the paddles. let sprite = Sprite { left : 0.0 , right : PADDLE_WIDTH , top : 0.0 , bottom : PADDLE_HEIGHT , } ; // Add the sprite to the paddles. // This is done in a separate step here because as they are identical sprites, // adding them both at once allows for better performance. Check out the ball // sprite to see how to add a sprite to only one entity. world . exec ( | mut data : SpriteRenderData | { data . add_multiple ( vec ! [ paddle_left paddle_right ] , & sprite , spritesheet , SPRITESHEET_SIZE , ) } ) . expect ( " " ) ; }
Initialises one paddle on the left, and one paddle on the right.
Initialises one paddle on the left and one paddle on the right .
world
&mut World
spritesheet
TextureHandle
world
&mut World
spritesheet
TextureHandle