Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
mmatyas committed May 25, 2024
1 parent 9271713 commit 25492ad
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 13 deletions.
20 changes: 10 additions & 10 deletions src/common/MovingPlatformPaths.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ MovingPlatformPath::MovingPlatformPath(float speed, Vec2f startPos, Vec2f endPos
if (preview) {
m_startPos /= 2.f;
m_endPos /= 2.f;
m_speed /= 2.0f;
m_speed /= 2.f;
}
}

Expand All @@ -49,15 +49,15 @@ StraightPath::StraightPath(float speed, Vec2f startPos, Vec2f endPos, bool previ
{
float width = m_endPos.x - m_startPos.x;
float height = m_endPos.y - m_startPos.y;
float length = 0.0f;
float length = 0.f;

if (width == 0) {
// Lock angle to vertical
m_angle = (height > 0) ? HALF_PI : THREE_HALF_PI;
length = ::fabs(height);
} else if (height == 0) {
// Lock angle to horizontal
m_angle = (width > 0) ? 0.0f : PI;
m_angle = (width > 0) ? 0.f : PI;
length = ::fabs(width);
} else {
m_angle = atan2(height, width);
Expand Down Expand Up @@ -96,10 +96,10 @@ void StraightPath::SetVelocity(short type)

//Fix rounding errors
if (::fabs(m_velocity[type].x) < 0.01f)
m_velocity[type].x = 0.0f;
m_velocity[type].x = 0.f;

if (::fabs(m_velocity[type].y) < 0.01f)
m_velocity[type].y = 0.0f;
m_velocity[type].y = 0.f;
}

void StraightPath::Reset()
Expand Down Expand Up @@ -141,12 +141,12 @@ bool StraightPathContinuous::Move(short type)
m_currentPos[type] += m_velocity[type];

float dx = m_currentPos[type].x - (float)m_platform->iHalfWidth;
if (dx < 0.0f)
if (dx < 0.f)
m_currentPos[type].x += m_edge.x;
else if (dx >= m_edge.x)
m_currentPos[type].x -= m_edge.x;

if (m_currentPos[type].y + (float)m_platform->iHalfHeight < 0.0f)
if (m_currentPos[type].y + (float)m_platform->iHalfHeight < 0.f)
m_currentPos[type].y += m_edge.y + (float)m_platform->iHeight;
else if (m_currentPos[type].y - (float)m_platform->iHalfHeight >= m_edge.y)
m_currentPos[type].y -= m_edge.y + (float)m_platform->iHeight;
Expand Down Expand Up @@ -188,8 +188,8 @@ bool EllipsePath::Move(short type)

m_angle[type] += m_speed;

if (m_speed < 0.0f) {
while (m_angle[type] < 0.0f)
if (m_speed < 0.f) {
while (m_angle[type] < 0.f)
m_angle[type] += TWO_PI;
} else {
while (m_angle[type] >= TWO_PI)
Expand Down Expand Up @@ -224,7 +224,7 @@ void EllipsePath::Reset()
//------------------------------------------------------------------------------

FallingPath::FallingPath(Vec2f startPos)
: MovingPlatformPath(0.0f, std::move(startPos), Vec2f::zero(), false)
: MovingPlatformPath(0.f, std::move(startPos), Vec2f::zero(), false)
{}

bool FallingPath::Move(short type)
Expand Down
1 change: 1 addition & 0 deletions src/common/MovingPlatformPaths.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ class EllipsePath : public MovingPlatformPath {
private:
Vec2f m_radius;
float m_startAngle;

float m_angle[2];

friend class MovingPlatform;
Expand Down
6 changes: 3 additions & 3 deletions src/common/map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1753,11 +1753,11 @@ void CMap::drawThumbnailPlatforms(SDL_Surface * targetSurface)
MovingPlatformPath * basepath = platform->pPath;

if (auto* path = dynamic_cast<StraightPath*>(basepath)) {
DrawPlatform(path->typeId(), platform->iTileData, ((short)path->m_startPos.x) << 1, ((short)path->m_startPos.y) << 1, ((short)path->m_endPos.x) << 1, ((short)path->m_endPos.y) << 1, 0.0f, 0.0f, 0.0f, 2, platform->iTileWidth, platform->iTileHeight, true, true);
DrawPlatform(path->typeId(), platform->iTileData, path->m_startPos.x * 2.f, path->m_startPos.y * 2.f, path->m_endPos.x * 2.f, path->m_endPos.y * 2.f, 0.0f, 0.0f, 0.0f, 2, platform->iTileWidth, platform->iTileHeight, true, true);
} else if (auto* path = dynamic_cast<StraightPathContinuous*>(basepath)) {
DrawPlatform(path->typeId(), platform->iTileData, ((short)path->m_startPos.x) << 1, ((short)path->m_startPos.y) << 1, 0, 0, path->m_angle, 0.0f, 0.0f, 2, platform->iTileWidth, platform->iTileHeight, true, true);
DrawPlatform(path->typeId(), platform->iTileData, path->m_startPos.x * 2.f, path->m_startPos.y * 2.f, 0, 0, path->m_angle, 0.0f, 0.0f, 2, platform->iTileWidth, platform->iTileHeight, true, true);
} else if (auto* path = dynamic_cast<EllipsePath*>(basepath)) {
DrawPlatform(path->typeId(), platform->iTileData, ((short)path->m_startPos.x) << 1, ((short)path->m_startPos.y) << 1, 0, 0, path->m_startAngle, path->m_radius.x * 2, path->m_radius.y * 2, 2, platform->iTileWidth, platform->iTileHeight, true, true);
DrawPlatform(path->typeId(), platform->iTileData, path->m_startPos.x * 2.f, path->m_startPos.y * 2.f, 0, 0, path->m_startAngle, path->m_radius.x * 2, path->m_radius.y * 2, 2, platform->iTileWidth, platform->iTileHeight, true, true);
}
}

Expand Down

0 comments on commit 25492ad

Please sign in to comment.