Mercurial > touhou
diff src/th06/enemy.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 | 6d4802abe134 |
children | 414f8611f344 |
line wrap: on
line diff
--- a/src/th06/enemy.rs +++ b/src/th06/enemy.rs @@ -74,12 +74,34 @@ pub struct Player { pos: Position, } +/// Struct representing an enemy bullet. +pub struct Bullet { + /// Current position of the bullet. + pub pos: Position, + + /// Current speed of the bullet. + pub speed: f32, + + /// Current XXX of the bullet. + pub dpos: [f32; 3], + + /// Current XXX of the bullet. + pub flags: u32, + + /// Current frame of the bullet. + pub frame: i32, + + /// Current attributes of the bullet. + pub attributes: [f32; 2], +} + /// God struct of our game. pub struct Game { enemies: Vec<Rc<RefCell<Enemy>>>, anmrunners: Vec<Rc<RefCell<AnmRunner>>>, + pub(crate) bullets: Vec<Rc<RefCell<Bullet>>>, player: Rc<RefCell<Player>>, - prng: Rc<RefCell<Prng>>, + pub(crate) prng: Rc<RefCell<Prng>>, rank: Rank, difficulty: i32, } @@ -90,6 +112,7 @@ impl Game { Game { enemies: Vec::new(), anmrunners: Vec::new(), + bullets: Vec::new(), player: Rc::new(RefCell::new(Player { pos: Position { x: 192., y: 384. } })), prng, rank, @@ -124,6 +147,17 @@ impl Game { sprites } + // TODO: Fix this function so we can stop making Game::bullets pub. + /* + /// Apply a function on all bullets. + pub fn iter_bullets(&mut self, mut f: impl FnMut(Bullet)) { + self.bullets.iter().map(|bullet| { + let mut bullet = bullet.borrow_mut(); + f(*bullet) + }); + } + */ + pub(crate) fn get_player(&self) -> Rc<RefCell<Player>> { self.player.clone() }