From 4740c54465f8c36a7ef84882abc9cdad3cdc4a39 Mon Sep 17 00:00:00 2001 From: Noel Berry Date: Sat, 20 Mar 2021 20:44:04 -0700 Subject: [PATCH] updated to latest 'blah' version --- libs/blah | 2 +- src/components/collider.cpp | 8 ++++---- src/components/player.cpp | 25 ++++++++++--------------- src/components/player.h | 6 +++--- src/content.cpp | 2 +- src/game.cpp | 4 ++-- 6 files changed, 21 insertions(+), 26 deletions(-) diff --git a/libs/blah b/libs/blah index a72cd5c..3f07c03 160000 --- a/libs/blah +++ b/libs/blah @@ -1 +1 @@ -Subproject commit a72cd5cab60f297926e18fa6d3d1fc125551bb9d +Subproject commit 3f07c03fa51162cee4dbe53abf4a958bb6c35cda diff --git a/src/components/collider.cpp b/src/components/collider.cpp index d4693bb..92fc1b2 100644 --- a/src/components/collider.cpp +++ b/src/components/collider.cpp @@ -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++) diff --git a/src/components/player.cpp b/src/components/player.cpp index a70546c..9d04590 100644 --- a/src/components/player.cpp +++ b/src/components/player.cpp @@ -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(); 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; diff --git a/src/components/player.h b/src/components/player.h index e47da5c..6d93618 100644 --- a/src/components/player.h +++ b/src/components/player.h @@ -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; diff --git a/src/content.cpp b/src/content.cpp index 08ec442..ccdd806 100644 --- a/src/content.cpp +++ b/src/content.cpp @@ -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; diff --git a/src/game.cpp b/src/game.cpp index aed9679..6041acd 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -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)