updated to latest 'blah' version

This commit is contained in:
Noel Berry 2021-03-20 20:44:04 -07:00
parent 26bc63236d
commit 4740c54465
6 changed files with 21 additions and 26 deletions

@ -1 +1 @@
Subproject commit a72cd5cab60f297926e18fa6d3d1fc125551bb9d
Subproject commit 3f07c03fa51162cee4dbe53abf4a958bb6c35cda

View File

@ -181,10 +181,10 @@ bool TL::Collider::rect_to_grid(const Collider* a, const Collider* b, Point offs
RectI rect = a->m_rect + a->entity()->position + offset - b->entity()->position;
// get the cells the rectangle overlaps
int left = Calc::clamp_int(Calc::floor(rect.x / (float)b->m_grid.tile_size), 0, b->m_grid.columns);
int right = Calc::clamp_int(Calc::ceiling(rect.right() / (float)b->m_grid.tile_size), 0, b->m_grid.columns);
int top = Calc::clamp_int(Calc::floor(rect.y / (float)b->m_grid.tile_size), 0, b->m_grid.rows);
int bottom = Calc::clamp_int(Calc::ceiling(rect.bottom() / (float)b->m_grid.tile_size), 0, b->m_grid.rows);
int left = Calc::clamp((int)Calc::floor(rect.x / (float)b->m_grid.tile_size), 0, b->m_grid.columns);
int right = Calc::clamp((int)Calc::ceiling(rect.right() / (float)b->m_grid.tile_size), 0, b->m_grid.columns);
int top = Calc::clamp((int)Calc::floor(rect.y / (float)b->m_grid.tile_size), 0, b->m_grid.rows);
int bottom = Calc::clamp((int)Calc::ceiling(rect.bottom() / (float)b->m_grid.tile_size), 0, b->m_grid.rows);
// check each cell
for (int x = left; x < right; x++)

View File

@ -24,20 +24,15 @@ namespace
Player::Player()
{
input_move = VirtualStick()
.add_keys(Key::Left, Key::Right, Key::Up, Key::Down)
.add_buttons(0, Button::Left, Button::Right, Button::Up, Button::Down)
.add_axes(0, Axis::LeftX, Axis::LeftY, 0.2f);
input_move.add_dpad(0);
input_move.add_left_stick(0, 0.2f);
input_move.add(Key::Left, Key::Right, Key::Up, Key::Down);
input_jump = VirtualButton()
.press_buffer(0.15f)
.add_key(Key::X)
.add_button(0, Button::A);
input_jump.press_buffer = 0.15f;
input_jump.add(Key::X, Button::A);
input_attack = VirtualButton()
.press_buffer(0.15f)
.add_key(Key::C)
.add_button(0, Button::X);
input_attack.press_buffer = 0.15f;
input_attack.add(Key::C, Button::X);
}
void Player::update()
@ -51,7 +46,7 @@ void Player::update()
auto hitbox = get<Collider>();
auto was_on_ground = m_on_ground;
m_on_ground = mover->on_ground();
int input = input_move.value_i().x;
int input = input_move.sign().x;
// Sprite Stuff
{
@ -121,7 +116,7 @@ void Player::update()
{
if (input_jump.pressed() && mover->on_ground())
{
input_jump.clear_press_buffer();
input_jump.consume_press();
anim->scale = Vec2(m_facing * 0.65f, 1.4f);
mover->speed.x = input * max_air_speed;
m_jump_timer = jump_time;
@ -131,7 +126,7 @@ void Player::update()
// Begin Attack
if (input_attack.pressed())
{
input_attack.clear_press_buffer();
input_attack.consume_press();
m_state = st_attack;
m_attack_timer = 0;

View File

@ -18,9 +18,9 @@ namespace TL
int health = max_health;
VirtualStick input_move;
VirtualButton input_jump;
VirtualButton input_attack;
StickBinding input_move;
Binding input_jump;
Binding input_attack;
Player();
void update() override;

View File

@ -45,7 +45,7 @@ FilePath Content::path()
if (!Directory::exists(root))
BLAH_ERROR("Unable to find content directory!");
Log::print("Content Path: %s", root.cstr());
Log::info("Content Path: %s", root.cstr());
}
return root;

View File

@ -241,8 +241,8 @@ void Game::update()
else
{
player->entity()->position = Point(
Calc::clamp_int(pos.x, bounds.x, bounds.x + bounds.w),
Calc::clamp_int(pos.y, bounds.y, bounds.y + bounds.h + 100));
Calc::clamp(pos.x, bounds.x, bounds.x + bounds.w),
Calc::clamp(pos.y, bounds.y, bounds.y + bounds.h + 100));
// reload if they fell out the bottom
if (player->entity()->position.y > bounds.y + bounds.h + 64)