comparison src/th06/ecl_vm.rs @ 739:01915da33b99

ecl_vm: Let enemies spawn other enemies.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Mon, 06 Jan 2020 22:43:31 +0100
parents 817c453b7223
children
comparison
equal deleted inserted replaced
738:817c453b7223 739:01915da33b99
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, Offset, BulletAttributes}; 4 use crate::th06::enemy::{Enemy, Offset, BulletAttributes, Position};
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 {
774 unimplemented!("spellcard end"); 774 unimplemented!("spellcard end");
775 775
776 } 776 }
777 777
778 // 95 778 // 95
779 /* 779 SubInstruction::SpawnEnemy(sub, x, y, z, life, bonus, score) => {
780 SubInstruction::PopEnemy(sub, x, y, z, life, bonus_dropped, die_score) => { 780 let x = self.get_f32(x);
781 self._pop_enemy(sub, 0, self.get_f32(x), 781 let y = self.get_f32(y);
782 self.get_f32(y), 782 let _z = self.get_f32(z);
783 self.get_f32(z), 783 let enemy = self.enemy.borrow_mut();
784 life, bonus_dropped, die_score) 784 let anm0 = enemy.anm0.upgrade().unwrap();
785 785 let game = enemy.game.upgrade().unwrap();
786 } 786 let enemy = Enemy::new(Position::new(x, y), life, bonus, score as u32, false, Rc::downgrade(&anm0), Rc::downgrade(&game));
787 */ 787 let ecl = self.ecl.clone().unwrap();
788 788 let mut runner = EclRunner::new(&ecl, enemy, sub as u16);
789 runner.run_frame();
790 }
789 791
790 // 96 792 // 96
791 /* 793 /*
792 SubInstruction::KillEnemies() => { 794 SubInstruction::KillEnemies() => {
793 let mut game = self.game.borrow_mut(); 795 let mut game = self.game.borrow_mut();
1285 #[cfg(test)] 1287 #[cfg(test)]
1286 mod tests { 1288 mod tests {
1287 use super::*; 1289 use super::*;
1288 use crate::th06::anm0::Anm0; 1290 use crate::th06::anm0::Anm0;
1289 use crate::th06::ecl::{Sub, CallSub, Rank}; 1291 use crate::th06::ecl::{Sub, CallSub, Rank};
1290 use crate::th06::enemy::{Game, Position}; 1292 use crate::th06::enemy::Game;
1291 use std::io::{self, Read}; 1293 use std::io::{self, Read};
1292 use std::fs::File; 1294 use std::fs::File;
1293 1295
1294 fn setup() -> (Rc<RefCell<Game>>, Rc<RefCell<Enemy>>) { 1296 fn setup() -> (Rc<RefCell<Game>>, Rc<RefCell<Enemy>>) {
1295 let file = File::open("EoSD/ST/stg1enm.anm").unwrap(); 1297 let file = File::open("EoSD/ST/stg1enm.anm").unwrap();