Browse Source

Intégration du GUI dans le main et corrections des include pour ce faire

master
Nikos 8 years ago
parent
commit
4ca3e6f7a1
5 changed files with 19 additions and 8 deletions
  1. +2
    -2
      Makefile
  2. +1
    -0
      gui.c
  3. +0
    -4
      gui.h
  4. +1
    -0
      guidemo.c
  5. +15
    -2
      main.c

+ 2
- 2
Makefile View File

@ -9,8 +9,8 @@ all : main dummy ai guidemo
api.h : dameschinoises.h dameschinoises.patch
patch -o api.h dameschinoises.h dameschinoises.patch
main : main.o
gcc -Wall -pedantic $(LDFLAGS) -o main main.o
main : main.o gui
gcc -Wall -pedantic $(LDFLAGS) -lSDL -lSDL_image -o main main.o gui.o
main.o : main.c api.h
gcc -c -Wall main.c


+ 1
- 0
gui.c View File

@ -3,6 +3,7 @@
#include <unistd.h> /* exit */
#include <stdio.h>
#include "api.h"
#include "gui.h"
#define null_die(instruction, error) do if(!(instruction)) { fprintf(stderr, "(fatal) %s%s", error, "\n"); exit(1); } while(0)


+ 0
- 4
gui.h View File

@ -1,7 +1,3 @@
#ifndef game_state_t
#include "api.h"
#endif
struct gui_resource_t {
SDL_Surface *screen, *title_img, *bgnd_img, *board_img, *pawn_img[7];
};


+ 1
- 0
guidemo.c View File

@ -1,6 +1,7 @@
#include <stdio.h>
#include <SDL/SDL.h>
#include "api.h"
#include "gui.h"
int main(int argc, char* argv[]) {


+ 15
- 2
main.c View File

@ -5,6 +5,9 @@
#include <time.h>
#include "api.h"
#include <SDL/SDL.h>
#include "gui.h"
#define start_pos startPos
#define end_pos endPos
@ -308,12 +311,14 @@ int main(int argc, char** argv) {
puts("");
#endif
/* ouverture de la fenêtre graphique */
struct gui_resource_t gui_res = display_start(gui_res);
/* appel de start_match */
for( i=0 ; i < nb_player ; i++ )
if( player_state[i].ia_lib_p )
ia_call_function(player_state[i], ia_start_match, NULL, nb_player, i+1);
while( nb_game-- > 0 ) {
#ifdef debug
fprintf(stderr,"%d %s left\n", nb_game, nb_game>1?"games":"game");
@ -335,6 +340,10 @@ int main(int argc, char** argv) {
game_state.board[start_position[player_state[i].branch][j]] = (player_state[i].branch)+1;
}
/* rafraîchissement du plateau à l'écran */
display_render_board(gui_res, game_state);
SDL_Flip(gui_res.screen);
#ifdef debug
for(i=0;i<121; i++)
if(game_state.board[i])
@ -378,6 +387,9 @@ int main(int argc, char** argv) {
ia_call_function(player_state[i], ia_end_game, NULL);
}
}
/* le joueur a déplacé un pion, rafraîchissement du plateau à l'écran */
display_render_board(gui_res, game_state);
SDL_Flip(gui_res.screen);
} else {
#ifdef debug
fprintf(stderr, "mouvement (%d,%d) invalide\n",movement.start_pos, movement.end_pos);
@ -412,7 +424,8 @@ int main(int argc, char** argv) {
dlclose(player_state[i].ia_lib_p);
}
/* fermeture de la fenêtre graphique */
display_close(gui_res);
return 0;
}

Loading…
Cancel
Save