diff 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
line wrap: on
line diff
--- a/src/th06/ecl_vm.rs
+++ b/src/th06/ecl_vm.rs
@@ -532,16 +532,16 @@ impl EclRunner {
                 enemy.angle = angle;
             }
             // 51
-             /*
-            SubInstruction::TargetPlayer(angle, speed) => {
+            SubInstruction::TargetPlayer(delta_angle, speed) => {
+                let speed = self.get_f32(speed);
                 let mut enemy = self.enemy.borrow_mut();
-                let player = enemy.select_player();
+                let game = enemy.game.upgrade().unwrap();
+                let player = game.borrow().get_player();
                 enemy.update_mode = 0;
                 enemy.speed = speed;
-                enemy.angle = enemy.get_angle(player) + angle;
+                enemy.angle = enemy.get_angle_to(player) + delta_angle;
+            }
 
-            }
-            */
             // 52 to 64 are different interlacing fields
 
             // 65