Explorar el Código

Snap pawn to grid

DricomDragon hace 4 años
padre
commit
0b75de568f
Se han modificado 1 ficheros con 2 adiciones y 2 borrados
  1. 2 2
      main.cpp

+ 2 - 2
main.cpp

@@ -52,8 +52,8 @@ int main()
 						done = true;
 					break;
 				case SDL_MOUSEMOTION:
-					pawnPos.x = event.motion.x - pawn->w / 2;
-					pawnPos.y = event.motion.y - pawn->h / 2;
+					pawnPos.x = (event.motion.x / pawn->w) * pawn->w;
+					pawnPos.y = (event.motion.y / pawn->h) * pawn->h;
 					break;
 			} // end switch event type
 		} // end of message processing