Skip to content

Commit

Permalink
tweakages
Browse files Browse the repository at this point in the history
  • Loading branch information
fallahn committed Sep 2, 2024
1 parent 905b241 commit 58f6ce6
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 61 deletions.
50 changes: 25 additions & 25 deletions samples/golf/src/golf/DrivingState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -621,31 +621,31 @@ bool DrivingState::handleEvent(const cro::Event& evt)
{
pauseGame();
}
else if (evt.type == SDL_WINDOWEVENT)
{
switch (evt.window.event)
{
default: break;
case SDL_WINDOWEVENT_FOCUS_GAINED:
//this needs to be delayed a frame so mouse clicking on the
//open window doesn't get sent to the input parser
{
auto entity = m_uiScene.createEntity();
entity.addComponent<cro::Callback>().active = true;
entity.getComponent<cro::Callback>().function =
[&](cro::Entity e, float)
{
m_inputParser.setSuspended(false);
e.getComponent<cro::Callback>().active = false;
m_uiScene.destroyEntity(e);
};
}
break;
case SDL_WINDOWEVENT_FOCUS_LOST:
m_inputParser.setSuspended(true);
break;
}
}
//else if (evt.type == SDL_WINDOWEVENT)
//{
// switch (evt.window.event)
// {
// default: break;
// case SDL_WINDOWEVENT_FOCUS_GAINED:
// //this needs to be delayed a frame so mouse clicking on the
// //open window doesn't get sent to the input parser
// {
// auto entity = m_uiScene.createEntity();
// entity.addComponent<cro::Callback>().active = true;
// entity.getComponent<cro::Callback>().function =
// [&](cro::Entity e, float)
// {
// m_inputParser.setSuspended(false);
// e.getComponent<cro::Callback>().active = false;
// m_uiScene.destroyEntity(e);
// };
// }
// break;
// case SDL_WINDOWEVENT_FOCUS_LOST:
// m_inputParser.setSuspended(true);
// break;
// }
//}

#ifdef CRO_DEBUG_
//m_gameScene.getSystem<FpsCameraSystem>()->handleEvent(evt);
Expand Down
4 changes: 2 additions & 2 deletions samples/golf/src/golf/GameConsts.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -362,8 +362,8 @@ static inline float getWindMultiplier(float ballHeight, float distanceToPin)
static constexpr float MinWind = 10.f;
static constexpr float MaxWind = 32.f;

static constexpr float MinHeight = 20.f;// 40.f;
static constexpr float MaxHeight = 30.f;// 50.f;
static constexpr float MinHeight = 30.f;// 40.f;
static constexpr float MaxHeight = 50.f;// 50.f;
const float HeightMultiplier = std::clamp((ballHeight - MinHeight) / (MaxHeight / MinHeight), 0.f, 1.f);

float multiplier = std::clamp((distanceToPin - MinWind) / (MaxWind - MinWind), 0.f, 1.f);
Expand Down
62 changes: 31 additions & 31 deletions samples/golf/src/golf/GolfState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1063,37 +1063,37 @@ bool GolfState::handleEvent(const cro::Event& evt)
}
}

else if (evt.type == SDL_WINDOWEVENT)
{
switch (evt.window.event)
{
default: break;
case SDL_WINDOWEVENT_FOCUS_GAINED:
//this needs to be delayed a frame so mouse clicking on the
//open window doesn't get sent to the input parser
if (m_currentPlayer.client == m_sharedData.localConnectionData.connectionID
&& !m_sharedData.localConnectionData.playerData[m_currentPlayer.player].isCPU)
{
auto entity = m_uiScene.createEntity();
entity.addComponent<cro::Callback>().active = true;
entity.getComponent<cro::Callback>().function =
[&](cro::Entity e, float)
{
m_inputParser.setSuspended(false);
e.getComponent<cro::Callback>().active = false;
m_uiScene.destroyEntity(e);
};
}
break;
case SDL_WINDOWEVENT_FOCUS_LOST:
if (m_currentPlayer.client == m_sharedData.localConnectionData.connectionID
&& !m_sharedData.localConnectionData.playerData[m_currentPlayer.player].isCPU)
{
m_inputParser.setSuspended(true);
}
break;
}
}
//else if (evt.type == SDL_WINDOWEVENT)
//{
// switch (evt.window.event)
// {
// default: break;
// case SDL_WINDOWEVENT_FOCUS_GAINED:
// //this needs to be delayed a frame so mouse clicking on the
// //open window doesn't get sent to the input parser
// if (m_currentPlayer.client == m_sharedData.localConnectionData.connectionID
// && !m_sharedData.localConnectionData.playerData[m_currentPlayer.player].isCPU)
// {
// auto entity = m_uiScene.createEntity();
// entity.addComponent<cro::Callback>().active = true;
// entity.getComponent<cro::Callback>().function =
// [&](cro::Entity e, float)
// {
// m_inputParser.setSuspended(false);
// e.getComponent<cro::Callback>().active = false;
// m_uiScene.destroyEntity(e);
// };
// }
// break;
// case SDL_WINDOWEVENT_FOCUS_LOST:
// if (m_currentPlayer.client == m_sharedData.localConnectionData.connectionID
// && !m_sharedData.localConnectionData.playerData[m_currentPlayer.player].isCPU)
// {
// m_inputParser.setSuspended(true);
// }
// break;
// }
//}

