comparison src/th06/ecl_vm.rs @ 693:14fddc27e6f5

ecl_vm: implement TargetPlayer, and add a dummy Player to Game.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Sat, 17 Aug 2019 15:33:45 +0200
parents a35df65e0d57
children f5b34a1c2707
comparison
equal deleted inserted replaced
692:a35df65e0d57 693:14fddc27e6f5
530 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;
531 let mut enemy = self.enemy.borrow_mut(); 531 let mut enemy = self.enemy.borrow_mut();
532 enemy.angle = angle; 532 enemy.angle = angle;
533 } 533 }
534 // 51 534 // 51
535 /* 535 SubInstruction::TargetPlayer(delta_angle, speed) => {
536 SubInstruction::TargetPlayer(angle, speed) => { 536 let speed = self.get_f32(speed);
537 let mut enemy = self.enemy.borrow_mut(); 537 let mut enemy = self.enemy.borrow_mut();
538 let player = enemy.select_player(); 538 let game = enemy.game.upgrade().unwrap();
539 let player = game.borrow().get_player();
539 enemy.update_mode = 0; 540 enemy.update_mode = 0;
540 enemy.speed = speed; 541 enemy.speed = speed;
541 enemy.angle = enemy.get_angle(player) + angle; 542 enemy.angle = enemy.get_angle_to(player) + delta_angle;
542 543 }
543 } 544
544 */
545 // 52 to 64 are different interlacing fields 545 // 52 to 64 are different interlacing fields
546 546
547 // 65 547 // 65
548 // to note: in game a flag is set to enable the screenbox and is set by 66 to disable 548 // to note: in game a flag is set to enable the screenbox and is set by 66 to disable
549 // it on top of setting our values. But we have a good engine and can detect if that's 549 // it on top of setting our values. But we have a good engine and can detect if that's