Mercurial > touhou
comparison src/th06/ecl_vm.rs @ 718:c187e0a6b751
ecl_vm: Implement 121 functions 0 and 1.
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Tue, 24 Sep 2019 17:49:23 +0200 |
parents | 5016c09e5d7c |
children | cffb0f1531fc |
comparison
equal
deleted
inserted
replaced
717:d5d5496e4e53 | 718:c187e0a6b751 |
---|---|
954 } | 954 } |
955 | 955 |
956 // 121 | 956 // 121 |
957 // Here lies the Di Sword of sadness | 957 // Here lies the Di Sword of sadness |
958 SubInstruction::CallSpecialFunction(function, arg) => { | 958 SubInstruction::CallSpecialFunction(function, arg) => { |
959 unimplemented!("spellcards are a bitch and a half"); | 959 match function { |
960 0 => { | |
961 let mut enemy = self.enemy.borrow_mut(); | |
962 let game = enemy.game.upgrade().unwrap(); | |
963 let mut game = game.borrow_mut(); | |
964 //game.drop_particle(12, enemy.pos, 1, 0xffffffff); | |
965 //game.iter_bullets(|mut bullet| { | |
966 for bullet in game.bullets.iter() { | |
967 //game.new_effect(bullet.sprite, TODO); | |
968 let mut bullet = bullet.borrow_mut(); | |
969 if arg == 0 { | |
970 bullet.speed = 0.; | |
971 bullet.dpos = [0., 0., 0.]; | |
972 } else if arg == 1 { | |
973 bullet.flags |= 0x10; | |
974 bullet.frame = 220; | |
975 let rand_angle = game.prng.borrow_mut().get_f64() * 2. * std::f64::consts::PI - std::f64::consts::PI; | |
976 bullet.attributes[0] = (rand_angle.cos() * 0.01) as f32; | |
977 bullet.attributes[1] = (rand_angle.sin() * 0.01) as f32; | |
978 } | |
979 } | |
980 } | |
981 1 => { | |
982 let range_x = arg as f64; | |
983 let range_y = (arg as f32 * 0.75) as f64; | |
984 let rand_x = self.get_prng().borrow_mut().get_f64(); | |
985 let rand_y = self.get_prng().borrow_mut().get_f64(); | |
986 let mut enemy = self.enemy.borrow_mut(); | |
987 let pos = [rand_x * range_x + enemy.pos.x as f64 - range_x / 2., | |
988 rand_y * range_y + enemy.pos.x as f64 - range_y / 2.]; | |
989 enemy.bullet_attributes.fire(); | |
990 } | |
991 _ => unimplemented!("spellcards are a bitch and a half") | |
992 } | |
960 } | 993 } |
961 | 994 |
962 _ => unimplemented!("{:?}", instruction) | 995 _ => unimplemented!("{:?}", instruction) |
963 } | 996 } |
964 } | 997 } |