Mercurial > touhou
diff src/th06/enemy.rs @ 738:817c453b7223
stagerunner: Add a binary able to run multiple enemies.
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Sat, 28 Dec 2019 23:53:09 +0100 |
parents | 0977d479e37d |
children | 3555845f8cf4 |
line wrap: on
line diff
--- a/src/th06/enemy.rs +++ b/src/th06/enemy.rs @@ -280,6 +280,8 @@ pub struct Enemy { pub(crate) boss: bool, pub(crate) automatic_orientation: bool, pub(crate) delay_attack: bool, + // Actually part of type_ atm. + pub(crate) mirror: bool, // Tuples. pub(crate) difficulty_coeffs: DifficultyCoeffs, @@ -315,19 +317,21 @@ pub struct Enemy { impl Enemy { /// Create a new enemy. - pub fn new(pos: Position, life: i32, bonus_dropped: u32, die_score: u32, anm0: Weak<RefCell<Anm0>>, game: Weak<RefCell<Game>>) -> Rc<RefCell<Enemy>> { + pub fn new(pos: Position, life: i16, bonus_dropped: i16, die_score: u32, mirror: bool, anm0: Weak<RefCell<Anm0>>, game: Weak<RefCell<Game>>) -> Rc<RefCell<Enemy>> { let game_rc = game.upgrade().unwrap(); let mut enemy = Enemy { pos, anm0, game, visible: true, - bonus_dropped, + // XXX: shouldn’t be u32, since that can be -1. + bonus_dropped: bonus_dropped as u32, die_score, life: if life < 0 { 1 } else { life as u32 }, touchable: true, collidable: true, damageable: true, + mirror, ..Default::default() }; let mut game = game_rc.borrow_mut(); @@ -457,7 +461,7 @@ impl Enemy { let dx = self.angle.cos() * speed; let dy = self.angle.sin() * speed; - if self.type_ & 2 != 0 { + if self.mirror { x -= dx; } else { x += dx;