comparison src/th06/anm0_vm.rs @ 709:6d4802abe134

Make interpolators use u32 instead of u16.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Sun, 08 Sep 2019 17:53:13 +0200
parents b6c351ca0a35
children 3555845f8cf4
comparison
equal deleted inserted replaced
708:3954801b6299 709:6d4802abe134
26 26
27 /// Base visual element. 27 /// Base visual element.
28 #[derive(Debug, Clone, Default)] 28 #[derive(Debug, Clone, Default)]
29 pub struct Sprite { 29 pub struct Sprite {
30 blendfunc: u32, 30 blendfunc: u32,
31 frame: u16, 31 frame: u32,
32 32
33 width_override: f32, 33 width_override: f32,
34 height_override: f32, 34 height_override: f32,
35 angle: f32, 35 angle: f32,
36 36
224 script: Script, 224 script: Script,
225 instruction_pointer: usize, 225 instruction_pointer: usize,
226 frame: u16, 226 frame: u16,
227 waiting: bool, 227 waiting: bool,
228 variables: ([i32; 4], [f32; 4], [i32; 4]), 228 variables: ([i32; 4], [f32; 4], [i32; 4]),
229 timeout: Option<u16>, 229 timeout: Option<u32>,
230 } 230 }
231 231
232 impl AnmRunner { 232 impl AnmRunner {
233 /// Create a new `AnmRunner`. 233 /// Create a new `AnmRunner`.
234 pub fn new(anm: &Anm0, script_id: u8, sprite: Rc<RefCell<Sprite>>, prng: Weak<RefCell<Prng>>, sprite_index_offset: u32) -> AnmRunner { 234 pub fn new(anm: &Anm0, script_id: u8, sprite: Rc<RefCell<Sprite>>, prng: Weak<RefCell<Prng>>, sprite_index_offset: u32) -> AnmRunner {
355 } 355 }
356 Instruction::SetScaleSpeed(ssx, ssy) => { 356 Instruction::SetScaleSpeed(ssx, ssy) => {
357 sprite.scale_speed = [ssx, ssy]; 357 sprite.scale_speed = [ssx, ssy];
358 } 358 }
359 Instruction::Fade(new_alpha, duration) => { 359 Instruction::Fade(new_alpha, duration) => {
360 sprite.fade_interpolator = Some(Interpolator1::new([sprite.color[3] as f32], sprite.frame, [new_alpha as f32], sprite.frame + duration as u16, Formula::Linear)); 360 sprite.fade_interpolator = Some(Interpolator1::new([sprite.color[3] as f32], sprite.frame, [new_alpha as f32], sprite.frame + duration, Formula::Linear));
361 } 361 }
362 Instruction::SetBlendmodeAlphablend() => { 362 Instruction::SetBlendmodeAlphablend() => {
363 sprite.blendfunc = 1; 363 sprite.blendfunc = 1;
364 } 364 }
365 Instruction::SetBlendmodeAdd() => { 365 Instruction::SetBlendmodeAdd() => {
383 } 383 }
384 Instruction::Move(x, y, z) => { 384 Instruction::Move(x, y, z) => {
385 sprite.dest_offset = [x, y, z]; 385 sprite.dest_offset = [x, y, z];
386 } 386 }
387 Instruction::MoveToLinear(x, y, z, duration) => { 387 Instruction::MoveToLinear(x, y, z, duration) => {
388 sprite.offset_interpolator = Some(Interpolator3::new(sprite.dest_offset, sprite.frame, [x, y, z], sprite.frame + duration as u16, Formula::Linear)); 388 sprite.offset_interpolator = Some(Interpolator3::new(sprite.dest_offset, sprite.frame, [x, y, z], sprite.frame + duration, Formula::Linear));
389 } 389 }
390 Instruction::MoveToDecel(x, y, z, duration) => { 390 Instruction::MoveToDecel(x, y, z, duration) => {
391 sprite.offset_interpolator = Some(Interpolator3::new(sprite.dest_offset, sprite.frame, [x, y, z], sprite.frame + duration as u16, Formula::InvertPower2)); 391 sprite.offset_interpolator = Some(Interpolator3::new(sprite.dest_offset, sprite.frame, [x, y, z], sprite.frame + duration, Formula::InvertPower2));
392 } 392 }
393 Instruction::MoveToAccel(x, y, z, duration) => { 393 Instruction::MoveToAccel(x, y, z, duration) => {
394 sprite.offset_interpolator = Some(Interpolator3::new(sprite.dest_offset, sprite.frame, [x, y, z], sprite.frame + duration as u16, Formula::Power2)); 394 sprite.offset_interpolator = Some(Interpolator3::new(sprite.dest_offset, sprite.frame, [x, y, z], sprite.frame + duration, Formula::Power2));
395 } 395 }
396 Instruction::Wait() => { 396 Instruction::Wait() => {
397 self.waiting = true; 397 self.waiting = true;
398 } 398 }
399 // There is nothing to do here. 399 // There is nothing to do here.
421 } 421 }
422 Instruction::SetVisible(visible) => { 422 Instruction::SetVisible(visible) => {
423 sprite.visible = (visible & 1) != 0; 423 sprite.visible = (visible & 1) != 0;
424 } 424 }
425 Instruction::ScaleIn(sx, sy, duration) => { 425 Instruction::ScaleIn(sx, sy, duration) => {
426 sprite.scale_interpolator = Some(Interpolator2::new(sprite.rescale, sprite.frame, [sx, sy], sprite.frame + duration as u16, Formula::Linear)); 426 sprite.scale_interpolator = Some(Interpolator2::new(sprite.rescale, sprite.frame, [sx, sy], sprite.frame + duration, Formula::Linear));
427 } 427 }
428 Instruction::Todo(_todo) => { 428 Instruction::Todo(_todo) => {
429 // TODO. 429 // TODO.
430 } 430 }
431 } 431 }