Struct gemini_engine::elements::view::Vec2D
source · pub struct Vec2D {
pub x: isize,
pub y: isize,
}Expand description
A pair of isize used for coordinates, size or direction on a 2D plane
Fields§
§x: isize§y: isizeImplementations§
source§impl Vec2D
impl Vec2D
sourcepub const fn new(x: isize, y: isize) -> Self
pub const fn new(x: isize, y: isize) -> Self
Examples found in repository?
examples/multi-movement.rs (line 15)
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
const BLOCK_SIZE: Vec2D = Vec2D::new(4, 2);
const FILL_CHAR: ColChar = ColChar::SOLID;
fn main() {
let mut view = View::new(50, 12, ColChar::BACKGROUND);
let mut blocks = vec![
Rect::new(Vec2D::new(0, 0), BLOCK_SIZE, FILL_CHAR),
Rect::new(Vec2D::new(0, 2), BLOCK_SIZE, FILL_CHAR),
Rect::new(Vec2D::new(0, 4), BLOCK_SIZE, FILL_CHAR),
Rect::new(Vec2D::new(0, 6), BLOCK_SIZE, FILL_CHAR),
Rect::new(Vec2D::new(0, 8), BLOCK_SIZE, FILL_CHAR),
Rect::new(Vec2D::new(0, 10), BLOCK_SIZE, FILL_CHAR),
];
let mut i = 0;
fps_gameloop!(
{
i += 1;
for j in 0..blocks.len() {
if i % 2_u32.pow(j as u32) == 0 {
blocks[j].pos.x += 1;
}
}
},
{
view.clear();
for block in &blocks {
view.blit(block, Wrapping::Wrap);
}
view.display_render().unwrap();
if blocks.iter().all(|b| b.pos.x % view.width as isize == 0) {
thread::sleep(Duration::from_secs(2));
};
},
200.0
);
}pub fn as_tuple(&self) -> (isize, isize)
Trait Implementations§
source§impl AddAssign<Vec2D> for Vec2D
impl AddAssign<Vec2D> for Vec2D
source§fn add_assign(&mut self, rhs: Self)
fn add_assign(&mut self, rhs: Self)
Performs the
+= operation. Read moresource§impl DivAssign<isize> for Vec2D
impl DivAssign<isize> for Vec2D
source§fn div_assign(&mut self, rhs: isize)
fn div_assign(&mut self, rhs: isize)
Performs the
/= operation. Read moresource§impl PartialEq<Vec2D> for Vec2D
impl PartialEq<Vec2D> for Vec2D
source§impl RemAssign<Vec2D> for Vec2D
impl RemAssign<Vec2D> for Vec2D
source§fn rem_assign(&mut self, rhs: Self)
fn rem_assign(&mut self, rhs: Self)
Performs the
%= operation. Read moresource§impl SubAssign<Vec2D> for Vec2D
impl SubAssign<Vec2D> for Vec2D
source§fn sub_assign(&mut self, rhs: Self)
fn sub_assign(&mut self, rhs: Self)
Performs the
-= operation. Read moreimpl Copy for Vec2D
impl Eq for Vec2D
impl StructuralEq for Vec2D
impl StructuralPartialEq for Vec2D
Auto Trait Implementations§
impl RefUnwindSafe for Vec2D
impl Send for Vec2D
impl Sync for Vec2D
impl Unpin for Vec2D
impl UnwindSafe for Vec2D
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more