createNewFoodPosition :: WormsAction (GLdouble,GLdouble)
createNewFoodPosition = do
  x <- randomInt (1,18)
  y <- randomInt (1,24)
  mapPositionOk <- checkMapPosition (x,y)
  tails <- getObjectsFromGroup "tail"
  tailPositionNotOk <- pointsObjectListCollision (toPixelCoord y) (toPixelCoord x) tileSize tileSize tails
  if (mapPositionOk && not tailPositionNotOk)
      then (return (toPixelCoord y,toPixelCoord x))
      else createNewFoodPosition
  where toPixelCoord a = (tileSize/2) + (fromIntegral a) * tileSize
createNewFoodPosition :: WormsAction (GLdouble,GLdouble)
createNewFoodPosition = do
  x <- randomInt (1,18)
  y <- randomInt (1,24)
  mapPositionOk <- checkMapPosition (x,y)
  tails <- getObjectsFromGroup "tail"
  tailPositionNotOk <- pointsObjectListCollision (toPixelCoord y) (toPixelCoord x) tileSize tileSize tails
  if (mapPositionOk && not tailPositionNotOk)
      then (return (toPixelCoord y,toPixelCoord x))
      else createNewFoodPosition
  where toPixelCoord a = (tileSize/2) + (fromIntegral a) * tileSize
createNewFoodPosition = do
  x <- randomInt (1,18)
  y <- randomInt (1,24)
  mapPositionOk <- checkMapPosition (x,y)
  tails <- getObjectsFromGroup "tail"
  tailPositionNotOk <- pointsObjectListCollision (toPixelCoord y) (toPixelCoord x) tileSize tileSize tails
  if (mapPositionOk && not tailPositionNotOk)
      then (return (toPixelCoord y,toPixelCoord x))
      else createNewFoodPosition
  where toPixelCoord a = (tileSize/2) + (fromIntegral a) * tileSize