Skip to content

Commit 1b90c30

Browse files
committed
Implemented MOSprite:GetPixelIndex(), implemented first take on MOSprite:GetAllPixelPositions()
1 parent ec01597 commit 1b90c30

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

Source/Entities/MOSprite.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,23 @@ void MOSprite::SetAllSpritePixelIndexes(int whichFrame, int colorIndex, int igno
439439
}
440440
}
441441

442+
std::vector<Vector>* MOSprite::GetAllPixelPositions(const Vector& origin, float angle, bool hflipped, bool includeTransparency, unsigned int whichFrame) {
443+
std::vector<Vector>* posList = new std::vector<Vector>();
444+
CLAMP(m_FrameCount - 1, 0, whichFrame);
445+
BITMAP* sprite = m_aSprite[whichFrame];
446+
for (int y = 0; y < GetSpriteHeight(); y++) {
447+
for (int x = 0; x < GetSpriteWidth(); x++) {
448+
int pixelIndex = GetPixelIndex(x, y, whichFrame);
449+
if (includeTransparency || pixelIndex > 0) {
450+
Vector pixelPos = (Vector(x, y) + m_SpriteOffset).FlipX(hflipped).RadRotate(angle) + origin;
451+
posList->push_back(pixelPos.GetRounded());
452+
}
453+
}
454+
}
455+
456+
return posList;
457+
}
458+
442459
void MOSprite::Update() {
443460
MovableObject::Update();
444461

0 commit comments

Comments
 (0)