basics
This commit is contained in:
parent
38e0fce5ec
commit
9090a75259
|
@ -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);
|
||||
|
||||
}
|
|
@ -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
8
main.c
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ ncurses = dependency('ncurses')
|
|||
src_2048 = [
|
||||
'2048.c',
|
||||
'tui.c',
|
||||
'gui.c',
|
||||
'main.c',
|
||||
]
|
||||
|
||||
|
|
Loading…
Reference in New Issue