Drake landing, take two

This commit is contained in:
Jérémy Rosen 2005-12-19 20:43:59 +00:00
parent 190df74692
commit 074f75c9ff
5 changed files with 45 additions and 1 deletions

View file

@ -236,6 +236,28 @@ const T& animated<T,T_void_value>::get_current_frame() const
return cur.value;
}
template<typename T, typename T_void_value>
const T& animated<T,T_void_value>::get_first_frame() const
{
typename std::vector<frame>::const_iterator frame_;
for(frame_ = frames_.begin() ; frame_ != frames_.end(); frame_++ ) {
if(frame_->has_value)
return frame_->value;
}
return void_value_;
}
template<typename T, typename T_void_value>
const T& animated<T,T_void_value>::get_last_frame() const
{
typename std::vector<frame>::const_reverse_iterator frame_;
for(frame_ = frames_.rbegin() ; frame_ != frames_.rend(); frame_++ ) {
if(frame_->has_value)
return frame_->value;
}
return void_value_;
}
template<typename T, typename T_void_value>
int animated<T,T_void_value>::get_first_frame_time() const
{

View file

@ -67,6 +67,8 @@ public:
int get_animation_time() const;
int get_frame_time() const;
const T& get_current_frame() const;
const T& get_first_frame() const;
const T& get_last_frame() const;
private:
struct frame

View file

@ -142,7 +142,7 @@ void move_unit_between(display& disp, const gamemap& map, const gamemap::locatio
const unit_animation* movement_anim = u.type().move_animation(map.underlying_terrain(src_terrain),a.get_relative_dir(b));
if(movement_anim) {
const int total_anim_time = (movement_anim->get_last_frame_time(unit_animation::UNIT_FRAME) - movement_anim->get_first_frame_time(unit_animation::UNIT_FRAME)) * u.movement_cost(map,terrain);
image::locator unit_loc = u.image_loc(); // will always contain the last used frame
image::locator unit_loc = image::locator(movement_anim->get_first_frame().image,u.team_rgb_range(),u.type().flag_rgb());
for(int i = 0 ; i < u.movement_cost(map,terrain) ; i++ ) {
unit_animation movement_animation(*movement_anim);
movement_animation.start_animation(movement_animation.get_first_frame_time(unit_animation::UNIT_FRAME),

View file

@ -122,6 +122,24 @@ const unit_animation::frame& unit_animation::get_current_frame(FRAME_TYPE type)
}
}
const unit_animation::frame& unit_animation::get_first_frame(FRAME_TYPE type) const
{
if(type == UNIT_FRAME) {
return unit_frames_.get_first_frame();
} else {
return missile_frames_.get_first_frame();
}
}
const unit_animation::frame& unit_animation::get_last_frame(FRAME_TYPE type) const
{
if(type == UNIT_FRAME) {
return unit_frames_.get_last_frame();
} else {
return missile_frames_.get_last_frame();
}
}
int unit_animation::get_animation_time() const
{
return unit_frames_.get_animation_time();

View file

@ -51,6 +51,8 @@ public:
void update_current_frames();
bool animation_finished() const;
const frame& get_current_frame(FRAME_TYPE type=UNIT_FRAME) const;
const frame& get_first_frame(FRAME_TYPE type=UNIT_FRAME) const;
const frame& get_last_frame(FRAME_TYPE type=UNIT_FRAME) const;
int get_animation_time() const;
int get_first_frame_time(FRAME_TYPE type=UNIT_FRAME) const;
int get_last_frame_time(FRAME_TYPE type=UNIT_FRAME) const;