Exemplo n.º 1
0
void SnappingUtils::snap()
{
  QgsPointLocator::Match match = snapToMap( QPoint( mInputCoordinate.x(), mInputCoordinate.y() ) );
  mSnappingResult = SnappingResult( match );

  emit snappingResultChanged();
}
Exemplo n.º 2
0
/*
=================================================================================================================================================================
logic() performs logical stuff on the ghost
=================================================================================================================================================================
*/
void Ghost::logic(const sf::Vector2i mousePos, const int maxWidth, const int maxHeight, const sf::RenderWindow& window)
{
    xPos = mGhostRect.getPosition().x / 40;    //Set a variable for y position that is relative to the "tile map" (1px = 40px)
    yPos = mGhostRect.getPosition().y / 40;    //Set a variable that x position  is relative to the "tile map" (1px = 40px)

    goToMouse(mousePos, maxWidth, maxHeight, window);   //Sets the sprites position to the mouse position (if possible)
    isOutOfBounds(maxWidth, maxHeight);    //Checks if the ghost somehow got out of bounds :/
    snapToMap();                                //Snaps the ghost to the tile grid

}