Untitled
unknown
c_cpp
10 months ago
2.0 kB
3
Indexable
void Output::DrawBelt(const CellPosition& fromCellPos, const CellPosition& toCellPos) const
{
// Validate the fromCell and toCell
if (!fromCellPos.IsValidCell() || !toCellPos.IsValidCell())
return;
// Belt must be horizontal or vertical, and fromCell cannot be the first cell
if (fromCellPos.VCell() != toCellPos.VCell() && fromCellPos.HCell() != toCellPos.HCell())
return;
if (fromCellPos.GetCellNum() == 1)
return;
// Get the start X and Y coordinates of the upper left corner of the fromCell
int fromCellStartX = GetCellStartX(fromCellPos);
int fromCellStartY = GetCellStartY(fromCellPos);
int toCellStartX = GetCellStartX(toCellPos);
int toCellStartY = GetCellStartY(toCellPos);
int beltFromCellX = fromCellStartX + (UI.CellWidth / 2) + UI.BeltXOffset;
int beltToCellX = toCellStartX + UI.BeltXOffset;
int beltFromCellY = fromCellStartY + UI.BeltYOffset;
int beltToCellY = toCellStartY + UI.BeltYOffset;
// Set pen color and width using the UI_Info object
pWind->SetPen(UI.BeltColor, UI.BeltLineWidth);
// Draw the line of the belt
pWind->DrawLine(beltFromCellX, beltFromCellY, beltToCellX, beltToCellY);
// Calculate triangle dimensions
int triangleWidth = UI.CellWidth / 4;
int triangleHeight = UI.CellHeight / 4;
// Determine belt direction
Direction Belt_Direction;
if (fromCellPos.VCell() > toCellPos.VCell()) // Moving downward
Belt_Direction = DOWN;
else if (fromCellPos.VCell() < toCellPos.VCell()) // Moving upward
Belt_Direction = UP;
else if (fromCellPos.HCell() > toCellPos.HCell()) // Moving left
Belt_Direction = LEFT;
else // Moving right
Belt_Direction = RIGHT;
// Draw the triangle at the center of the belt line pointing to the direction of the belt
DrawTriangle(
(beltFromCellX + beltToCellX) / 2, // Center X-coordinate of the triangle
(beltFromCellY + beltToCellY) / 2, // Center Y-coordinate of the triangle
triangleHeight,
triangleWidth,
Belt_Direction,
UI.BeltColor,
FILLED,
1
);
}
Editor is loading...
Leave a Comment