Skip to content

More enemy and powerup types. #52

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Jun 26, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Nerf responsiveness when holding fire.
  • Loading branch information
karnkaul committed Jun 26, 2024
commit edfe77e22c4554f72a5cf3480a55b49db81dd37d
3 changes: 3 additions & 0 deletions src/spaced/spaced/game/controllers/follow_controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ auto FollowController::tick(Seconds const dt) -> float {
auto const y = tick_y(dt);

m_spring_arm.target = glm::vec2{0.0f, y};
m_spring_arm.k = is_firing() ? m_spring_k.hi : m_spring_k.lo;
m_spring_arm.tick(dt);

return m_spring_arm.position.y;
Expand All @@ -16,6 +17,8 @@ auto FollowController::tick(Seconds const dt) -> float {
void FollowController::do_inspect() {
if constexpr (bave::imgui_v) {
if (ImGui::TreeNode("spring arm")) {
ImGui::DragFloat("k.lo", &m_spring_k.lo, 1.0f, 1.0f, 1000.0f);
ImGui::DragFloat("k.hi", &m_spring_k.hi, 1.0f, 1.0f, 1000.0f);
ImGui::DragFloat("k", &m_spring_arm.k, 1.0f, 1.0f, 1000.0f);
ImGui::DragFloat("damp", &m_spring_arm.damp, 0.01f, 0.01f, 0.99f);
ImGui::DragFloat("min distance", &m_spring_arm.min_distance, 0.01f, 0.01f, 1000.0f);
Expand Down
2 changes: 2 additions & 0 deletions src/spaced/spaced/game/controllers/follow_controller.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#pragma once
#include <bave/core/inclusive_range.hpp>
#include <spaced/game/controller.hpp>
#include <spaced/game/spring_arm.hpp>

Expand All @@ -12,5 +13,6 @@ class FollowController : public IController {
void do_inspect() override;

SpringArm m_spring_arm{};
bave::InclusiveRange<float> m_spring_k{200.0f, 40.0f};
};
} // namespace spaced
9 changes: 6 additions & 3 deletions src/spaced/spaced/game/controllers/player_controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,12 @@ using bave::PointerTap;
using bave::Seconds;
using bave::Services;

PlayerController::PlayerController(Services const& services) : m_layout(&services.get<Layout>()), m_gamepad_provider(&services.get<IGamepadProvider>()) {
max_y = 0.5f * m_layout->world_space.y;
min_y = -max_y; // NOLINT(cppcoreguidelines-prefer-member-initializer)
PlayerController::PlayerController(Services const& services, Type const type)
: m_layout(&services.get<Layout>()), m_gamepad_provider(&services.get<IGamepadProvider>()), m_type(type) {
auto const half_size = 0.5f * m_layout->player_size;
auto const play_area = m_layout->play_area;
max_y = play_area.lt.y - half_size.y;
min_y = play_area.rb.y + half_size.y;
}

void PlayerController::on_move(PointerMove const& pointer_move) {
Expand Down
2 changes: 1 addition & 1 deletion src/spaced/spaced/game/controllers/player_controller.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class PlayerController : public FollowController {

[[nodiscard]] auto get_type_name() const -> std::string_view final { return type_name_v; };

explicit PlayerController(bave::Services const& services);
explicit PlayerController(bave::Services const& services, Type type);

void on_move(bave::PointerMove const& pointer_move) final;
void on_tap(bave::PointerTap const& pointer_tap) final;
Expand Down
12 changes: 4 additions & 8 deletions src/spaced/spaced/scenes/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ using bave::im_text;
using bave::Key;
using bave::KeyInput;
using bave::KeyMods;
using bave::Platform;
using bave::PointerMove;
using bave::PointerTap;
using bave::Ptr;
Expand All @@ -35,14 +36,9 @@ namespace ui = bave::ui;

namespace {
[[nodiscard]] auto make_player_controller(Services const& services) {
auto ret = std::make_unique<PlayerController>(services);
if constexpr (bave::platform_v == bave::Platform::eAndroid) { ret->set_type(PlayerController::Type::eTouch); }
auto const& layout = services.get<Layout>();
auto const half_size = 0.5f * layout.player_size;
auto const play_area = layout.play_area;
ret->max_y = play_area.lt.y - half_size.y;
ret->min_y = play_area.rb.y + half_size.y;
return ret;
using enum PlayerController::Type;
static constexpr auto type_v = bave::platform_v == Platform::eAndroid ? eTouch : eMouse;
return std::make_unique<PlayerController>(services, type_v);
}

[[nodiscard]] auto make_auto_controller(ITargetProvider const& target_provider, Services const& services) {
Expand Down