m_gameScene.forwardEvent(evt);
m_skyScene.forwardEvent(evt);
Expand Down
8 changes: 5 additions & 3 deletions samples/golf/src/golf/MenuConsts.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,14 @@ static inline const std::array<std::string, ScoreType::Count> RuleDescriptions =
#ifdef USE_GNS
"The player with the fewest total strokes wins.\nSolo or network play scores contribute to the\nmonthly and all time leaderboards.\nContributes to the Club League.\n\nRecommended for solo play or 2+ players.",
#else
"The player with the fewest total strokes wins.\nContributes to the Club League.\n\nRecommended for solo play or 2+ players",
"The player with the fewest total strokes wins.\nContributes to the Club League.\n\n\n\nRecommended for solo play or 2+ players",
#endif
"Stroke play rules, however par is scored at\n2 points, with one extra point awarded for every\nstroke under par. Max strokes are reached when\nthere are no more points available. The player with\nthe most points wins. Contributes to the Club League.\nRecommended for solo play or 2+ players.",
"Stableford rules, however one point for every\nstroke over par is deducted instead of reaching\nthe stroke limit. The player with the most points wins.\nContributes to the Club League.\n\nRecommended for solo play or 2+ players.",
"Holes are scored individually by fewest strokes\n and one point is awarded for each hole won.\nThe player with the most points wins.\nGroup mode is ignored.\n\nA head to head round, 2 players only.",
"Holes are scored individually by fewest strokes.\nThe winner of the hole gets the skins pot,\nelse the pot rolls over to the next hole.\nTies are resolved with a sudden death round.\nGroup mode is ignored.\nMinimum 2 players, recommended for 2-4 players.",
"Holes are scored individually by fewest strokes\n and one point is awarded for each hole won.\nThe player with the most points wins.\n\n\nA head to head round, 2 players only.",
"Holes are scored individually by fewest strokes.\nThe winner of the hole gets the skins pot,\nelse the pot rolls over to the next hole.\nTies are resolved with a sudden death round.\n\nMinimum 2 players, recommended for 2-4 players.",
//"Holes are scored individually by fewest strokes\n and one point is awarded for each hole won.\nThe player with the most points wins.\nGroup mode is ignored.\n\nA head to head round, 2 players only.",
//"Holes are scored individually by fewest strokes.\nThe winner of the hole gets the skins pot,\nelse the pot rolls over to the next hole.\nTies are resolved with a sudden death round.\nGroup mode is ignored.\nMinimum 2 players, recommended for 2-4 players.",
"Stroke play, but each player must hit the mid-point\ntarget before reaching the green. Not hitting the\ntarget forfeits the hole. Round times are usually\nlonger than average. Par is increased by one\non larger courses.\nRecommended for 2-4 players.",
#ifdef USE_GNS
"As stroke play, however the number of holes is\nreduced by 33% - 18 holes become 12 and 9 holes\nbecome 6. Ideal for casual games. User courses\nremain unaffected, and scores are omitted from\nthe leaderboards. Contributes to the Club League.\nRecommended for solo play or 2+ players.",
Expand Down

0 comments on commit 58f6ce6

Please sign in to comment.