# HG changeset patch # User Emmanuel Gil Peyrot # Date 1565305423 -7200 # Node ID 988e5130fb00e0f54447fcb2ee0d93e60b37b7f5 # Parent 6b4d2b4054421c13df6a0098db103ea8a79cd8f2 Add a simpler Sprite::new() which doesn’t override width/height. diff --git a/examples/anmrenderer.rs b/examples/anmrenderer.rs --- a/examples/anmrenderer.rs +++ b/examples/anmrenderer.rs @@ -109,7 +109,7 @@ fn main() { } // Create the sprite. - let sprite = Rc::new(RefCell::new(Sprite::new(0., 0.))); + let sprite = Rc::new(RefCell::new(Sprite::new())); // TODO: seed this PRNG with a valid seed. let prng = Rc::new(RefCell::new(Prng::new(0))); diff --git a/src/th06/anm0_vm.rs b/src/th06/anm0_vm.rs --- a/src/th06/anm0_vm.rs +++ b/src/th06/anm0_vm.rs @@ -63,7 +63,18 @@ pub struct Sprite { impl Sprite { /// Create a new sprite. - pub fn new(width_override: f32, height_override: f32) -> Sprite { + pub fn new() -> Sprite { + Sprite { + changed: true, + visible: true, + rescale: [1., 1.], + color: [255, 255, 255, 255], + ..Default::default() + } + } + + /// Create a new sprite overriding its size. + pub fn with_size(width_override: f32, height_override: f32) -> Sprite { Sprite { width_override, height_override, @@ -429,7 +440,7 @@ mod tests { let anm0 = Anm0::from_slice(&buf).unwrap(); assert_eq!(anm0.size, (256, 256)); assert_eq!(anm0.format, 5); - let sprite = Rc::new(RefCell::new(Sprite::new(0., 0.))); + let sprite = Rc::new(RefCell::new(Sprite::new())); let prng = Rc::new(RefCell::new(Prng::new(0))); let mut anm_runner = AnmRunner::new(&anm0, 1, sprite.clone(), Rc::downgrade(&prng), 0); for _ in 0..50 {