mirror of
https://github.com/NoelFB/tiny_link.git
synced 2025-07-01 19:45:27 +08:00
it's done!!!
This commit is contained in:
@ -6,6 +6,7 @@
|
||||
#include "orb.h"
|
||||
#include "../masks.h"
|
||||
#include "../factory.h"
|
||||
#include "../game.h"
|
||||
|
||||
using namespace TL;
|
||||
|
||||
@ -183,8 +184,13 @@ void GhostFrog::update()
|
||||
{
|
||||
if (Vec2(orb->entity()->position - orb->target()).length() < 16)
|
||||
{
|
||||
auto sign = Calc::sign(orb->entity()->position.x - x);
|
||||
if (sign != 0)
|
||||
m_facing = sign;
|
||||
|
||||
anim->play("reflect");
|
||||
orb->on_hit();
|
||||
|
||||
m_reflect_count++;
|
||||
m_timer = 0;
|
||||
}
|
||||
@ -195,7 +201,7 @@ void GhostFrog::update()
|
||||
{
|
||||
Factory::pop(world(), entity()->position + Point(0, -8));
|
||||
orb->entity()->destroy();
|
||||
on_hurt(nullptr);
|
||||
get<Hurtable>()->hurt();
|
||||
m_timer = 0;
|
||||
}
|
||||
}
|
||||
@ -205,6 +211,7 @@ void GhostFrog::update()
|
||||
else if (m_state == st_dead_state)
|
||||
{
|
||||
anim->play("dead");
|
||||
world()->game->shake(1.0f);
|
||||
|
||||
if (Time::on_interval(0.25f))
|
||||
{
|
||||
@ -219,6 +226,7 @@ void GhostFrog::update()
|
||||
Factory::pop(world(), entity()->position + Point(x * 12, -8 + y * 12));
|
||||
|
||||
Time::pause_for(0.3f);
|
||||
world()->game->shake(0.1f);
|
||||
entity()->destroy();
|
||||
}
|
||||
}
|
||||
|
@ -3,17 +3,20 @@
|
||||
|
||||
using namespace TL;
|
||||
|
||||
void Hurtable::hurt()
|
||||
{
|
||||
Time::pause_for(0.1f);
|
||||
stun_timer = 0.5f;
|
||||
flicker_timer = 0.5f;
|
||||
on_hurt(this);
|
||||
}
|
||||
|
||||
void Hurtable::update()
|
||||
{
|
||||
if (collider && on_hurt && stun_timer <= 0)
|
||||
{
|
||||
if (collider->check(hurt_by))
|
||||
{
|
||||
Time::pause_for(0.1f);
|
||||
stun_timer = 0.5f;
|
||||
flicker_timer = 0.5f;
|
||||
on_hurt(this);
|
||||
}
|
||||
hurt();
|
||||
}
|
||||
|
||||
stun_timer -= Time::delta;
|
||||
|
@ -17,6 +17,7 @@ namespace TL
|
||||
uint32_t hurt_by = 0;
|
||||
std::function<void(Hurtable* self)> on_hurt;
|
||||
|
||||
void hurt();
|
||||
void update() override;
|
||||
};
|
||||
}
|
@ -14,7 +14,7 @@ namespace TL
|
||||
static constexpr int st_attack = 1;
|
||||
static constexpr int st_hurt = 2;
|
||||
static constexpr int st_start = 3;
|
||||
static constexpr int max_health = 30;
|
||||
static constexpr int max_health = 4;
|
||||
|
||||
int health = max_health;
|
||||
|
||||
|
Reference in New Issue
Block a user