|
53 | 53 |
|
54 | 54 | const float TUX_INVINCIBLE_TIME_WARNING = 2.0f;
|
55 | 55 |
|
56 |
| -namespace { |
57 |
| - |
| 56 | +namespace |
| 57 | +{ |
58 | 58 | /* Times: */
|
59 | 59 | const float TUX_SAFE_TIME = 1.8f;
|
60 | 60 | const float TUX_INVINCIBLE_TIME = 14.0f;
|
@@ -232,6 +232,8 @@ Player::Player(PlayerStatus& player_status, const std::string& name_, int player
|
232 | 232 | m_water_jump(false),
|
233 | 233 | m_airarrow(Surface::from_file("images/engine/hud/airarrow.png")),
|
234 | 234 | m_bubbles_sprite(SpriteManager::current()->create("images/particles/air_bubble.sprite")),
|
| 235 | + m_should_fancy_idle(true), |
| 236 | + m_fancy_idle_active(true), |
235 | 237 | m_floor_normal(0.0f, 0.0f),
|
236 | 238 | m_ghost_mode(false),
|
237 | 239 | m_unduck_hurt_timer(),
|
@@ -2189,42 +2191,60 @@ Player::draw(DrawingContext& context)
|
2189 | 2191 | }
|
2190 | 2192 | else
|
2191 | 2193 | {
|
2192 |
| - if (fabsf(m_physic.get_velocity_x()) < 1.0f) { |
2193 |
| - if (std::all_of(IDLE_STAGES.begin(), IDLE_STAGES.end(), |
2194 |
| - [this](const std::string& stage) { return m_sprite->get_action().find("-" + stage + "-") == std::string::npos; })) |
| 2194 | + if (fabsf(m_physic.get_velocity_x()) < 1.0f) |
| 2195 | + { |
| 2196 | + const bool is_not_idle = std::all_of(IDLE_STAGES.begin(), IDLE_STAGES.end(), |
| 2197 | + [this](const std::string& stage) { return m_sprite->get_action().find("-" + stage + "-") == std::string::npos; }); |
| 2198 | + |
| 2199 | + if (is_not_idle || (m_should_fancy_idle && !m_fancy_idle_active)) |
2195 | 2200 | {
|
2196 | 2201 | m_idle_stage = 0;
|
2197 | 2202 | m_idle_timer.start(static_cast<float>(TIME_UNTIL_IDLE) / 1000.0f);
|
| 2203 | + m_sprite->set_action(sa_prefix + ("-" + IDLE_STAGES[m_idle_stage]) + sa_postfix, Sprite::LOOPS_CONTINUED); |
2198 | 2204 |
|
2199 |
| - m_sprite->set_action(sa_prefix+("-" + IDLE_STAGES[m_idle_stage])+sa_postfix, Sprite::LOOPS_CONTINUED); |
2200 |
| - } |
2201 |
| - else if (m_idle_timer.check() || m_sprite->animation_done()) { |
2202 |
| - m_idle_stage++; |
2203 |
| - if (m_idle_stage >= static_cast<unsigned int>(IDLE_STAGES.size())) |
| 2205 | + if (!m_should_fancy_idle) |
2204 | 2206 | {
|
2205 |
| - m_idle_stage = static_cast<int>(IDLE_STAGES.size()) - 1; |
2206 |
| - m_sprite->set_action(sa_prefix+("-" + IDLE_STAGES[m_idle_stage])+sa_postfix); |
2207 | 2207 | m_sprite->set_animation_loops(-1);
|
| 2208 | + m_fancy_idle_active = false; |
2208 | 2209 | }
|
2209 | 2210 | else
|
| 2211 | + m_fancy_idle_active = true; |
| 2212 | + } |
| 2213 | + else if (m_should_fancy_idle) |
| 2214 | + { |
| 2215 | + if (m_idle_timer.check() || m_sprite->animation_done()) |
2210 | 2216 | {
|
2211 |
| - m_sprite->set_action(sa_prefix+("-" + IDLE_STAGES[m_idle_stage])+sa_postfix, 1); |
| 2217 | + m_idle_stage++; |
| 2218 | + |
| 2219 | + if (m_idle_stage >= static_cast<unsigned int>(IDLE_STAGES.size())) |
| 2220 | + { |
| 2221 | + m_idle_stage = static_cast<int>(IDLE_STAGES.size()) - 1; |
| 2222 | + m_sprite->set_action(sa_prefix + ("-" + IDLE_STAGES[m_idle_stage]) + sa_postfix); |
| 2223 | + m_sprite->set_animation_loops(-1); |
| 2224 | + } |
| 2225 | + else |
| 2226 | + m_sprite->set_action(sa_prefix + ("-" + IDLE_STAGES[m_idle_stage]) + sa_postfix, 1); |
2212 | 2227 | }
|
2213 | 2228 | }
|
2214 |
| - else { |
2215 |
| - m_sprite->set_action(sa_prefix+("-" + IDLE_STAGES[m_idle_stage])+sa_postfix, Sprite::LOOPS_CONTINUED); |
| 2229 | + else |
| 2230 | + { |
| 2231 | + if (m_idle_stage != 0 || m_sprite->get_action() != sa_prefix + ("-" + IDLE_STAGES[0]) + sa_postfix) |
| 2232 | + { |
| 2233 | + m_idle_stage = 0; |
| 2234 | + m_sprite->set_action(sa_prefix + ("-" + IDLE_STAGES[0]) + sa_postfix); |
| 2235 | + m_sprite->set_animation_loops(-1); |
| 2236 | + } |
| 2237 | + m_fancy_idle_active = false; |
2216 | 2238 | }
|
2217 | 2239 | }
|
2218 | 2240 | else
|
2219 | 2241 | {
|
2220 |
| - if (std::abs(m_physic.get_velocity_x()) >= MAX_RUN_XM-3) |
2221 |
| - { |
2222 |
| - m_sprite->set_action(sa_prefix+"-run"+sa_postfix); |
2223 |
| - } |
| 2242 | + if (std::abs(m_physic.get_velocity_x()) >= MAX_RUN_XM - 3) |
| 2243 | + m_sprite->set_action(sa_prefix + "-run" + sa_postfix); |
2224 | 2244 | else
|
2225 |
| - { |
2226 |
| - m_sprite->set_action(sa_prefix+"-walk"+sa_postfix); |
2227 |
| - } |
| 2245 | + m_sprite->set_action(sa_prefix + "-walk" + sa_postfix); |
| 2246 | + |
| 2247 | + m_fancy_idle_active = false; |
2228 | 2248 | }
|
2229 | 2249 | }
|
2230 | 2250 |
|
@@ -3082,6 +3102,8 @@ Player::register_class(ssq::VM& vm)
|
3082 | 3102 | cls.addFunc("make_invincible", &Player::make_invincible);
|
3083 | 3103 | cls.addFunc("deactivate", &Player::deactivate);
|
3084 | 3104 | cls.addFunc("activate", &Player::activate);
|
| 3105 | + cls.addFunc("enable_fancy_idling", &Player::enable_fancy_idling); |
| 3106 | + cls.addFunc("disable_fancy_idling", &Player::disable_fancy_idling); |
3085 | 3107 | cls.addFunc("walk", &Player::walk);
|
3086 | 3108 | cls.addFunc("set_dir", &Player::set_dir);
|
3087 | 3109 | cls.addFunc("set_visible", &Player::set_visible);
|
|
0 commit comments