Mercurial > touhou
comparison src/th06/ecl_vm.rs @ 690:eecb8626f472
ecl_vm: implement SetBulletLaunchOffset.
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Sat, 17 Aug 2019 14:04:59 +0200 |
parents | 1adecaddf442 |
children | f5d85a646975 |
comparison
equal
deleted
inserted
replaced
689:482d81f50a11 | 690:eecb8626f472 |
---|---|
1 //! ECL runner. | 1 //! ECL runner. |
2 | 2 |
3 use crate::th06::ecl::{Ecl, SubInstruction}; | 3 use crate::th06::ecl::{Ecl, SubInstruction}; |
4 use crate::th06::enemy::{Enemy, BulletAttributes}; | 4 use crate::th06::enemy::{Enemy, BulletAttributes, Offset}; |
5 use crate::util::prng::Prng; | 5 use crate::util::prng::Prng; |
6 use std::cell::RefCell; | 6 use std::cell::RefCell; |
7 use std::rc::Rc; | 7 use std::rc::Rc; |
8 | 8 |
9 macro_rules! gen_SetBulletAttributes { | 9 macro_rules! gen_SetBulletAttributes { |
511 enemy.update_mode = 0; | 511 enemy.update_mode = 0; |
512 enemy.rotation_speed = rotation_speed; | 512 enemy.rotation_speed = rotation_speed; |
513 } | 513 } |
514 // 47 | 514 // 47 |
515 SubInstruction::SetSpeed(speed) => { | 515 SubInstruction::SetSpeed(speed) => { |
516 let speed = self.get_f32(speed); | |
516 let mut enemy = self.enemy.borrow_mut(); | 517 let mut enemy = self.enemy.borrow_mut(); |
517 enemy.update_mode = 0; | 518 enemy.update_mode = 0; |
518 enemy.speed = self.get_f32(speed); | 519 enemy.speed = speed; |
519 } | 520 } |
520 // 48 | 521 // 48 |
521 SubInstruction::SetAcceleration(acceleration) => { | 522 SubInstruction::SetAcceleration(acceleration) => { |
523 let acceleration = self.get_f32(acceleration); | |
522 let mut enemy = self.enemy.borrow_mut(); | 524 let mut enemy = self.enemy.borrow_mut(); |
523 enemy.update_mode = 0; | 525 enemy.update_mode = 0; |
524 enemy.acceleration = self.get_f32(acceleration); | 526 enemy.acceleration = acceleration; |
525 } | 527 } |
526 // 49 | 528 // 49 |
527 SubInstruction::SetRandomAngle(min_angle, max_angle) => { | 529 SubInstruction::SetRandomAngle(min_angle, max_angle) => { |
528 let angle = self.get_prng().borrow_mut().get_f64() as f32 * (max_angle - min_angle) + min_angle; | 530 let angle = self.get_prng().borrow_mut().get_f64() as f32 * (max_angle - min_angle) + min_angle; |
529 let mut enemy = self.enemy.borrow_mut(); | 531 let mut enemy = self.enemy.borrow_mut(); |
641 (enemy->bullet_attributes).number_of_shots = enemy.pos.pos.y + enemy.bullet_pos.pos.y; | 643 (enemy->bullet_attributes).number_of_shots = enemy.pos.pos.y + enemy.bullet_pos.pos.y; |
642 (enemy->bullet_attributes).speed = enemy.z + bullet_pos.z; | 644 (enemy->bullet_attributes).speed = enemy.z + bullet_pos.z; |
643 enemy.fire(bullet_attributes=bullet_attributes) | 645 enemy.fire(bullet_attributes=bullet_attributes) |
644 } | 646 } |
645 */ | 647 */ |
648 | |
646 // 81 | 649 // 81 |
647 /* | 650 SubInstruction::SetBulletLaunchOffset(dx, dy, dz) => { |
648 SubInstruction::SetBulletLaunchOffset(x, y, z) => { | 651 let (dx, dy, dz) = (self.get_f32(dx), self.get_f32(dy), self.get_f32(dz)); |
649 let mut enemy = self.enemy.borrow_mut(); | 652 let mut enemy = self.enemy.borrow_mut(); |
650 enemy.bullet_launch_offset = (self._getval(x), self._getval(y), self._getval(z)); | 653 enemy.bullet_offset = Offset { dx, dy }; |
651 } | 654 } |
652 */ | 655 |
653 // 82 | 656 // 82 |
654 // TODO: correct but how to implement that in a rusty way? | 657 // TODO: correct but how to implement that in a rusty way? |
655 /* | 658 /* |
656 SubInstruction::SetExtendedBulletAttributes(x, y, z) => { | 659 SubInstruction::SetExtendedBulletAttributes(x, y, z) => { |
657 let mut enemy = self.enemy.borrow_mut(); | 660 let mut enemy = self.enemy.borrow_mut(); |