Trait chipmunk_rs::ChipmunkRsTypes [] [src]

pub trait ChipmunkRsTypes {
    type Vect;
    fn to_vect(cp_vect: CPVect) -> Self::Vect;
    fn to_cp_vect(vect: &Self::Vect) -> CPVect;
}

Implement this trait to define what types you intend to use with this library.

Examples

To use a tuple (x, y) as the 2D vector type simple do:

use chipmunk_rs::{ ChipmunkRsTypes };
use chipmunk_rs::ffi::{ CPVect };

enum TupleTypes {}
impl ChipmunkRsTypes for TupleTypes {
    type Vect = (f64, f64);
    fn to_vect(cp_vect: CPVect) -> Self::Vect {
        (cp_vect.x, cp_vect.y)
    }

    fn to_cp_vect(vect: &Self::Vect) -> CPVect {
        CPVect::new(vect.0, vect.1)
    }
}

Associated Types

The 2D vector type.

Required Methods

Convert a CPVect to the Vect type.

Convert a Vect to the CPVect type.

Implementors