|
|
@ -268,23 +268,25 @@ int find_pawn_index(Uint16 click_x, Uint16 click_y, const struct pawns_pxcoords_ |
|
|
|
return res; |
|
|
|
} |
|
|
|
|
|
|
|
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 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) { |
|
|
|
null_die(res, "ヌルポ。。。ガ! (gui_resource)"); |
|
|
|
null_die(gamestate, "ヌルポ。。。ガ! (game_state)"); |
|
|
|
null_die(move, "ヌルポ。。。ガ! (move)"); |
|
|
|
null_die(move, "ヌルポ。。。ガ! (moremoves)"); |
|
|
|
|
|
|
|
struct pawns_pxcoords_t pawns_pxcoords = calc_pawns_pxcoords( ((((double)currentplayer)-1)*M_PI)/3 ); |
|
|
|
|
|
|
|
SDL_Event event; |
|
|
|
int quit = 0; |
|
|
|
while(!quit) { |
|
|
|
//voir s'il faut dessiner le plateau, on a ptet foutu le bazar avant un continue |
|
|
|
/* (ré)affichage du plateau dans son état d'avant le mouvement */ |
|
|
|
display_render_board(res, gamestate, currentplayer); |
|
|
|
SDL_Flip(res->screen); |
|
|
|
|
|
|
|
/* attente du début de glisser-déposer */ |
|
|
|
int press = 0; |
|
|
|
while(!quit && !press) { |
|
|
|
while(SDL_WaitEvent(&event)) { |
|
|
|
SDL_Flip(res->screen); /* rafraîchir l'écran à tout événement suffit-il ? TODO poll si c'est pas suffisant et tout noir */ |
|
|
|
if(event.type == SDL_MOUSEBUTTONDOWN) { |
|
|
|
press = 1; |
|
|
|
break; |
|
|
@ -315,7 +317,6 @@ int display_usermove_pawn(const struct gui_resource_t *res, const struct game_st |
|
|
|
} |
|
|
|
} |
|
|
|
//render_board gamestate sans le pion, blit le pion par-dessus dans res->screen à la position curseur (x_mouse - w/2, y_mouse - h/2 ) // ptet seulement s'il a bougé, éco proc… (résolu par waitevent !!) |
|
|
|
SDL_Flip(res->screen); |
|
|
|
} |
|
|
|
if(quit) |
|
|
|
break; |
|
|
@ -325,7 +326,7 @@ int display_usermove_pawn(const struct gui_resource_t *res, const struct game_st |
|
|
|
if (move->startPos == -1) { |
|
|
|
// animation de retour du pion à startPos/ (au pixel, obligé) TODO |
|
|
|
continue; |
|
|
|
} else if(gamestate->board[move->endPos] != none) { |
|
|
|
} else if(gamestate->board[move->endPos] != none /**/&& move->endPos != move->startPos/* à virer si bouton fini TODO*/) { |
|
|
|
/* animation de retour */ |
|
|
|
display_animove_pawn(res, *gamestate, currentplayer, move->endPos, move->startPos); //ou au pixel TODO |
|
|
|
continue; |
|
|
@ -334,6 +335,7 @@ int display_usermove_pawn(const struct gui_resource_t *res, const struct game_st |
|
|
|
|
|
|
|
break; // rendu ici le mouvement est OK, on sort |
|
|
|
} |
|
|
|
*moremoves = (move->endPos == move->startPos); // TODO un bouton "j'ai fini" ? |
|
|
|
return quit; |
|
|
|
} |
|
|
|
|
|
|
|