diff --git a/include/render.h b/include/render.h index 0c949a7..6addb78 100644 --- a/include/render.h +++ b/include/render.h @@ -9,4 +9,4 @@ void renderGame(); int CreateSDLWindow(); -void DestroyWindwo(); \ No newline at end of file +void DestroyWindow(); \ No newline at end of file diff --git a/src/config.c b/src/config.c index 395de52..469792e 100644 --- a/src/config.c +++ b/src/config.c @@ -5,7 +5,7 @@ config_t config = { .windowSize = 800, .blockSizePx = 800/10, //default map is 10x10 blocks - .cycleDurationMs = 1000, + .cycleDurationMs = 400, .difficulty = 1, .snakeDefaultLength = 2, .leaderboardFilename = "" diff --git a/src/main.cpp b/src/main.cpp index c1efde5..3e61233 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,16 +1,11 @@ #include -extern "C" { -#include "food.h" -} - -extern "C"{ - #include "render.h" -} - -extern "C"{ - #include "game.h" - #include "common.h" +extern "C" +{ +#include "game.h" +#include "common.h" +#include "input.h" +#include "render.h" } //initialize SDL window @@ -46,11 +41,16 @@ int main(int argc, char *argv[]) while(1){ if(game.gameState != EXIT) { if (game.gameState == RUNNING) { + processInputEvent(); DELAY(config.cycleDurationMs); + processInputEvent(); runGameCycle(); } - } else {SDL_Quit(); return 0;} + } else { + DestroyWindow(); + SDL_Quit(); + return 0;} } diff --git a/src/render.c b/src/render.c index 4870a96..86632d2 100644 --- a/src/render.c +++ b/src/render.c @@ -11,7 +11,7 @@ SDL_Window* window; void renderGame(){ SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255); -/* SDL_RenderClear(renderer); + SDL_RenderClear(renderer); //Head__________________________________________________ SDL_SetRenderDrawColor(renderer, 0, 200, 100, 255); //RGB-Farbe Kopf @@ -72,7 +72,7 @@ void renderGame(){ SDL_RenderFillRect(renderer, &rect); //Rechteck rendern } -*/ + SDL_RenderPresent(renderer); //Fenster aktualisieren }