Expose sprite angle
This commit is contained in:
parent
ea8da5e990
commit
77b8414c48
|
@ -119,10 +119,14 @@ impl Sprite {
|
|||
self.rect.set_y(new_y);
|
||||
}
|
||||
|
||||
pub fn angle(&mut self, angle: f64) {
|
||||
pub fn set_angle(&mut self, angle: f64) {
|
||||
self.angle = angle;
|
||||
}
|
||||
|
||||
pub fn angle(&self) -> f64 {
|
||||
self.angle
|
||||
}
|
||||
|
||||
pub fn position(&self) -> (i32, i32) {
|
||||
self.rect.center().into()
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ fn main() {
|
|||
let y_diff = m.y() - start_y;
|
||||
|
||||
let angle = (y_diff as f64).atan2(x_diff as f64);
|
||||
s.angle(angle.to_degrees());
|
||||
s.set_angle(angle.to_degrees());
|
||||
|
||||
for event in event_pump {
|
||||
match event {
|
||||
|
@ -38,8 +38,7 @@ fn main() {
|
|||
_ => {}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
s.draw(canvas).unwrap();
|
||||
})
|
||||
.unwrap();
|
||||
|
|
Loading…
Reference in a new issue