Mercurial > touhou
comparison src/th06/enemy.rs @ 664:f08e8e3c6196
Use bitflags for the rank, instead of an u16.
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Sun, 11 Aug 2019 19:55:45 +0200 |
parents | 107bb5ca5cc8 |
children | 965ecdbf0316 |
comparison
equal
deleted
inserted
replaced
663:994f41154be8 | 664:f08e8e3c6196 |
---|---|
1 //! Module providing an Enemy struct, to be changed by EclRunner. | 1 //! Module providing an Enemy struct, to be changed by EclRunner. |
2 | 2 |
3 use crate::th06::anm0::Anm0; | 3 use crate::th06::anm0::Anm0; |
4 use crate::th06::anm0_vm::{Sprite, AnmRunner}; | 4 use crate::th06::anm0_vm::{Sprite, AnmRunner}; |
5 use crate::th06::ecl::Rank; | |
5 use crate::th06::interpolator::{Interpolator1, Interpolator2}; | 6 use crate::th06::interpolator::{Interpolator1, Interpolator2}; |
6 use crate::util::prng::Prng; | 7 use crate::util::prng::Prng; |
7 use std::cell::RefCell; | 8 use std::cell::RefCell; |
8 use std::collections::HashMap; | 9 use std::collections::HashMap; |
9 use std::rc::{Rc, Weak}; | 10 use std::rc::{Rc, Weak}; |
58 /// God struct of our game. | 59 /// God struct of our game. |
59 pub struct Game { | 60 pub struct Game { |
60 enemies: Vec<Rc<RefCell<Enemy>>>, | 61 enemies: Vec<Rc<RefCell<Enemy>>>, |
61 anmrunners: Vec<Rc<RefCell<AnmRunner>>>, | 62 anmrunners: Vec<Rc<RefCell<AnmRunner>>>, |
62 prng: Rc<RefCell<Prng>>, | 63 prng: Rc<RefCell<Prng>>, |
63 rank: i32, | 64 rank: Rank, |
64 difficulty: i32, | 65 difficulty: i32, |
65 } | 66 } |
66 | 67 |
67 impl Game { | 68 impl Game { |
68 /// Create said god struct. | 69 /// Create said god struct. |
69 pub fn new(prng: Rc<RefCell<Prng>>) -> Game { | 70 pub fn new(prng: Rc<RefCell<Prng>>, rank: Rank) -> Game { |
70 Game { | 71 Game { |
71 enemies: Vec::new(), | 72 enemies: Vec::new(), |
72 anmrunners: Vec::new(), | 73 anmrunners: Vec::new(), |
73 prng, | 74 prng, |
74 rank: 0, | 75 rank, |
75 difficulty: 0, | 76 difficulty: 0, |
76 } | 77 } |
77 } | 78 } |
78 | 79 |
79 /// Run the simulation for a single frame. | 80 /// Run the simulation for a single frame. |
260 self.pos = Position { x, y }; | 261 self.pos = Position { x, y }; |
261 | 262 |
262 self.frame += 1; | 263 self.frame += 1; |
263 } | 264 } |
264 | 265 |
265 pub(crate) fn get_rank(&self) -> i32 { | 266 pub(crate) fn get_rank(&self) -> Rank { |
266 let game = self.game.upgrade().unwrap(); | 267 let game = self.game.upgrade().unwrap(); |
267 let game = game.borrow(); | 268 let game = game.borrow(); |
268 game.rank | 269 game.rank |
269 } | 270 } |
270 | 271 |