Skip to content
This repository has been archived by the owner on Jan 2, 2021. It is now read-only.

Commit

Permalink
Feat/camera player movement (#75)
Browse files Browse the repository at this point in the history
* feat: Add attacks on controller

* feat: update camera

* fix: fix compilation

* fix: update camera viewport

* fix: controller attack buttons
  • Loading branch information
BenjaminPraud authored Nov 11, 2020
1 parent 100a900 commit 695a5fb
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/Application/src/GameLogic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ auto game::GameLogic::on_game_started(entt::registry &world) -> void

// default camera value to see the generated terrain properly
m_game.getCamera().setCenter(glm::vec2(13, 22));
m_game.getCamera().setViewportSize(glm::vec2(109, 64));
m_game.getCamera().setViewportSize(glm::vec2(25, 17));

onFloorChange.publish(world);
}
Expand Down
27 changes: 24 additions & 3 deletions src/Application/src/ThePURGE.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,34 @@ auto game::ThePurge::onUpdate(entt::registry &world, const engine::Event &e) ->
[&](const engine::TimeElapsed &dt) { m_logics->gameUpdated.publish(world, dt); },
[&](const engine::Moved<engine::JoystickAxis> &joy) {
auto joystick = holder.instance->getJoystick(joy.source.id);
m_logics->movement.publish(
world, player, {((*joystick)->axes[0] / 10.0f), -((*joystick)->axes[1] / 10.0f)});
m_logics->movement.publish(world, player, {((*joystick)->axes[0] / 10.0f), -((*joystick)->axes[1] / 10.0f)});
},
[&](const engine::Pressed<engine::JoystickButton> &joy) {
switch (joy.source.button) {
case engine::Joystick::ACTION_RIGHT: {
auto &spell = world.get<SpellSlots>(player).spells[0];
if (!spell.has_value()) break;

auto &vel = world.get<engine::d2::Velocity>(player);
m_logics->castSpell.publish(world, player, {vel.x, vel.y}, spell.value());
break;
}
case engine::Joystick::ACTION_BOTTOM: {
auto &spell = world.get<SpellSlots>(player).spells[1];
if (!spell.has_value()) break;

auto &vel = world.get<engine::d2::Velocity>(player);
m_logics->castSpell.publish(world, player, {vel.x, vel.y}, spell.value());
break;
}
default: return;
}
},
[&](auto) {},
},
e);

auto &pos = world.get<engine::d3::Position>(player);
m_camera.setCenter({pos.x, pos.y});
if (m_camera.isUpdated()) { holder.instance->updateView(m_camera.getViewProjMatrix()); }
}
}
Expand Down

0 comments on commit 695a5fb

Please sign in to comment.