added gridPositionIsValid function
used in moveSpriteInGrid