struct Player { //image: Image, texture: Texture, pos_x: f64, pos_y: f64, size: f64, up_d: bool, down_d: bool, left_d: bool, right_d: bool, life: i8, score: i64, } impl Player { fn update(&mut self, _args: &UpdateArgs) { self.pos_y-=0.8; if self.pos_x < 50.0 { self.pos_x = 50.0; } if self.pos_x > 490.0 { self.pos_x = 490.0; } if self.pos_y < 0.0{ self.pos_y = 0.0; } if self.pos_y > 540.0 { self.pos_y = 540.0; } if self.up_d { self.pos_y -= 1.0; } if self.down_d { self.pos_y += 1.0; } if self.left_d { self.pos_x-=2.0; } if self.right_d { self.pos_x+=2.0; } } fn press_player(&mut self, args: &Button){ if let &Button::Keyboard(key) = args { match key { Key::Up => { self.up_d = true; } Key::Down => { self.down_d = true; } Key::Left => { self.left_d = true; } Key::Right => { self.right_d = true; } _ => {} } } } fn rel_player(&mut self, args: &Button){ if let &Button::Keyboard(key) = args { match key { Key::Up => { self.up_d = false; } Key::Down => { self.down_d = false; } Key::Left => { self.left_d = false; } Key::Right => { self.right_d = false; } _ => {} } } } }