fn collide(&mut self) {
        let available_x = self.background.0 as f64 - self.size.0;
        let available_y = self.background.1 as f64 - self.size.1;
        let before_theta = self.arrow.theta;
        let plane_vec = match (between(0.0, available_x, self.current_state.0),
                               between(0.0, available_y, self.current_state.1)) {
            (false, true) => 1.0,
            (true, false) => 2.0,
            (false, false) => 2.0 * before_theta,
            (true, true) => {
                panic!("system error");
            }
        };
        let mut result = plane_vec - before_theta;
        // set theta range in 0.0~2.0
        loop {
            if result < 0.0 {
                result += 2.0;
                continue;
            } else if result > 2.0 {
                result -= 2.0;
                continue;
            } else {
                break;
            }
        }
        self.arrow = Arrow::new(result);
    }
// set the new direction according to current position
set the new direction according to current position
set the new direction according to current position
fn collide(&mut self) {
        let available_x = self.background.0 as f64 - self.size.0;
        let available_y = self.background.1 as f64 - self.size.1;
        let before_theta = self.arrow.theta;
        let plane_vec = match (between(0.0, available_x, self.current_state.0),
                               between(0.0, available_y, self.current_state.1)) {
            (false, true) => 1.0,
            (true, false) => 2.0,
            (false, false) => 2.0 * before_theta,
            (true, true) => {
                panic!("system error");
            }
        };
        let mut result = plane_vec - before_theta;
        // set theta range in 0.0~2.0
        loop {
            if result < 0.0 {
                result += 2.0;
                continue;
            } else if result > 2.0 {
                result -= 2.0;
                continue;
            } else {
                break;
            }
        }
        self.arrow = Arrow::new(result);
    }
fn collide ( & mut self ) { let available_x = self . background . 0 as f64 - self . size . 0 ; let available_y = self . background . 1 as f64 - self . size . 1 ; let before_theta = self . arrow . theta ; let plane_vec = match ( between ( 0.0 , available_x , self . current_state . 0 ) , between ( 0.0 , available_y , self . current_state . 1 ) ) { ( false , true ) => 1.0 , ( true , false ) => 2.0 , ( false , false ) => 2.0 * before_theta , ( true , true ) => { panic ! ( " " ) ; } } ; let mut result = plane_vec - before_theta ; // set theta range in 0.0~2.0 loop { if result < 0.0 { result += 2.0 ; continue ; } else if result > 2.0 { result -= 2.0 ; continue ; } else { break ; } } self . arrow = Arrow :: new ( result ) ; }
set the new direction according to current position
set the new direction according to current position
&mut self
&mut self