Start sdl

This commit is contained in:
Miloslav Ciz 2023-08-08 20:39:29 +02:00
parent 891d0f67a1
commit b542fa8cc1
3 changed files with 22 additions and 5 deletions

View file

@ -1,4 +1,5 @@
#include <stdio.h> #include <stdio.h>
#include <SDL2/SDL.h>
#include "game.h" #include "game.h"
#include "debug.h" #include "debug.h"
@ -19,26 +20,27 @@ int main(int argc, char *argv[])
window = window =
SDL_CreateWindow("Licar", SDL_WINDOWPOS_UNDEFINED, 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); SDL_WINDOW_SHOWN);
renderer = SDL_CreateRenderer(window,-1,0); renderer = SDL_CreateRenderer(window,-1,0);
texture = texture =
SDL_CreateTexture(renderer,SDL_PIXELFORMAT_RGB565,SDL_TEXTUREACCESS_STATIC, 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); screenSurface = SDL_GetWindowSurface(window);
sdlKeyboardState = SDL_GetKeyboardState(NULL);
//SDL_ShowCursor(0); //SDL_ShowCursor(0);
SDL_PumpEvents(); SDL_PumpEvents();
sdlKeyboardState = SDL_GetKeyboardState(NULL);
while (running) while (running)
{ {
running = sdlKeyboardState[SDL_SCANCODE_Q]; SDL_PumpEvents();
sdlKeyboardState = SDL_GetKeyboardState(NULL);
running = !sdlKeyboardState[SDL_SCANCODE_Q];
} }
SDL_DestroyTexture(texture); SDL_DestroyTexture(texture);

7
make.sh Executable file
View file

@ -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

View file

@ -1,6 +1,14 @@
#ifndef _LCR_SETTINGS_H #ifndef _LCR_SETTINGS_H
#define _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 #ifndef LCR_SETTING_MAP_MAX_SIZE
/** Maximum number of blocks a map can consist of, decreasing will save RAM /** Maximum number of blocks a map can consist of, decreasing will save RAM
but also rule out loading bigger maps. */ but also rule out loading bigger maps. */