Graphical Window Sprites

version 1 by Erik Temple

  • Home page
  • Beginning
  • Previous
  • Next



  • Section: Simple Calculations with Coordinates

    There may be times when it is useful to calculate the coordinates of one sprite based on the coordinates of another. For example, the Castle of Sprites example below implements a torch that appears to be carried by the player's avatar thanks to the calculation of the torch sprite's coordinates as an offset of the player avatar's coordinates. To calculate an offset, we simply use the phrasing "x offset by y", where x and y are coordinates in the form {a, b}:

        Change the coordinates of the torch-sprite to the coordinates of the player-sprite offset by {-12, 15}.
        
    This will set the torch-sprite coordinates to the coordinates of the player's avatar, but offset by 12 pixels to the left and 15 pixels down. Again, the coordinates are given with reference to the background.