Skip to main content
Engineering LibreTexts

8.31: Convert from Board Coordinates to Pixel Coordinates

  • Page ID
  • def convertToPixelCoords(boxx, boxy):
        # Convert the given xy coordinates of the board to xy
        # coordinates of the location on the screen.
        return (XMARGIN + (boxx * BOXSIZE)), (TOPMARGIN + (boxy * BOXSIZE))

    This helper function converts the board’s box coordinates to pixel coordinates. This function works the same way to the other "convert coordinates" functions used in the previous game programs.

    • Was this article helpful?