]> git.mxchange.org Git - quix0rs-blobwars.git/blobdiff - src/CEngine.cpp
Added .gitignore to ignore certain files + fixed access rights on Makefile* as
[quix0rs-blobwars.git] / src / CEngine.cpp
index 6f0cc752a598da6d8d4dbc13d38e229a2b5ea75e..d1723aab14f883800b8fd099e87f9228be753456 100644 (file)
@@ -155,14 +155,6 @@ void Engine::addKeyEvent()
 
 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)
@@ -184,6 +176,11 @@ void Engine::getInput()
                                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)
@@ -325,9 +322,12 @@ int Engine::getMouseY() const
        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()