void MaskFrame::nudgeMaskPoint(Direction direction){ MaskPoint* highlightedMaskPoint = getHighlightedMaskPoint(); if(highlightedMaskPoint > 0){ int newX, newY; newX = highlightedMaskPoint->getLiveX(); newY = highlightedMaskPoint->getLiveY(); if(direction == Left){ newX--; }else if(direction == Up){ newY--; }else if(direction == Right){ newX++; }else if(direction == Down){ newY++; } newX = clampInt(newX, frameMargin, this->liveWidth - frameMargin); newY = clampInt(newY, frameMargin, this->liveHeight - frameMargin); highlightedMaskPoint->setLiveX(newX); highlightedMaskPoint->setLiveY(newY); transposeToDesignCanvas(); } }
void MaskFrame::nudge(Direction direction){ int newX, newY; newX = this->livePosition.x; newY = this->livePosition.y; if(direction == Left){ newX--; }else if(direction == Up){ newY--; }else if(direction == Right){ newX++; }else if(direction == Down){ newY++; } int innerBoundaryX = 0; int outerBoundaryX = this->liveCanvas->getWidth() - this->liveWidth; this->livePosition.x = clampInt(newX, innerBoundaryX, outerBoundaryX); int innerBoundaryY = 0; int outerBoundaryY = this->liveCanvas->getHeight() - this->liveHeight; this->livePosition.y = clampInt(newY, innerBoundaryY, outerBoundaryY); transposeToDesignCanvas(); }
void MaskFrame::nudgeDragHandle(Direction direction){ int newWidth, newHeight; newWidth = this->liveWidth; newHeight = this->liveHeight; DragHandle *highlightedDragHandle = this->getHighlightedDragHandle(); Corner corner = highlightedDragHandle->getCorner(); if(corner == TopLeft){ if(direction == Left){ newWidth++; }else if(direction == Up){ newHeight++; }else if(direction == Right){ newWidth--; }else if(direction == Down){ newHeight--; } }else if(corner == TopRight){ if(direction == Left){ newWidth--; }else if(direction == Up){ newHeight++; }else if(direction == Right){ newWidth++; }else if(direction == Down){ newHeight--; } }else if(corner == BottomRight){ if(direction == Left){ newWidth--; }else if(direction == Up){ newHeight--; }else if(direction == Right){ newWidth++; }else if(direction == Down){ newHeight++; } }else if(corner == BottomLeft){ if(direction == Left){ newWidth++; }else if(direction == Up){ newHeight--; }else if(direction == Right){ newWidth--; }else if(direction == Down){ newHeight++; } } int smallestLegalWidth = this->getSmallestLegalLiveWidth(corner); int smallestLegalHeight = this->getSmallestLegalLiveHeight(corner); int newWidthClamped = clampInt(newWidth, smallestLegalWidth); int newHeightClamped = clampInt(newHeight, smallestLegalHeight); this->setLiveSize(newWidthClamped, newHeightClamped, corner); }
void GameState::play() { srand(time(NULL)); win.playerAtExit = false; player1.caught = false; win.exitCurrentBlock = clampInt(10, 21, rand() % 10 + 10); player1.pCurrentBlock = 1; enemy.eCurrentBlock = clampInt( 2, 21, rand() % 21 + 2); enemy2.eCurrentBlock = clampInt(2, 21, rand() % 21 + 2); enemy3.eCurrentBlock = clampInt(2, 21, rand() % 21 + 2); win.displayBorder(); remove("PlayerPath.txt"); }
void MaskFrame::setLiveRectY(int absoluteY){ int canvasY = absoluteY - this->liveCanvas->getY(); int innerBoundaryY = 0; int outerBoundaryY = this->liveCanvas->getHeight() - this->liveHeight; this->livePosition.y = clampInt(canvasY, innerBoundaryY, outerBoundaryY); }
void MaskFrame::setLiveRectX(int absoluteX){ int canvasX = absoluteX - this->liveCanvas->getX(); int innerBoundaryX = 0; int outerBoundaryX = this->liveCanvas->getWidth() - this->liveWidth; this->livePosition.x = clampInt(canvasX, innerBoundaryX, outerBoundaryX); }
void MaskFrame::setSelectedMaskPointPosition(int x, int y){ int clampedX = clampInt(x, frameMargin, this->getWidth() - frameMargin); int clampedY = clampInt(y, frameMargin, this->getHeight() - frameMargin); selectedMaskPoint->setPosition(clampedX, clampedY); transposeToLiveCanvas(); }