1
0
Fork 0

Add mouse support

This commit is contained in:
Gregory Eremin 2015-09-29 22:16:17 +03:00
parent a0b460a5cc
commit b7b1780f9e
No known key found for this signature in database
GPG Key ID: 5EFA427EEC26E86C
1 changed files with 11 additions and 8 deletions

View File

@ -1,5 +1,4 @@
#include <iostream>
#include <unistd.h>
#include "SDL2/SDL.h"
int main(int argc, char const *argv[]) {
@ -73,6 +72,10 @@ int main(int argc, char const *argv[]) {
break;
}
}
if (e.type == SDL_MOUSEMOTION) {
platform.x = e.motion.x - 100;
}
}
// Re-rendering
SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255);
@ -80,7 +83,7 @@ int main(int argc, char const *argv[]) {
SDL_SetRenderDrawColor(renderer, 0, 0, 255, 255);
SDL_RenderFillRect(renderer, &platform);
SDL_RenderPresent(renderer);
}
SDL_Delay(1);
}
SDL_DestroyWindow(window);