Skip to content

Commit

Permalink
Reset flip/rotation in addition to position in case of collison after…
Browse files Browse the repository at this point in the history
… movement
  • Loading branch information
ElTh0r0 committed Jul 6, 2024
1 parent 91c97db commit d14fbc8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
7 changes: 4 additions & 3 deletions block.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,8 @@ void Block::moveBlock(const bool bRelease) {
if (!bRelease) {
m_bActive = true;
this->bringToForeground();
m_posBlockSelected = this->pos(); // Save last position
m_posBlockSelected = this->pos(); // Save last position
m_PolyShapeSelected = m_PolyShape; // Save shape
} else {
m_bActive = false;

Expand All @@ -219,8 +220,8 @@ void Block::moveBlock(const bool bRelease) {

emit incrementMoves();
if (this->checkCollision(thisPath)) {
// Reset position
this->setPos(this->snapToGrid(m_posBlockSelected));
m_PolyShape = m_PolyShapeSelected; // Reset shape (flip / rotation)
this->setPos(this->snapToGrid(m_posBlockSelected)); // Reset position
this->checkBlockIntersection();
} else {
// Check if puzzle is solved
Expand Down
1 change: 1 addition & 0 deletions block.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ class Block : public QGraphicsObject {
QTransform *m_pTransform;
QPointF m_posBlockSelected;
QPointF m_posMouseSelected;
QPolygonF m_PolyShapeSelected;
QGraphicsSimpleTextItem m_ItemNumberText;
};

Expand Down

0 comments on commit d14fbc8

Please sign in to comment.