feat:修正上一版bug,timer类回调函数超时设置错误!敌人生成
This commit is contained in:
parent
da08160625
commit
0c0e27ff32
@ -61,7 +61,7 @@ public:
|
||||
rect_src.y = (idx / num_x) * height_frame;
|
||||
rect_src.w = width_frame;
|
||||
rect_src.h = height_frame;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
void set_loop(bool is_loop)
|
||||
@ -89,8 +89,8 @@ public:
|
||||
{
|
||||
static SDL_Rect rect_dst;
|
||||
|
||||
rect_dst.x = pos_dst.x; rect_dst.y = pos_dst.y;
|
||||
rect_dst.w = width_frame; rect_dst.h = height_frame;
|
||||
rect_dst.x = pos_dst.x, rect_dst.y = pos_dst.y;
|
||||
rect_dst.w = width_frame, rect_dst.h = height_frame;
|
||||
|
||||
//渲染器,纹理,裁剪矩形,目标矩形,角度,旋转中心点(默认1/2),翻转。 纹理绘制
|
||||
SDL_RenderCopyEx(renderer, texture, &rect_src_list[idx_frame], &rect_dst, angle, nullptr, SDL_RendererFlip::SDL_FLIP_NONE);
|
||||
|
@ -23,7 +23,7 @@ public:
|
||||
|
||||
//闪白计时器
|
||||
timer_sketch.set_one_shot(true);
|
||||
timer_sketch.set_wait_time(0.001);
|
||||
timer_sketch.set_wait_time(0.075);
|
||||
timer_sketch.set_on_timeout([&]() {is_show_sketch = false; });
|
||||
|
||||
//速度恢复计时器
|
||||
@ -57,7 +57,7 @@ public:
|
||||
velocity.y = direction.y * speed * SIZE_TILE;
|
||||
|
||||
//是否展示水平动画
|
||||
bool is_show_x_anim = (velocity.x) >= abs(velocity.y);
|
||||
bool is_show_x_anim = abs(velocity.x) >= abs(velocity.y);
|
||||
|
||||
//1.是否展示剪影 2.展示动画左右
|
||||
if (is_show_sketch)
|
||||
@ -85,7 +85,7 @@ public:
|
||||
static SDL_Rect rect;
|
||||
static SDL_Point point;
|
||||
static const int offset_y = 2;
|
||||
static Vector2 size_hp_bar = { 40,8 };
|
||||
static const Vector2 size_hp_bar = { 40,8 };
|
||||
//血条外边框颜色
|
||||
static const SDL_Color color_border = { 116,185,124,255 };
|
||||
//血条内容物颜色
|
||||
@ -130,7 +130,7 @@ public:
|
||||
void decrease_hp(double val)
|
||||
{
|
||||
hp -= val;
|
||||
if (hp < 0)
|
||||
if (hp <= 0)
|
||||
{
|
||||
hp = 0;
|
||||
is_valid = false;
|
||||
@ -287,8 +287,8 @@ private:
|
||||
const SDL_Point& point = idx_list[idx_target];
|
||||
static const SDL_Rect& rect_tile_map = ConfigManager::instance()->rect_tile_map;
|
||||
|
||||
position.x = rect_tile_map.x + point.x * SIZE_TILE + SIZE_TILE / 2;
|
||||
position.y = rect_tile_map.y + point.y * SIZE_TILE + SIZE_TILE / 2;
|
||||
position_target.x = rect_tile_map.x + point.x * SIZE_TILE + SIZE_TILE / 2;
|
||||
position_target.y = rect_tile_map.y + point.y * SIZE_TILE + SIZE_TILE / 2;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -92,15 +92,15 @@ public:
|
||||
(
|
||||
[&](Enemy* enemy_src)
|
||||
{
|
||||
double revocer_radius = enemy_src->get_recover_radius();
|
||||
if (revocer_radius < 0) return;
|
||||
double recover_radius = enemy_src->get_recover_radius();
|
||||
if (recover_radius < 0) return;
|
||||
|
||||
const Vector2 pos_src = enemy_src->get_position();
|
||||
for (Enemy* enemy_dst : enemy_list)
|
||||
{
|
||||
const Vector2& pos_dst = enemy_dst->get_position();
|
||||
double distance = (pos_dst - pos_src).length();
|
||||
if (distance <= revocer_radius)
|
||||
if (distance <= recover_radius)
|
||||
enemy_dst->increase_hp(enemy_src->get_recover_intensity());
|
||||
}
|
||||
}
|
||||
|
@ -26,13 +26,13 @@ public:
|
||||
static const std::vector<int> idx_list_right = { 10, 11, 12, 13, 14 };
|
||||
|
||||
anim_up.set_loop(true); anim_up.set_interval(0.15);
|
||||
anim_up.set_frame_data(tex_skeleton, 6, 4, idx_list_up);
|
||||
anim_up.set_frame_data(tex_skeleton, 5, 4, idx_list_up);
|
||||
anim_down.set_loop(true); anim_down.set_interval(0.15);
|
||||
anim_down.set_frame_data(tex_skeleton, 6, 4, idx_list_down);
|
||||
anim_down.set_frame_data(tex_skeleton, 5, 4, idx_list_down);
|
||||
anim_left.set_loop(true); anim_left.set_interval(0.15);
|
||||
anim_left.set_frame_data(tex_skeleton, 6, 4, idx_list_left);
|
||||
anim_left.set_frame_data(tex_skeleton, 5, 4, idx_list_left);
|
||||
anim_right.set_loop(true); anim_right.set_interval(0.15);
|
||||
anim_right.set_frame_data(tex_skeleton, 6, 4, idx_list_right);
|
||||
anim_right.set_frame_data(tex_skeleton, 5, 4, idx_list_right);
|
||||
|
||||
anim_up_sketch.set_loop(true); anim_up_sketch.set_interval(0.15);
|
||||
anim_up_sketch.set_frame_data(tex_skeleton_sketch, 5, 4, idx_list_up);
|
||||
|
@ -53,7 +53,7 @@ public:
|
||||
shotted = true;
|
||||
//如果能触发,且超时函数已经设置
|
||||
if (can_shot && on_timeout)
|
||||
on_timeout;
|
||||
on_timeout();
|
||||
|
||||
pass_time -= wait_time;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user