Skip to content

Commit

Permalink
fix ball scale on minimap
Browse files Browse the repository at this point in the history
add animated flag to minimap
  • Loading branch information
fallahn committed Sep 14, 2024
1 parent c35431e commit 583529f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions samples/golf/src/golf/GolfStateUI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1768,13 +1768,14 @@ void GolfState::buildUI()
entity.getComponent<cro::Transform>().setOrigin({ 0.5f, -0.5f });
entity.addComponent<cro::Drawable2D>().setFacing(cro::Drawable2D::Facing::Back);
entity.addComponent<cro::CommandTarget>().ID = CommandID::UI::MiniFlag;
entity.addComponent<cro::Sprite>() = m_sprites[SpriteID::MapFlag];
entity.addComponent<cro::Sprite>() = m_sprites[SpriteID::MiniFlag/*MapFlag*/];
entity.addComponent<cro::SpriteAnimation>().play(0);
entity.addComponent<cro::Callback>().active = true;
entity.getComponent<cro::Callback>().function =
[&, mapEnt](cro::Entity e, float dt)
{
e.getComponent<cro::Transform>().setPosition(glm::vec3(m_minimapZoom.toMapCoords(m_holeData[m_currentHole].pin), 0.02f));
e.getComponent<cro::Transform>().setScale(((m_minimapZoom.mapScale * 2.f * (1.f + ((m_minimapZoom.zoom - 1.f) * 0.125f))) * 0.75f) * (glm::vec2(1.f) / MapSizeRatio));
e.getComponent<cro::Transform>().setScale(((m_minimapZoom.mapScale * 1.8f * (1.f + ((m_minimapZoom.zoom - 1.f) * 0.125f))) * 0.75f) * (glm::vec2(1.f) / MapSizeRatio));

auto miniBounds = mapEnt.getComponent<cro::Transform>().getWorldTransform() * mapEnt.getComponent<cro::Drawable2D>().getLocalBounds();
//auto flagBounds = glm::inverse(e.getComponent<cro::Transform>().getWorldTransform()) * miniBounds;
Expand Down
2 changes: 1 addition & 1 deletion samples/golf/src/golf/MiniBallSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ void MiniBallSystem::process(float dt)
//set scale based on height
static constexpr float MaxHeight = 40.f;
float scale = 1.f + (position.y / MaxHeight);
entity.getComponent<cro::Transform>().setScale(glm::vec2(scale) * m_minimapZoom.mapScale);
entity.getComponent<cro::Transform>().setScale(glm::vec2(scale) * m_minimapZoom.mapScale * 2.f);


//or if in bounds of the mini map
Expand Down

0 comments on commit 583529f

Please sign in to comment.