it's done!!!

This commit is contained in:
Noel Berry
2021-01-03 21:54:18 -08:00
parent f721b86bb9
commit fc57d2e47c
7 changed files with 51 additions and 10 deletions

View File

@ -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();
}
}

View File

@ -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;

View File

@ -17,6 +17,7 @@ namespace TL
uint32_t hurt_by = 0;
std::function<void(Hurtable* self)> on_hurt;
void hurt();
void update() override;
};
}

View File

@ -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;