code: def clamp_within_range(self, x, y):
          
          x = int(x)
          y = int(y)
  
          if x < 0:
              x = 0
          if y < 0:
              y = 0
          if x > self.size_in_tiles.X:
              x = self.size_in_tiles.X
          if y > self.size_in_tiles.Y:
              y = self.size_in_tiles.Y
  
          return x, y
docs: Clamp x and y so that they fall within range of the tilemap.