first steps with refs

This commit is contained in:
2023-11-27 19:21:10 +01:00
parent 227e44dd43
commit 677acf771a
6 changed files with 198 additions and 23 deletions

View File

@@ -1,7 +1,23 @@
use crate::level::Level;
use crate::player::Player;
pub const LEVELS: usize = 2;
pub struct Game<'game> {
pub player: &'game mut Player,
pub levels: Vec<&'game mut Level>,
pub levels: Vec<Level>,
}
impl Game<'_> {
pub fn new(p: &mut Player) -> Game {
let mut v: Vec<Level> = Vec::with_capacity(LEVELS);
for _ in 0..LEVELS {
let mut l = Level::new();
v.push(l);
}
Game {
player: p,
levels: v,
}
}
}