Skip to content

Instantly share code, notes, and snippets.

@clooth
Created September 23, 2013 11:52
Show Gist options
  • Save clooth/6669471 to your computer and use it in GitHub Desktop.
Save clooth/6669471 to your computer and use it in GitHub Desktop.
// Map edge scrolling
if (mousePosition.x < mapScrollTreshold && mousePosition.x >= 0) {
mapScrollSpeed += (mapScrollSpeed - mousePosition.x) * 1.5f;
panMapLeft(mapScrollSpeed, TimePerFrame);
}
if (mousePosition.x >= window.getSize().x - mapScrollTreshold
&& mousePosition.x <= window.getSize().x) {
mapScrollSpeed += (window.getSize().x - mousePosition.x) * 1.5f;
panMapRight(mapScrollSpeed, TimePerFrame);
}
if (mousePosition.y < mapScrollTreshold && mousePosition.y >= 0) {
mapScrollSpeed += (mapScrollTreshold - mousePosition.y) * 1.5f;
panMapUp(mapScrollSpeed, TimePerFrame);
}
if (mousePosition.y >= window.getSize().y - mapScrollTreshold
&& mousePosition.y <= window.getSize().y) {
mapScrollSpeed += (window.getSize().y - mousePosition.y) * 1.5f;
panMapDown(mapScrollSpeed, TimePerFrame);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment