Skip to content

Commit

Permalink
hole radius
Browse files Browse the repository at this point in the history
  • Loading branch information
fallahn committed Nov 3, 2024
1 parent 6b233f5 commit 299b129
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
4 changes: 2 additions & 2 deletions samples/golf/buildnumber.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#ifndef BUILD_NUMBER_H_
#define BUILD_NUMBER_H_

#define BUILDNUMBER 7181
#define BUILDNUMBER_STR "7181"
#define BUILDNUMBER 7184
#define BUILDNUMBER_STR "7184"

#endif /* BUILD_NUMBER_H_ */
10 changes: 7 additions & 3 deletions samples/golf/src/golf/DrivingState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -720,14 +720,18 @@ void DrivingState::handleMessage(const cro::Message& msg)
|| data.type == GolfBallEvent::Holed)
{
//display a message with score
showMessage(glm::length(PlayerPosition - data.position));
const auto dist = glm::length(PlayerPosition - data.position);
showMessage(dist);

const auto pin = m_holeData[m_gameScene.getDirector<DrivingRangeDirector>()->getCurrentHole()].pin;

//does fireworks at pin
if (data.type == GolfBallEvent::Holed)
if (data.type == GolfBallEvent::Holed
|| glm::length2(pin - data.position) < (HoleRadius * HoleRadius))
{
auto* msg2 = postMessage<GolfEvent>(MessageID::GolfMessage);
msg2->type = GolfEvent::HoleInOne;
msg2->position = data.position;
msg2->position = pin;

Achievements::awardAchievement(AchievementStrings[AchievementID::DriveItHome]);
}
Expand Down

0 comments on commit 299b129

Please sign in to comment.