From b542fa8cc13e8d27ff97e3e463618e793232e44e Mon Sep 17 00:00:00 2001 From: Miloslav Ciz Date: Tue, 8 Aug 2023 20:39:29 +0200 Subject: [PATCH] Start sdl --- main_sdl.c | 12 +++++++----- make.sh | 7 +++++++ settings.h | 8 ++++++++ 3 files changed, 22 insertions(+), 5 deletions(-) create mode 100755 make.sh diff --git a/main_sdl.c b/main_sdl.c index 0f37e11..a00dd50 100644 --- a/main_sdl.c +++ b/main_sdl.c @@ -1,4 +1,5 @@ #include +#include #include "game.h" #include "debug.h" @@ -19,26 +20,27 @@ int main(int argc, char *argv[]) window = SDL_CreateWindow("Licar", SDL_WINDOWPOS_UNDEFINED, - SDL_WINDOWPOS_UNDEFINED, SFG_SCREEN_RESOLUTION_X, SFG_SCREEN_RESOLUTION_Y, + SDL_WINDOWPOS_UNDEFINED, LCR_SETTING_RESOLUTION_X, LCR_SETTING_RESOLUTION_Y, SDL_WINDOW_SHOWN); renderer = SDL_CreateRenderer(window,-1,0); texture = SDL_CreateTexture(renderer,SDL_PIXELFORMAT_RGB565,SDL_TEXTUREACCESS_STATIC, - SFG_SCREEN_RESOLUTION_X,SFG_SCREEN_RESOLUTION_Y); + LCR_SETTING_RESOLUTION_X,LCR_SETTING_RESOLUTION_Y); screenSurface = SDL_GetWindowSurface(window); - sdlKeyboardState = SDL_GetKeyboardState(NULL); - //SDL_ShowCursor(0); SDL_PumpEvents(); + sdlKeyboardState = SDL_GetKeyboardState(NULL); while (running) { - running = sdlKeyboardState[SDL_SCANCODE_Q]; + SDL_PumpEvents(); + sdlKeyboardState = SDL_GetKeyboardState(NULL); + running = !sdlKeyboardState[SDL_SCANCODE_Q]; } SDL_DestroyTexture(texture); diff --git a/make.sh b/make.sh new file mode 100755 index 0000000..6d9c668 --- /dev/null +++ b/make.sh @@ -0,0 +1,7 @@ +#/bin/sh + +clear +clear + +gcc -std=c99 -Wall -Wextra -pedantic -O3 -Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers `sdl2-config --libs --static-libs` -o game main_sdl.c && ./game + diff --git a/settings.h b/settings.h index 66882c2..f112fef 100644 --- a/settings.h +++ b/settings.h @@ -1,6 +1,14 @@ #ifndef _LCR_SETTINGS_H #define _LCR_SETTINGS_H +#ifndef LCR_SETTING_RESOLUTION_X + #define LCR_SETTING_RESOLUTION_X 800 +#endif + +#ifndef LCR_SETTING_RESOLUTION_Y + #define LCR_SETTING_RESOLUTION_Y 600 +#endif + #ifndef LCR_SETTING_MAP_MAX_SIZE /** Maximum number of blocks a map can consist of, decreasing will save RAM but also rule out loading bigger maps. */