Dolda2000 GitWeb
/
kaka
/
rust-sdl-test.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Added a basic gamestate with a controlled mario
[kaka/rust-sdl-test.git]
/
src
/
common.rs
diff --git
a/src/common.rs
b/src/common.rs
index
442b11c
..
52b7324
100644
(file)
--- a/
src/common.rs
+++ b/
src/common.rs
@@
-1,5
+1,7
@@
use std::ops::{Add, AddAssign, Mul};
use std::ops::{Add, AddAssign, Mul};
+pub type Nanoseconds = u64;
+
#[macro_export]
macro_rules! point {
( $x:expr, $y:expr ) => {
#[macro_export]
macro_rules! point {
( $x:expr, $y:expr ) => {
@@
-7,7
+9,7
@@
macro_rules! point {
};
}
};
}
-#[derive(Debug, Copy, Clone, PartialEq)]
+#[derive(Debug,
Default,
Copy, Clone, PartialEq)]
pub struct Point2D<T> {
pub x: T,
pub y: T,
pub struct Point2D<T> {
pub x: T,
pub y: T,
@@
-37,6
+39,15
@@
impl<T: AddAssign> AddAssign for Point2D<T> {
}
}
}
}
+impl<T> From<(T, T)> for Point2D<T> {
+ fn from(item: (T, T)) -> Self {
+ Point2D {
+ x: item.0,
+ y: item.1,
+ }
+ }
+}
+
#[macro_export]
macro_rules! rect {
( $x:expr, $y:expr ) => {
#[macro_export]
macro_rules! rect {
( $x:expr, $y:expr ) => {