Browse Source

Drag & Friction: Add mouse

Godzil 1 year ago
parent
commit
3d37330f8e
2 changed files with 12 additions and 0 deletions
  1. 10 0
      source/app.cpp
  2. 2 0
      source/include/app.h

+ 10 - 0
source/app.cpp

@@ -73,6 +73,16 @@ void application::input()
             if (event.key.keysym.sym == SDLK_LEFT) this->pushForce.x = 0;
 
             break;
+
+        case SDL_MOUSEBUTTONDOWN:
+            if (event.button.button == SDL_BUTTON_LEFT)
+            {
+                int x, y;
+                SDL_GetMouseState(&x, &y);
+                particle *part = new particle(x, y, 1., 5);
+                this->particles.push_back(part);
+            }
+            break;
         }
     }
 }

+ 2 - 0
source/include/app.h

@@ -12,6 +12,8 @@
 
 #include <vector>
 
+#include <SDL.h>
+
 #include <timeprobe.h>
 #include <physics/particle.h>