diff options
| author | troido <troido@protonmail.com> | 2020-02-03 16:36:52 +0100 |
|---|---|---|
| committer | troido <troido@protonmail.com> | 2020-02-03 16:36:52 +0100 |
| commit | 19ce5319e2250b7b0e1a188f69d24de282a85a7f (patch) | |
| tree | 2e51064f5e1dfa82304c558c56ab907255c953bd /src/components.rs | |
| parent | f0153eefd580ec443b380504303620a61f24630b (diff) | |
merged Draw into View; renamed Position to Pos
Diffstat (limited to 'src/components.rs')
| -rw-r--r-- | src/components.rs | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/src/components.rs b/src/components.rs index aae6453..1613b7f 100644 --- a/src/components.rs +++ b/src/components.rs @@ -11,30 +11,30 @@ use super::util::clamp; #[derive(Component, Debug, Hash, PartialEq, Eq, Clone, Copy)] -pub struct Position { +pub struct Pos { pub x: i32, pub y: i32 } -impl ops::Add<Position> for Position { - type Output = Position; +impl ops::Add<Pos> for Pos { + type Output = Pos; - fn add(self, other: Position) -> Position { - Position { + fn add(self, other: Pos) -> Pos { + Pos { x: self.x + other.x, y: self.y + other.y } } } -impl Position { +impl Pos { - pub fn new(x: i32, y: i32) -> Position { - Position {x, y} + pub fn new(x: i32, y: i32) -> Pos { + Pos {x, y} } - pub fn clamp(self, smaller: Position, larger: Position) -> Position { - Position { + pub fn clamp(self, smaller: Pos, larger: Pos) -> Pos { + Pos { x: clamp(self.x, smaller.x, larger.x), y: clamp(self.y, smaller.y, larger.y) } |
