Skip to content

Commit

Permalink
use d-pad for fine tune aiming
Browse files Browse the repository at this point in the history
unlock all golf clubs when playing hotseat
add shadow casting to ropes
  • Loading branch information
fallahn committed Nov 12, 2024
1 parent f8e1549 commit 032955f
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
13 changes: 13 additions & 0 deletions samples/golf/src/golf/GolfState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,19 @@ GolfState::GolfState(cro::StateStack& stack, cro::State::Context context, Shared
}
m_cpuGolfer.setCPUCount(cpuCount, sd);


//if we're playing hotseat unlock all the clubs unless
//the clubset limit is set
if (clientCount == 1
&& humanCount > 1)
{
if (!m_sharedData.clubLimit)
{
m_sharedData.clubSet = 2;
}
}


Timeline::setGameMode(Timeline::GameMode::LoadingScreen);
context.mainWindow.loadResources([this]() {
addSystems();
Expand Down
7 changes: 6 additions & 1 deletion samples/golf/src/golf/InputParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ namespace

static constexpr float RotationSpeed = 1.2f;
static constexpr float MaxRotation = 0.36f;
float FineTune = 1.f; //this is halved when using D-Pad for finer aiming

static constexpr float MinPower = 0.01f;
static constexpr float MaxPower = 1.f - MinPower;
Expand Down Expand Up @@ -302,10 +303,12 @@ void InputParser::handleEvent(const cro::Event& evt)
else if (evt.cbutton.button == cro::GameController::DPadLeft)
{
m_inputFlags |= InputFlag::Left;
FineTune = 0.5f;
}
else if (evt.cbutton.button == cro::GameController::DPadRight)
{
m_inputFlags |= InputFlag::Right;
FineTune = 0.5f;
}
else if (evt.cbutton.button == cro::GameController::DPadUp)
{
Expand Down Expand Up @@ -375,10 +378,12 @@ void InputParser::handleEvent(const cro::Event& evt)
else if (evt.cbutton.button == cro::GameController::DPadLeft)
{
m_inputFlags &= ~InputFlag::Left;
FineTune = 1.f;
}
else if (evt.cbutton.button == cro::GameController::DPadRight)
{
m_inputFlags &= ~InputFlag::Right;
FineTune = 1.f;
}
else if (evt.cbutton.button == cro::GameController::DPadUp)
{
Expand Down Expand Up @@ -1019,7 +1024,7 @@ void InputParser::updateStroke(float dt)


//rotation
const float rotation = RotationSpeed * m_maxRotation * m_analogueAmount * dt;
const float rotation = RotationSpeed * FineTune * m_maxRotation * m_analogueAmount * dt;

if (m_inputFlags & InputFlag::Left)
{
Expand Down
9 changes: 9 additions & 0 deletions samples/golf/src/golf/MenuState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ source distribution.
#include <crogine/util/Wavetable.hpp>

#include <crogine/ecs/InfoFlags.hpp>
#include <crogine/ecs/components/ShadowCaster.hpp>
#include <crogine/ecs/components/Transform.hpp>
#include <crogine/ecs/components/Text.hpp>
#include <crogine/ecs/components/Camera.hpp>
Expand Down Expand Up @@ -2551,6 +2552,9 @@ void main(){FRAG_OUT = u_colour;}
auto material = m_resources.materials.get(matID);
material.setProperty("u_colour", CD32::Colours[CD32::GreyLight] * m_sharedData.menuSky.sunColour);

auto shaderID = m_resources.shaders.loadBuiltIn(cro::ShaderResource::ShadowMap, cro::ShaderResource::DepthMap);
auto shadowMatID = m_resources.materials.add(m_resources.shaders.get(shaderID));

const auto createRopeMesh = [&](glm::vec3 pos, std::size_t ropeID)
{
//position only, triangle strip
Expand All @@ -2559,6 +2563,11 @@ void main(){FRAG_OUT = u_colour;}
auto meshID = m_resources.meshes.loadMesh(cro::DynamicMeshBuilder(cro::VertexProperty::Position, 1, GL_LINE_STRIP));
entity.addComponent<cro::Model>(m_resources.meshes.getMesh(meshID), material);

if (timeOfDay != TimeOfDay::Night)
{
entity.addComponent<cro::ShadowCaster>();
entity.getComponent<cro::Model>().setShadowMaterial(0, m_resources.materials.get(shadowMatID));
}

//indices are fixed at nodecount + 2 for anchors
std::vector<std::uint32_t> indices;
Expand Down

0 comments on commit 032955f

Please sign in to comment.