summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVittorio Romeo <vittorio.romeo@outlook.com>2021-01-30 01:45:44 +0000
committerVittorio Romeo <vittorio.romeo@outlook.com>2021-01-30 01:45:44 +0000
commit6f37a303c566d466e47e851bf0073b7df5923a4b (patch)
tree91fd616a81c37b0029dd042f631c77e5a8513e60
parentb3a63bdf96e23062bc6b75ad3bf2e17b0657fc4e (diff)
-rw-r--r--_RELEASE/config.json4
-rw-r--r--include/SSVOpenHexagon/Components/CWall.hpp2
-rw-r--r--src/SSVOpenHexagon/Components/CPlayer.cpp4
-rw-r--r--src/SSVOpenHexagon/Components/CWall.cpp12
-rw-r--r--src/SSVOpenHexagon/Core/HGUpdate.cpp10
5 files changed, 21 insertions, 11 deletions
diff --git a/_RELEASE/config.json b/_RELEASE/config.json
index 9e24ab13..c1c646fb 100644
--- a/_RELEASE/config.json
+++ b/_RELEASE/config.json
@@ -58,7 +58,7 @@
"sound_volume" : 75.0,
"t_down" :
[
- [ "kS" ],
+ [ "" ],
[ "" ],
[ "" ],
[ "" ]
@@ -149,7 +149,7 @@
],
"t_up" :
[
- [ "kW" ],
+ [ "" ],
[ "" ],
[ "" ],
[ "" ]
diff --git a/include/SSVOpenHexagon/Components/CWall.hpp b/include/SSVOpenHexagon/Components/CWall.hpp
index e1e51a36..b387061d 100644
--- a/include/SSVOpenHexagon/Components/CWall.hpp
+++ b/include/SSVOpenHexagon/Components/CWall.hpp
@@ -38,7 +38,7 @@ public:
void moveTowardsCenter(HexagonGame& mHexagonGame,
const sf::Vector2f& mCenterPos, const ssvu::FT mFT);
- void moveVertexAlongCurve(sf::Vector2f& mVertex,
+ [[gnu::always_inline]] void moveVertexAlongCurve(sf::Vector2f& mVertex,
const sf::Vector2f& mCenterPos, const ssvu::FT mFT) const
{
ssvs::rotateRadAround(mVertex, mCenterPos, curve.speed / 60.f * mFT);
diff --git a/src/SSVOpenHexagon/Components/CPlayer.cpp b/src/SSVOpenHexagon/Components/CPlayer.cpp
index b0622139..811c6e39 100644
--- a/src/SSVOpenHexagon/Components/CPlayer.cpp
+++ b/src/SSVOpenHexagon/Components/CPlayer.cpp
@@ -182,6 +182,7 @@ void CPlayer::kill(HexagonGame& mHexagonGame)
// of the rotation is different from the direction player is moving.
const SpeedData& curveData{wall.getCurve()};
const int speedSign{ssvu::getSign(curveData.speed)};
+
if(curveData.speed != 0.f && speedSign != movement)
{
wall.moveVertexAlongCurve(pos, mCenterPos, mFT);
@@ -202,6 +203,7 @@ void CPlayer::kill(HexagonGame& mHexagonGame)
const float currentSpeed{
mHexagonGame.getPlayerSpeedMult() *
(mHexagonGame.getInputFocused() ? focusSpeed : speed)};
+
lastAngle =
angle + ssvu::toRad(currentSpeed * movement * mFT) + movement * padding;
lastPos = ssvs::getOrbitRad(startPos, lastAngle, mHexagonGame.getRadius());
@@ -220,10 +222,12 @@ void CPlayer::kill(HexagonGame& mHexagonGame)
const std::array<sf::Vector2f, 4>& wVertexes{wall.getVertexes()};
const float radZero{ssvs::getRad(wVertexes[0])},
radOne{ssvs::getRad(wVertexes[1])};
+
angle = ssvu::getDistRad(angle, radOne) > ssvu::getDistRad(angle, radZero)
? radZero
: radOne;
angle += movement * padding;
+
updatePosition(mHexagonGame, mFT);
return false;
}
diff --git a/src/SSVOpenHexagon/Components/CWall.cpp b/src/SSVOpenHexagon/Components/CWall.cpp
index b94444ca..01fc6622 100644
--- a/src/SSVOpenHexagon/Components/CWall.cpp
+++ b/src/SSVOpenHexagon/Components/CWall.cpp
@@ -57,12 +57,13 @@ void CWall::moveTowardsCenter(HexagonGame& mHexagonGame,
const float radius{mHexagonGame.getRadius() * 0.5f};
const float outerBounds{wallSpawnDist * 1.1f};
- float xDistance, yDistance;
- int pointsOutOfBounds{0}, pointsOnCenter{0};
+ int pointsOutOfBounds{0};
+ int pointsOnCenter{0};
+
for(sf::Vector2f& vp : vertexPositions)
{
- xDistance = std::abs(vp.x - mCenterPos.x);
- yDistance = std::abs(vp.y - mCenterPos.y);
+ const float xDistance = std::abs(vp.x - mCenterPos.x);
+ const float yDistance = std::abs(vp.y - mCenterPos.y);
if(xDistance < radius && yDistance < radius)
{
@@ -74,10 +75,11 @@ void CWall::moveTowardsCenter(HexagonGame& mHexagonGame,
{
++pointsOutOfBounds;
}
+
ssvs::moveTowards(vp, mCenterPos, speed.speed * 5.f * mFT);
}
- if(pointsOnCenter == 4 || pointsOutOfBounds == 4)
+ if(pointsOnCenter > 3 || pointsOutOfBounds > 3)
{
killed = true;
}
diff --git a/src/SSVOpenHexagon/Core/HGUpdate.cpp b/src/SSVOpenHexagon/Core/HGUpdate.cpp
index d2b730ea..57d75f2d 100644
--- a/src/SSVOpenHexagon/Core/HGUpdate.cpp
+++ b/src/SSVOpenHexagon/Core/HGUpdate.cpp
@@ -207,13 +207,17 @@ void HexagonGame::updateWalls(ssvu::FT mFT)
const auto updateWall = [this](CWall& wall, const ssvu::FT& mFT) {
wall.update(*this, mFT);
wall.moveTowardsCenter(*this, centerPos, mFT);
+
if(wall.getCurve().speed != 0.f)
{
wall.moveCurve(*this, centerPos, mFT);
}
};
+
const sf::Vector2f& pPosition{player.getPosition()};
- int i, wSize{static_cast<int>(walls.size())};
+
+ int i;
+ const int wSize{static_cast<int>(walls.size())};
for(i = 0; i < wSize; ++i)
{
@@ -239,8 +243,7 @@ void HexagonGame::updateWalls(ssvu::FT mFT)
break;
}
- // If i == wSize it means there was no collision,
- // so we can stop here.
+ // If `i == wSize` it means there was no collision, so we can stop here.
if(i == wSize)
{
return;
@@ -252,6 +255,7 @@ void HexagonGame::updateWalls(ssvu::FT mFT)
{
steamManager.unlock_achievement("a22_swapdeath");
}
+
player.kill(*this);
};