-
-
Notifications
You must be signed in to change notification settings - Fork 124
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Added R key to reset game * Invaders, Shield, Player module processing * Improve the processing of Shield and Player modules
- Loading branch information
Showing
5 changed files
with
118 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
use crate::geo::Point; | ||
use crate::loader::Assets; | ||
use crate::sprites::{Frame, SpriteRef}; | ||
use core::time::Duration; | ||
|
||
// Player positioning | ||
const PLAYER_START: Point = Point::new(80, 216); | ||
|
||
/// The player entity. | ||
#[derive(Debug)] | ||
pub(crate) struct Player { | ||
pub sprite: SpriteRef, | ||
pub pos: Point, | ||
pub dt: Duration, | ||
} | ||
|
||
impl Player { | ||
pub fn new(assets: &Assets) -> Self { | ||
let sprite = SpriteRef::new(assets, Frame::Player1, Duration::from_millis(100)); | ||
let pos = PLAYER_START; | ||
let dt = Duration::default(); | ||
Player { sprite, pos, dt } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
use crate::geo::Point; | ||
use crate::loader::Assets; | ||
use crate::sprites::{Frame, Sprite}; | ||
|
||
/// The shield entity. | ||
#[derive(Debug)] | ||
pub(crate) struct Shield { | ||
// Shield sprite is not referenced because we want to deform it when it gets shot | ||
pub sprite: Sprite, | ||
pub pos: Point, | ||
} | ||
|
||
impl Shield { | ||
// New | ||
pub fn new(assets: &Assets, pos: Point) -> Self { | ||
let sprite = Sprite::new(assets, Frame::Shield1); | ||
|
||
Shield { sprite, pos } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters