-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: initial implementation of legion ecs (#4)
* chore: refactor method locations * feat: implement velocity based collision on player * feat: support non-square maps * feat: update door icon * feat: initial implementation of legion ecs
- Loading branch information
1 parent
56e1954
commit 2df6899
Showing
16 changed files
with
627 additions
and
245 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,30 +1,38 @@ | ||
######################################################################################################################## | ||
# # | ||
# * # | ||
# # | ||
# # | ||
# # | ||
# # | ||
# # | ||
# # | ||
# |--------| # | ||
# | , | * # | ||
# | | # | ||
# |---+----| # | ||
##################################################################################################################### | ||
# | # | ||
#* | # | ||
# | # | ||
# | # | ||
# |----------/# | ||
# * # | ||
# # | ||
# # | ||
# |--------| # | ||
# | , | * # | ||
# | | # | ||
# |---/----| # | ||
# # | ||
# # | ||
# # | ||
# # | ||
# # | ||
# |-----------| # | ||
# | | # | ||
# | | # | ||
# | | # | ||
# |-----x-----| # | ||
# |-----+-----| # | ||
# # | ||
# # | ||
# # | ||
# * # | ||
# # | ||
# # | ||
########################################################################################################################% | ||
############################################ #################################################### | ||
######################## | ||
|
||
|
||
|
||
|
||
|
||
|
||
% |
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,20 @@ | ||
use crate::background_map::tiles::door::Door; | ||
use crate::background_map::tiles::wall::Wall; | ||
use crate::background_map::tiles::{OpenState, Tile}; | ||
|
||
pub fn map_character_to_tile(x: i32, y: i32, character: char) -> Tile { | ||
match character { | ||
'\n' => Tile::NewLine, | ||
'\r' => Tile::CarriageReturn, | ||
'%' => Tile::EndOfFile, | ||
'#' => Tile::Boundary, | ||
' ' => Tile::EmptySpace, | ||
'|' => Tile::Wall(Wall::new(x, y, character)), | ||
'-' => Tile::Wall(Wall::new(x, y, character)), | ||
'+' => Tile::Door(Door::new(x, y, OpenState::Closed)), | ||
'/' => Tile::Door(Door::new(x, y, OpenState::Open)), | ||
',' => Tile::Wall(Wall::new(x, y, character)), | ||
'*' => Tile::Wall(Wall::new(x, y, character)), | ||
_ => Tile::EmptySpace, | ||
} | ||
} |
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,48 @@ | ||
pub(crate) mod door; | ||
pub(crate) mod wall; | ||
|
||
use crate::background_map::tiles::door::Door; | ||
use crate::background_map::tiles::wall::Wall; | ||
|
||
#[derive(Clone, Copy, PartialEq)] | ||
pub enum Collidable { | ||
True, | ||
False, | ||
} | ||
|
||
#[derive(Clone, Copy)] | ||
pub enum OpenState { | ||
Open, | ||
Closed, | ||
} | ||
|
||
#[derive(Clone, Copy)] | ||
pub struct Location { | ||
pub x: i32, | ||
pub y: i32, | ||
} | ||
|
||
#[derive(Clone, Copy)] | ||
pub enum Tile { | ||
Wall(Wall), | ||
Door(Door), | ||
EmptySpace, | ||
Boundary, | ||
NewLine, | ||
CarriageReturn, | ||
EndOfFile, | ||
} | ||
|
||
impl Tile { | ||
pub fn character(&self) -> char { | ||
match self { | ||
Tile::Wall(wall) => wall.character_icon, | ||
Tile::Door(door) => door.character_icon, | ||
Tile::EmptySpace => ' ', | ||
Tile::Boundary => '#', | ||
Tile::NewLine => ' ', | ||
Tile::CarriageReturn => ' ', | ||
Tile::EndOfFile => ' ', | ||
} | ||
} | ||
} |
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 @@ | ||
pub mod components; |
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,49 @@ | ||
use console_engine::Color; | ||
use uuid::Uuid; | ||
|
||
#[derive(Clone, Copy, Debug, PartialEq)] | ||
pub struct Position { | ||
pub x: i32, | ||
pub y: i32, | ||
} | ||
|
||
#[derive(Clone, Copy, Debug, PartialEq)] | ||
pub struct Velocity { | ||
pub x: i32, | ||
pub y: i32, | ||
} | ||
|
||
#[derive(Clone, Copy, Debug, PartialEq)] | ||
pub struct OpenState { | ||
pub open: bool, | ||
} | ||
|
||
#[derive(Clone, Copy, Debug, PartialEq)] | ||
pub struct CollisionState { | ||
pub collidable: bool, | ||
} | ||
|
||
#[derive(Clone, Copy, Debug, PartialEq)] | ||
pub struct Character { | ||
pub icon: char, | ||
} | ||
|
||
#[derive(Clone, Copy, Debug, PartialEq)] | ||
pub struct EntityColour { | ||
pub colour: Color, | ||
} | ||
|
||
#[derive(Clone, Copy, Debug, PartialEq)] | ||
pub struct IsPlayer { | ||
pub is_player: bool, | ||
} | ||
|
||
#[derive(Clone, Copy, Debug, PartialEq)] | ||
pub struct VisibleState { | ||
pub visible: bool, | ||
} | ||
|
||
#[derive(Clone, Copy, Debug, PartialEq)] | ||
pub struct PlayerId { | ||
pub uuid: Uuid, | ||
} |
Oops, something went wrong.