clang de con

This commit is contained in:
valentin carmona committed 2022-03-17 14:38:23 +01:00
1 parent 3c5a3c0383
commit 9a439ac591
1 file changed
+36 -35
+36 -35
View File
@@ -26,7 +26,6 @@
/* **************************************************************** */
struct Env_t {
game g;
SDL_Texture** zero; // array of two texture one white and one red for each number (red color = r:255 g:50 b:50)
@@ -39,13 +38,13 @@ struct Env_t {
SDL_Texture* text_undo;
SDL_Texture* text_redo;
SDL_Texture* text_solve;
SDL_Rect* rec_redo; //rectangle of each buttons
SDL_Rect* rec_redo; // rectangle of each buttons
SDL_Rect* rec_undo;
SDL_Rect* rec_restart;
SDL_Rect* rec_solve;
SDL_Rect* rec_game; //rectangle of the grid
SDL_Rect** tab_rec_game; //array of rectangles containing each square of the grid
uint size_game; //contain the number of squares in the game
SDL_Rect* rec_game; // rectangle of the grid
SDL_Rect** tab_rec_game; // array of rectangles containing each square of the grid
uint size_game; // contain the number of squares in the game
};
/* **************************************************************** */
@@ -185,53 +184,55 @@ bool process(SDL_Window* win, SDL_Renderer* ren, Env* env, SDL_Event* e) {
} else if (e->type == SDL_MOUSEMOTION) {
SDL_Point mouse;
SDL_GetMouseState(&mouse.x, &mouse.y);
if(SDL_PointInRect(mouse, env->rec_restart)){
if (SDL_PointInRect(mouse, env->rec_restart)) {
env->text_restart = IMG_LoadTexture(ren, RESTART_DOWN);
if (!env->text_restart) ERROR("IMG_LoadTexture: %s\n", RESTART_DOWN);
}
else if(SDL_PointInRect(mouse, env->rec_undo)){
if (!env->text_restart)
ERROR("IMG_LoadTexture: %s\n", RESTART_DOWN);
} else if (SDL_PointInRect(mouse, env->rec_undo)) {
env->text_undo = IMG_LoadTexture(ren, UNDO_DOWN);
if (!env->text_undo) ERROR("IMG_LoadTexture: %s\n", UNDO_DOWN);
}
else if(SDL_PointInRect(mouse, env->rec_redo)){
if (!env->text_undo)
ERROR("IMG_LoadTexture: %s\n", UNDO_DOWN);
} else if (SDL_PointInRect(mouse, env->rec_redo)) {
env->text_redo = IMG_LoadTexture(ren, REDO_DOWN);
if (!env->text_redo) ERROR("IMG_LoadTexture: %s\n", REDO_DOWN);
}
else if(SDL_PointInRect(mouse, env->rec_sove)){
if (!env->text_redo)
ERROR("IMG_LoadTexture: %s\n", REDO_DOWN);
} else if (SDL_PointInRect(mouse, env->rec_sove)) {
env->text_solve = IMG_LoadTexture(ren, SOLVE_DOWN);
if (!env->text_solve) ERROR("IMG_LoadTexture: %s\n", SOLVE_DOWN);
}else{
if (!env->text_solve)
ERROR("IMG_LoadTexture: %s\n", SOLVE_DOWN);
} else {
env->text_restart = IMG_LoadTexture(ren, RESTART_UP);
if (!env->text_restart) ERROR("IMG_LoadTexture: %s\n", RESTART_UP);
if (!env->text_restart)
ERROR("IMG_LoadTexture: %s\n", RESTART_UP);
env->text_undo = IMG_LoadTexture(ren, UNDO_UP);
if (!env->text_undo) ERROR("IMG_LoadTexture: %s\n", UNDO_UP);
if (!env->text_undo)
ERROR("IMG_LoadTexture: %s\n", UNDO_UP);
env->text_redo = IMG_LoadTexture(ren, REDO_UP);
if (!env->text_redo) ERROR("IMG_LoadTexture: %s\n", REDO_UP);
if (!env->text_redo)
ERROR("IMG_LoadTexture: %s\n", REDO_UP);
env->text_solve = IMG_LoadTexture(ren, SOLVE_UP);
if (!env->text_solve) ERROR("IMG_LoadTexture: %s\n", SOLVE_UP);
if (!env->text_solve)
ERROR("IMG_LoadTexture: %s\n", SOLVE_UP);
}
} else if (e->type == SDL_MOUSEBUTTONDOWN) {
SDL_Point mouse;
SDL_GetMouseState(&mouse.x, &mouse.y);
if(SDL_PointInRect(mouse, env->rec_restart)){
if (SDL_PointInRect(mouse, env->rec_restart)) {
game_restart(env->g);
}
else if(SDL_PointInRect(mouse, env->rec_undo)){
} else if (SDL_PointInRect(mouse, env->rec_undo)) {
game_undo(env->g);
}
else if(SDL_PointInRect(mouse, env->rec_redo)){
} else if (SDL_PointInRect(mouse, env->rec_redo)) {
game_redo(env->g);
}
else if(SDL_PointInRect(mouse, env->rec_sove)){
} else if (SDL_PointInRect(mouse, env->rec_sove)) {
game_solve(env->g);
}else if (SDL_PointInRect(mouse, env->rec_game)){
for(uint ind = 0; i < env->size; ind++){
uint i = ind%(env->g->height);
uint j = ind/(env->g->width);
if(SDL_PointInRect(mouse, env->tab_rec_game[ind])){
if(game_is_blank(env->g, i, j)){
} else if (SDL_PointInRect(mouse, env->rec_game)) {
for (uint ind = 0; i < env->size; ind++) {
uint i = ind % (env->g->height);
uint j = ind / (env->g->width);
if (SDL_PointInRect(mouse, env->tab_rec_game[ind])) {
if (game_is_blank(env->g, i, j)) {
game_play_move(env->g, i, j, S_LIGHTBULB);
}else if(game_is_lightbulb(env->g, i, j)){
} else if (game_is_lightbulb(env->g, i, j)) {
game_play_move(env->g, i, j, S_BLANK);
}
}