Skip to content

Commit 088d093

Browse files
committed
Fully implemented MOSprite:GetAllPixelPositions()
1 parent 00e1ce9 commit 088d093

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

Source/Entities/MOSprite.cpp

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -355,16 +355,28 @@ std::vector<Vector>* MOSprite::GetAllPixelPositions(const Vector& origin, float
355355
std::vector<Vector>* posList = new std::vector<Vector>();
356356
CLAMP(m_FrameCount - 1, 0, whichFrame);
357357
BITMAP* sprite = m_aSprite[whichFrame];
358-
for (int y = 0; y < GetSpriteHeight(); y++) {
359-
for (int x = 0; x < GetSpriteWidth(); x++) {
360-
int pixelIndex = GetPixelIndex(x, y, whichFrame);
358+
BITMAP* temp = create_bitmap_ex(8, m_SpriteDiameter * m_Scale, m_SpriteDiameter * m_Scale);
359+
rectfill(temp, 0, 0, temp->w - 1, temp->h - 1, 0);
360+
Vector offset = Vector(temp->w / 2 + m_SpriteOffset.m_X, temp->h / 2 + m_SpriteOffset.m_Y);
361+
362+
if (!hflipped) {
363+
rotate_scaled_sprite(temp, sprite, offset.m_X, offset.m_Y, ftofix(GetAllegroAngle(-m_Rotation.GetDegAngle())), ftofix(m_Scale));
364+
} else {
365+
rotate_scaled_sprite_v_flip(temp, sprite, offset.m_X, offset.m_Y, ftofix(GetAllegroAngle(-m_Rotation.GetDegAngle())) + itofix(128), ftofix(m_Scale));
366+
}
367+
368+
for (int y = 0; y < temp->h; y++) {
369+
for (int x = 0; x < temp->w; x++) {
370+
int pixelIndex = getpixel(temp, x, y);
361371
if (includeTransparency || pixelIndex > 0) {
362-
Vector pixelPos = (Vector(x, y) + m_SpriteOffset).FlipX(hflipped).RadRotate(angle) + origin;
372+
Vector pixelPos = (Vector(x - temp->w / 2, y - temp->h / 2)) + origin;
363373
posList->push_back(pixelPos.GetRounded());
364374
}
365375
}
366376
}
367377

378+
destroy_bitmap(temp);
379+
temp = NULL;
368380
return posList;
369381
}
370382

0 commit comments

Comments
 (0)