Created
January 7, 2021 03:09
-
-
Save tmwatchanan/f53bb5dc9654982080dcbe6efc3406ba to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <windows.h> | |
| #include <iostream> | |
| #include <unistd.h> | |
| using namespace std; | |
| int main() | |
| { | |
| POINT point; | |
| POINT* pts = new POINT[2]; | |
| int time = 1; // seconds | |
| GetCursorPos(&point); | |
| pts[0] = point; | |
| cout << pts[0].x << " " << pts[0].y << endl; | |
| sleep(time); | |
| GetCursorPos(&point); | |
| pts[1] = point; | |
| cout << pts[1].x << " " << pts[1].y << endl; | |
| double speed_x = (pts[1].x - pts[0].x) / static_cast<double>(time); | |
| double speed_y = (pts[1].y - pts[0].y) / static_cast<double>(time); | |
| cout << "speed x = " << speed_x << " pixels/s" << endl; | |
| cout << "speed y = " << speed_y << " pixels/s" << endl; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment