diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..5316595 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +*.o +mobiground diff --git a/main.c b/main.c index 6c07a69..f31a1d8 100644 --- a/main.c +++ b/main.c @@ -4,7 +4,6 @@ #include #include // only include this one in the source file with main()! - SDL_Window* window = NULL; SDL_Renderer* renderer = NULL; @@ -33,47 +32,30 @@ int main( int argc, char* argv[] ) window = SDL_CreateWindow("Hello SDL", WIDTH, HEIGHT, 0); if (!window) { - panic("SDL_CreateWindow"); + panic("SDL_CreateWindow"); } - renderer = SDL_CreateRenderer(window, 0); + renderer = SDL_CreateRenderer(window, "opengl"); if (!renderer) { - panic("SDL_CreateRenderer"); + panic("SDL_CreateRenderer"); } - SDL_SetRenderDrawColor(renderer, 255, 64, 0, 255); - SDL_RenderClear(renderer); - SDL_RenderPresent(renderer); - + int orange = 0; while (!loopShouldStop) { SDL_Event e; SDL_zero(e); while (SDL_PollEvent(&e)) { - switch (e.type) - { - case SDL_EVENT_KEY_DOWN: - switch (e.key.mod) - { - case SDL_KMOD_LCTRL: - switch (e.key.key) - { - case SDLK_Q: - SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_INFORMATION, "Hello OOPS!", "OOPS!", window); - break; - } - break; - } - break; - case SDL_EVENT_QUIT: - loopShouldStop = true; - break; - default: - break; - } + if (e.type == SDL_EVENT_KEY_DOWN && e.key.mod == SDL_KMOD_LCTRL && e.key.key == SDLK_Q) + loopShouldStop = true; } + + SDL_SetRenderDrawColor(renderer, 0, orange, 0, 255); + SDL_RenderClear(renderer); + SDL_RenderPresent(renderer); + orange = (orange + 1) % 256; } SDL_DestroyRenderer(renderer); SDL_DestroyWindow(window);