pub fn collect(&mut self, player: &mut Player<'a>) {
        // Resets time if 1 seconde is over (for Rendering)
        if self.dt.to(PreciseTime::now()).num_milliseconds() > 1000 {
            self.dt = PreciseTime::now();
        }
        // Is Player at same position as Item?
        if player.coord.get_x() == self.coord.get_x() &&
           player.coord.get_y() == self.coord.get_y() && !self.get_gone() {
            if let Some(ref item) = self.item_type {
                match *item {
                    // Change Weapon
                    ItemType::Weapon(weapon) => player.weapon = weapon,
                    // Heal
                    ItemType::Heal(heal) => player.damage_taken(heal as i32 * -1),
                }
            }
            // Set to gone. Gone Items will be deletet
            self.gone();
        }
    }
/// collects an Item if Player is on same field.
collects an Item if Player is on same field.
collects an Item if Player is on same field .
pub fn collect(&mut self, player: &mut Player<'a>) {
        // Resets time if 1 seconde is over (for Rendering)
        if self.dt.to(PreciseTime::now()).num_milliseconds() > 1000 {
            self.dt = PreciseTime::now();
        }
        // Is Player at same position as Item?
        if player.coord.get_x() == self.coord.get_x() &&
           player.coord.get_y() == self.coord.get_y() && !self.get_gone() {
            if let Some(ref item) = self.item_type {
                match *item {
                    // Change Weapon
                    ItemType::Weapon(weapon) => player.weapon = weapon,
                    // Heal
                    ItemType::Heal(heal) => player.damage_taken(heal as i32 * -1),
                }
            }
            // Set to gone. Gone Items will be deletet
            self.gone();
        }
    }
pub fn collect ( & mut self , player : & mut Player < ' a > ) { // Resets time if 1 seconde is over (for Rendering) if self . dt . to ( PreciseTime :: now ( ) ) . num_milliseconds ( ) > 1000 { self . dt = PreciseTime :: now ( ) ; } // Is Player at same position as Item? if player . coord . get_x ( ) == self . coord . get_x ( ) && player . coord . get_y ( ) == self . coord . get_y ( ) && ! self . get_gone ( ) { if let Some ( ref item ) = self . item_type { match * item { // Change Weapon ItemType :: Weapon ( weapon ) => player . weapon = weapon , // Heal ItemType :: Heal ( heal ) => player . damage_taken ( heal as i32 * - 1 ) , } } // Set to gone. Gone Items will be deletet self . gone ( ) ; } }
collects an Item if Player is on same field.
collects an Item if Player is on same field .
&mut self
player
&mut Player<'a>
&mut self
player
&mut Player<'a>