4
Copyright (C) 2005-2010 Julien Jorge, Sebastien Angibaud
6
This program is free software; you can redistribute it and/or modify it
7
under the terms of the GNU General Public License as published by the
8
Free Software Foundation; either version 2 of the License, or (at your
9
option) any later version.
11
This program is distributed in the hope that it will be useful, but WITHOUT
12
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
16
You should have received a copy of the GNU General Public License along
17
with this program; if not, write to the Free Software Foundation, Inc.,
18
51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20
contact: plee-the-bear@gamned.org
22
Please add the tag [PTB] in the subject of your mails.
26
* \brief Implementation of the ptb::hazelnut class.
27
* \author Sebastien Angibaud
29
#include "ptb/item/hazelnut.hpp"
31
#include "ptb/player.hpp"
32
#include "ptb/level_variables.hpp"
34
BASE_ITEM_EXPORT( hazelnut, ptb )
36
/*----------------------------------------------------------------------------*/
40
ptb::hazelnut::hazelnut()
42
set_can_move_items(false);
47
} // hazelnut::hazelnut()
49
/*----------------------------------------------------------------------------*/
51
* \brief Load the media required by this class.
53
void ptb::hazelnut::pre_cache()
57
get_level_globals().load_animation("animation/owl/hazelnut.canim");
58
} // hazelnut::pre_cache()
60
/*----------------------------------------------------------------------------*/
62
* \brief Initialize the item.
64
void ptb::hazelnut::build()
69
( get_level_globals().get_animation("animation/owl/hazelnut.canim") );
71
set_size( get_animation().get_size() );
72
} // hazelnut::build()
74
/*---------------------------------------------------------------------------*/
76
* \brief Do one iteration in the progression of the item.
77
* \param elapsed_time Elapsed time since the last call.
79
void ptb::hazelnut::progress( bear::universe::time_type elapsed_time )
81
super::progress(elapsed_time);
83
if ( has_bottom_contact() )
84
add_internal_force( bear::universe::force_type(0, 200000) );
85
} // hazelnut::progress()
87
/*----------------------------------------------------------------------------*/
89
* \brief Check if the collision is with a player.
90
* \param that The other item of the collision.
91
* \param info Some informations about the collision.
93
void ptb::hazelnut::collision_check_and_apply
94
( bear::engine::base_item& that, bear::universe::collision_info& info )
96
player* p = dynamic_cast<player*>(&that);
100
if ( !level_variables::get_hazelnut(get_level()) )
102
if ( info.get_collision_side() != bear::universe::zone::middle_zone)
104
level_variables::set_hazelnut(get_level(), true);
108
default_collision(info);
111
default_collision(info);
114
default_collision(info);
115
} // hazelnut::collision_check_and_apply()
117
/*----------------------------------------------------------------------------*/
119
* \brief Call collision_check_and_apply().
120
* \param that The other item of the collision.
121
* \param info Some informations about the collision.
123
void ptb::hazelnut::collision
124
( bear::engine::base_item& that, bear::universe::collision_info& info )
126
collision_check_and_apply(that, info);
127
} // hazelnut::collision()