mirror of
https://github.com/Relintai/programming_tutorials.git
synced 2025-05-11 22:52:11 +02:00
Set up a simple sdl event loop.
This commit is contained in:
parent
c3fb047808
commit
c0f5e57b5a
@ -6,6 +6,27 @@
|
|||||||
|
|
||||||
#include <SDL.h>
|
#include <SDL.h>
|
||||||
|
|
||||||
|
void main_loop_1() {
|
||||||
|
bool quit = false;
|
||||||
|
SDL_Event e;
|
||||||
|
|
||||||
|
while (!quit) {
|
||||||
|
while (SDL_PollEvent(&e)) {
|
||||||
|
if (e.type == SDL_QUIT) {
|
||||||
|
quit = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (e.type == SDL_KEYDOWN) {
|
||||||
|
printf("keydown\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (e.type == SDL_KEYUP) {
|
||||||
|
printf("keyup\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int main(int argv, char **args) {
|
int main(int argv, char **args) {
|
||||||
Renderer r;
|
Renderer r;
|
||||||
|
|
||||||
@ -23,7 +44,7 @@ int main(int argv, char **args) {
|
|||||||
r.draw_sprite(s);
|
r.draw_sprite(s);
|
||||||
r.present();
|
r.present();
|
||||||
|
|
||||||
SDL_Delay(500);
|
main_loop_1();
|
||||||
|
|
||||||
t.free();
|
t.free();
|
||||||
i.free();
|
i.free();
|
||||||
|
Loading…
Reference in New Issue
Block a user