This commit is contained in:
Jay Oster 2021-12-04 10:00:58 -08:00 committed by GitHub
parent bd2de37b84
commit b15854b4d1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 17 deletions

View file

@ -1,5 +1,5 @@
/// Player control inputs. /// Player control inputs.
#[derive(Debug)] #[derive(Debug, Default)]
pub struct Controls { pub struct Controls {
/// Move the player. /// Move the player.
pub direction: Direction, pub direction: Direction,
@ -18,15 +18,6 @@ pub enum Direction {
Right, Right,
} }
impl Default for Controls {
fn default() -> Controls {
Controls {
direction: Direction::default(),
fire: false,
}
}
}
impl Default for Direction { impl Default for Direction {
fn default() -> Direction { fn default() -> Direction {
Direction::Still Direction::Still

View file

@ -49,7 +49,7 @@ pub struct World {
player: Player, player: Player,
bullet: Option<Bullet>, bullet: Option<Bullet>,
collision: Collision, collision: Collision,
score: u32, _score: u32,
assets: Assets, assets: Assets,
dt: Duration, dt: Duration,
gameover: bool, gameover: bool,
@ -72,7 +72,7 @@ struct Invaders {
struct Invader { struct Invader {
sprite: SpriteRef, sprite: SpriteRef,
pos: Point, pos: Point,
score: u32, _score: u32,
} }
/// Creates a boundary around the live invaders. /// Creates a boundary around the live invaders.
@ -172,7 +172,7 @@ impl World {
}; };
let bullet = None; let bullet = None;
let collision = Collision::default(); let collision = Collision::default();
let score = 0; let _score = 0;
let dt = Duration::default(); let dt = Duration::default();
let gameover = false; let gameover = false;
@ -185,7 +185,7 @@ impl World {
player, player,
bullet, bullet,
collision, collision,
score, _score,
assets, assets,
dt, dt,
gameover, gameover,
@ -556,7 +556,7 @@ fn make_invader_grid(assets: &Assets) -> Vec<Vec<Option<Invader>>> {
Some(Invader { Some(Invader {
sprite: SpriteRef::new(assets, Blipjoy1, Duration::default()), sprite: SpriteRef::new(assets, Blipjoy1, Duration::default()),
pos: START + BLIPJOY_OFFSET + Point::new(x, y) * GRID, pos: START + BLIPJOY_OFFSET + Point::new(x, y) * GRID,
score: 10, _score: 10,
}) })
}) })
.collect() .collect()
@ -567,7 +567,7 @@ fn make_invader_grid(assets: &Assets) -> Vec<Vec<Option<Invader>>> {
Some(Invader { Some(Invader {
sprite: SpriteRef::new(assets, Ferris1, Duration::default()), sprite: SpriteRef::new(assets, Ferris1, Duration::default()),
pos: START + FERRIS_OFFSET + Point::new(x, y) * GRID, pos: START + FERRIS_OFFSET + Point::new(x, y) * GRID,
score: 10, _score: 10,
}) })
}) })
.collect() .collect()
@ -578,7 +578,7 @@ fn make_invader_grid(assets: &Assets) -> Vec<Vec<Option<Invader>>> {
Some(Invader { Some(Invader {
sprite: SpriteRef::new(assets, Cthulhu1, Duration::default()), sprite: SpriteRef::new(assets, Cthulhu1, Duration::default()),
pos: START + CTHULHU_OFFSET + Point::new(x, y) * GRID, pos: START + CTHULHU_OFFSET + Point::new(x, y) * GRID,
score: 10, _score: 10,
}) })
}) })
.collect() .collect()