fn initialise_ball(&self, world: &mut World, sprite_sheet_handle: Handle<SpriteSheet>) -> Entity {
        // Create the translation.
        let mut local_transform = Transform::default();
        local_transform.set_translation_xyz(self.window_settings.arena_width() / 2.0, self.window_settings.arena_height() / 2.0, 0.0);
        local_transform.set_scale(Vector3::new(self.window_settings.ball_scale(), self.window_settings.ball_scale(), 1.0));

        // Assign the sprite for the ball. The ball is the second sprite in the sheet.
        let sprite_render = SpriteRender::new(sprite_sheet_handle, 1);

        let mut rn = rand::thread_rng();
        let neg_x = rn.gen_bool(0.5);
        let neg_y = rn.gen_bool(0.5);
        let mult_x = if neg_x { 1.0 } else { -1.0 };
        let mult_y = if neg_y { 1.0 } else { -1.0 };
        world
            .create_entity()
            .with(sprite_render)
            .with(Ball {
                radius: self.window_settings.ball_radius(),
                velocity: [self.window_settings.ball_velocity_x() * mult_x, self.window_settings.ball_velocity_y() * mult_y],
                calculated_impact_y: None,
            })
            .with(local_transform)
            .build()
    }
/// Initialises one ball in the middle-ish of the arena.
Initialises one ball in the middle-ish of the arena.
Initialises one ball in the middle - ish of the arena .
fn initialise_ball(&self, world: &mut World, sprite_sheet_handle: Handle<SpriteSheet>) -> Entity {
        // Create the translation.
        let mut local_transform = Transform::default();
        local_transform.set_translation_xyz(self.window_settings.arena_width() / 2.0, self.window_settings.arena_height() / 2.0, 0.0);
        local_transform.set_scale(Vector3::new(self.window_settings.ball_scale(), self.window_settings.ball_scale(), 1.0));
        // Assign the sprite for the ball. The ball is the second sprite in the sheet.
        let sprite_render = SpriteRender::new(sprite_sheet_handle, 1);
        let mut rn = rand::thread_rng();
        let neg_x = rn.gen_bool(0.5);
        let neg_y = rn.gen_bool(0.5);
        let mult_x = if neg_x { 1.0 } else { -1.0 };
        let mult_y = if neg_y { 1.0 } else { -1.0 };
        world
            .create_entity()
            .with(sprite_render)
            .with(Ball {
                radius: self.window_settings.ball_radius(),
                velocity: [self.window_settings.ball_velocity_x() * mult_x, self.window_settings.ball_velocity_y() * mult_y],
                calculated_impact_y: None,
            })
            .with(local_transform)
            .build()
    }
fn initialise_ball ( & self , world : & mut World , sprite_sheet_handle : Handle < SpriteSheet > ) -> Entity { // Create the translation. let mut local_transform = Transform :: default ( ) ; local_transform . set_translation_xyz ( self . window_settings . arena_width ( ) / 2.0 , self . window_settings . arena_height ( ) / 2.0 , 0.0 ) ; local_transform . set_scale ( Vector3 :: new ( self . window_settings . ball_scale ( ) , self . window_settings . ball_scale ( ) , 1.0 ) ) ; // Assign the sprite for the ball. The ball is the second sprite in the sheet. let sprite_render = SpriteRender :: new ( sprite_sheet_handle , 1 ) ; let mut rn = rand :: thread_rng ( ) ; let neg_x = rn . gen_bool ( 0.5 ) ; let neg_y = rn . gen_bool ( 0.5 ) ; let mult_x = if neg_x { 1.0 } else { - 1.0 } ; let mult_y = if neg_y { 1.0 } else { - 1.0 } ; world . create_entity ( ) . with ( sprite_render ) . with ( Ball { radius : self . window_settings . ball_radius ( ) , velocity : [ self . window_settings . ball_velocity_x ( ) * mult_x , self . window_settings . ball_velocity_y ( ) * mult_y ] , calculated_impact_y : None , } ) . with ( local_transform ) . build ( ) }
Initialises one ball in the middle-ish of the arena.
Initialises one ball in the middle - ish of the arena .
&self
world
&mut World
sprite_sheet_handle
Handle<SpriteSheet>
&self
world
&mut World
sprite_sheet_handle
Handle<SpriteSheet>