void Engine::getInput()
{
- SDL_GetMouseState(&mouseX, &mouseY);
-
- // Scale from window coordinates to graphics coordinates
- int w, h;
- SDL_GetWindowSize(graphics.window, &w, &h);
- mouseX = mouseX * 640 / w;
- mouseY = mouseY * 480 / h;
-
while (SDL_PollEvent(&event))
{
switch (event.type)
if (event.button.button == SDL_BUTTON_RIGHT) mouseRight = 0;
break;
+ case SDL_MOUSEMOTION:
+ mouseX = event.motion.x;
+ mouseY = event.motion.y;
+ break;
+
case SDL_KEYDOWN:
if (waitForButton)
return mouseY;
}
-void Engine::setMouse(int x, int y)
+void Engine::moveMouse(int dx, int dy)
{
- SDL_WarpMouseInWindow(graphics.window, x, y);
+ mouseX += dx;
+ mouseY += dy;
+ Math::limitInt(&mouseX, 0, 640);
+ Math::limitInt(&mouseY, 0, 480);
}
bool Engine::userAccepts()