This repository has been archived by the owner on Jan 23, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
101 additions
and
103 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
use transform::Transform; | ||
use math::Transform; | ||
|
||
pub struct Camera { | ||
pub transform: Transform, | ||
|
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
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,11 @@ | ||
use std::ops::SubAssign; | ||
pub fn check_and_use<T, K>(resource: &mut T, cost: K) -> bool | ||
where T: SubAssign<K> + PartialOrd<K> | ||
{ | ||
if *resource >= cost { | ||
*resource -= cost; | ||
true | ||
} else { | ||
false | ||
} | ||
} |
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,5 @@ | ||
pub mod vector; | ||
pub mod transform; | ||
pub mod polar_coords; | ||
mod check_and_use; | ||
pub use self::check_and_use::check_and_use; |
2 changes: 1 addition & 1 deletion
2
nitro/src/polar_coords.rs → nitro/src/math_private/polar_coords.rs
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,4 +1,4 @@ | ||
use Vector; | ||
use math::Vector; | ||
use std::f32; | ||
|
||
pub struct PolarCoords { | ||
|
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,5 +1,5 @@ | ||
use std::f32; | ||
use Vector; | ||
use math::Vector; | ||
|
||
#[derive(Copy, Clone, Debug)] | ||
pub struct Transform { | ||
|
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,3 @@ | ||
use nphysics2d; | ||
|
||
pub type Vector = nphysics2d::math::Vector<f32>; |
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,51 @@ | ||
use std::borrow::{Borrow, BorrowMut}; | ||
|
||
/// Special variant of Option that indicates a value may exist but is currently loaned out in a | ||
/// &mut. | ||
pub enum OptionLoaned<T> { | ||
Some(T), | ||
Loaned, | ||
None, | ||
} | ||
|
||
impl<T> From<Option<Option<T>>> for OptionLoaned<T> { | ||
fn from(result: Option<Option<T>>) -> OptionLoaned<T> { | ||
match result { | ||
Some(Some(result)) => OptionLoaned::Some(result), | ||
Some(None) => OptionLoaned::Loaned, | ||
None => OptionLoaned::None, | ||
} | ||
} | ||
} | ||
|
||
impl<'a, T, M> From<Option<&'a Option<M>>> for OptionLoaned<&'a T> | ||
where M: Borrow<T> | ||
{ | ||
fn from(result: Option<&'a Option<M>>) -> OptionLoaned<&'a T> { | ||
match result { | ||
Some(inner) => { | ||
match inner.as_ref() { | ||
Some(inner) => OptionLoaned::Some(inner.borrow()), | ||
None => OptionLoaned::Loaned, | ||
} | ||
} | ||
None => OptionLoaned::None, | ||
} | ||
} | ||
} | ||
|
||
impl<'a, T, M> From<Option<&'a mut Option<M>>> for OptionLoaned<&'a mut T> | ||
where M: BorrowMut<T> | ||
{ | ||
fn from(result: Option<&'a mut Option<M>>) -> OptionLoaned<&'a mut T> { | ||
match result { | ||
Some(inner) => { | ||
match inner.as_mut() { | ||
Some(inner) => OptionLoaned::Some(inner.borrow_mut()), | ||
None => OptionLoaned::Loaned, | ||
} | ||
} | ||
None => OptionLoaned::None, | ||
} | ||
} | ||
} |
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,4 +1,4 @@ | ||
use Vector; | ||
use math::Vector; | ||
use sdl2::rect::Rect as SdlRect; | ||
|
||
pub struct Rect { | ||
|
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