Sortir ce drawcall de la boucle
fn draw(&mut self, ctx: &mut Context) -> GameResult {
graphics::clear(ctx, Color::BLUE);
for i in 0..11{
for y in 0..8{
let a=y as f32;
let r=i as f32;
graphics::draw(ctx, &self.sol, DrawParam::default().dest(Vec2::new(0.0+(r*75.0), 100.0+a*75.0)).scale(Vec2::new(0.5, 0.5)))?;}}
graphics::draw(ctx, &self.image, DrawParam::default().dest(Vec2::new(self.pos_x, self.pos_y)).scale(Vec2::new(0.05, 0.05)))?;
for i in 0..self.num_bat {
let x=self.coord[i].x;
let y=self.coord[i].y;
graphics::draw(ctx, &self.image, DrawParam::default().dest(Vec2::new(x, y)).scale(Vec2::new(0.1, 0.1)))?;}
graphics::present(ctx)?;
Ok(())
}
Ici la ligne graphics::draw(ctx, &self.image, DrawParam::default().dest(Vec2::new(self.pos_x, self.pos_y)).scale(Vec2::new(0.05, 0.05)))?;
pourrais sortir de la boucle car aucun param depends de la boucle.