This commit is contained in:
David Husicka 2021-12-05 15:31:33 +01:00
parent 38e0fce5ec
commit 9090a75259
4 changed files with 60 additions and 1 deletions

38
gui.c Normal file
View File

@ -0,0 +1,38 @@
#include "gui.h"
#include "SDL.h"
const SCREEN_WIDTH = 800;
const SCREEN_HEIGHT = 600;
SDL_Window* window = NULL;
SDL_Surface* screenSurface = NULL;
void gui_init() {
//Initialize SDL
if( SDL_Init( SDL_INIT_VIDEO ) < 0 )
{
printf( "SDL could not initialize! SDL_Error: %s\n", SDL_GetError() );
}
window = SDL_CreateWindow( "2048", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, SCREEN_WIDTH, SCREEN_HEIGHT, SDL_WINDOW_SHOWN );
if( window == NULL )
{
printf( "Window could not be created! SDL_Error: %s\n", SDL_GetError() );
}
}
void gui_destroy () {
//Destroy window
SDL_DestroyWindow( window );
//Quit SDL subsystems
SDL_Quit();
}
void gui_loop(Game *game) {
sleep(2000);
}

14
gui.h Normal file
View File

@ -0,0 +1,14 @@
#include <SDL.h>
#include "2048.h"
#ifndef HEADER_GUI
#define HEADER_GUI
typedef struct GUI {
} GUI;
void gui_init();
void gui_destroy();
void gui_loop(Game *game);
#endif

8
main.c
View File

@ -1,15 +1,21 @@
#include "tui.h"
#include "gui.h"
#include "2048.h"
int main(int argc, char *argv[])
{
Game game;
game = game_init(4, 4);
tui_init();
/*tui_init();
tui_loop(&game);
tui_destroy();
*/
gui_init();
gui_loop(&game);
gui_destroy();
game_destroy(game);
return 0;
}

View File

@ -6,6 +6,7 @@ ncurses = dependency('ncurses')
src_2048 = [
'2048.c',
'tui.c',
'gui.c',
'main.c',
]