attack / hurt / bramble!!

This commit is contained in:
Noel Berry
2021-01-03 15:11:49 -08:00
parent fb9cebd8ff
commit fa949e1298
19 changed files with 256 additions and 8 deletions

View File

@ -11,7 +11,7 @@ using namespace TL;
namespace
{
constexpr float transition_duration = 0.75f;
constexpr float transition_duration = 0.4f;
}
void Game::startup()
@ -91,6 +91,11 @@ void Game::load_room(Point cell)
if (!world.first<Player>())
Factory::player(&world, world_position + Point(tile_width / 2, tile_height));
break;
// brambles
case 0xd77bba:
Factory::bramble(&world, world_position + Point(tile_width / 2, tile_height));
break;
}
}
}
@ -134,6 +139,8 @@ void Game::update()
// see if room exists
if (Content::find_room(next_room))
{
Time::pause_for(0.1f);
// transiton to it!
m_transition = true;
m_next_ease = 0;
@ -165,12 +172,17 @@ void Game::update()
// Room Transition routine
else
{
// increment ease
m_next_ease = Calc::approach(m_next_ease, 1.0f, Time::delta / transition_duration);
// get last & next camera position
auto last_cam = Vec2(m_last_room.x * width, m_last_room.y * height);
auto next_cam = Vec2(m_next_room.x * width, m_next_room.y * height);
m_next_ease = Calc::approach(m_next_ease, 1.0f, Time::delta / transition_duration);
// LERP camera position
camera = last_cam + (next_cam - last_cam) * Ease::cube_in_out(m_next_ease);
// Finish Transition
if (m_next_ease >= 1.0f)
{
// delete old objects (except player!)
@ -180,6 +192,7 @@ void Game::update()
world.destroy_entity(it);
}
Time::pause_for(0.1f);
m_transition = false;
}
}