Browse Source

Merge branch 'master' of ssh://ssh.confais.org/git/dames_chinoises

master
Bastien 8 years ago
committed by Squiz
parent
commit
af360e2dd6
3 changed files with 6 additions and 31 deletions
  1. +0
    -26
      gui.c
  2. +5
    -4
      gui.h
  3. +1
    -1
      guidemo.c

+ 0
- 26
gui.c View File

@ -55,32 +55,6 @@ struct gui_resource_t display_start() {
return res;
}
SDL_Event display_until_event(const struct gui_resource_t *res) {
null_die(res, "ヌルポ。。。ガ! (gui_resource)");
#define FIXEDFRAMETIME 125 /* 125ms → 8fps */
SDL_Event event;
uint32_t time1, time2; /* mesure du temps de rendu de frame */
for(;;) {
time1 = SDL_GetTicks();
if(SDL_PollEvent(&event))
break;
SDL_Flip(res->screen);
/* attente du temps restant dans la frame */
time2 = SDL_GetTicks();
if(time2-time1 < FIXEDFRAMETIME)
SDL_Delay(FIXEDFRAMETIME - (time2-time1));
#ifdef rant
else
fprintf(stderr,"(rant) fixed image: the machine is slow, frame took %dms\n", time2-time1);
#endif
}
return event;
}
SDL_Rect coord_rotate(SDL_Rect coord, double sin, double cos) {
SDL_Rect res;
res.x = (short)round( cos * ((double)coord.x) + sin * ((double)coord.y) );


+ 5
- 4
gui.h View File

@ -5,14 +5,17 @@ struct gui_resource_t {
TTF_Font *font_big, *font_small;
};
/* ouvre la fenêtre */
struct gui_resource_t display_start();
SDL_Event display_until_event(const struct gui_resource_t *res);
/* ferme la fenêtre */
void display_close(struct gui_resource_t *res);
/* simple rendu interne du plateau, il faut SDL_Flip() pour l'afficher */
void display_render_board(const struct gui_resource_t *res, const struct game_state_t *gamestate, enum hole_t currentplayer);
/* les fonctions display_ani* retournent 1 si l'utilisateur ferme l'application, sinon 0 */
/* les fonctions suivantes retournent 1 si l'utilisateur ferme l'application, sinon 0 */
int display_animsg(const struct gui_resource_t *res, const struct game_state_t *gamestate, enum hole_t currentplayer, const char *msg, uint32_t duration);
@ -21,5 +24,3 @@ int display_anirotate_board(const struct gui_resource_t *res, const struct game_
int display_animove_pawn(const struct gui_resource_t *res, struct game_state_t gamestate, enum hole_t currentplayer, int startpos, int endpos);
int display_usermove_pawn(const struct gui_resource_t *res, const struct game_state_t *gamestate, enum hole_t currentplayer, struct move_t *move, int *moremoves);
void display_close(struct gui_resource_t *res);

+ 1
- 1
guidemo.c View File

@ -42,7 +42,7 @@ int main(void) {
quit = 1;
while(!quit) {
event = display_until_event(&gui_res);
SDL_WaitEvent(&event);
if(event.type == SDL_QUIT) {
quit = 1;


Loading…
Cancel
Save