commencement des commentaires
This commit is contained in:
1 parent
b9838aa1b9
commit
8f470b43ef
1 file changed
+18
-8
@@ -15,6 +15,7 @@
|
||||
|
||||
/* **************************************************************** */
|
||||
|
||||
/* names of assets fichier*/
|
||||
#define LIGHTBULB_WHITE "lightbulb_white.png"
|
||||
#define LIGHTBULB_RED "lightbulb_red.png"
|
||||
#define LB1 "lb1.mp3"
|
||||
@@ -28,6 +29,7 @@
|
||||
#define MARK3 "mark3.wav"
|
||||
#define WIN "win.mp3"
|
||||
#define FONT "Roboto-Regular.ttf"
|
||||
|
||||
#define NB_MUSIC 10
|
||||
#define NB_BUTTONS 5
|
||||
#define FONTSIZE 200
|
||||
@@ -60,6 +62,7 @@ static void copy_asset(char* src, char* dst) {
|
||||
|
||||
/* **************************************************************** */
|
||||
|
||||
/* Fonction Min */
|
||||
int int_min_intero(int a, int b) {
|
||||
if (a < b)
|
||||
return a;
|
||||
@@ -78,6 +81,7 @@ bool game_has_error_general_intero(cgame g) {
|
||||
|
||||
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)
|
||||
SDL_Texture** one;
|
||||
SDL_Texture** two;
|
||||
@@ -89,18 +93,21 @@ struct Env_t {
|
||||
SDL_Texture** text_redo;
|
||||
SDL_Texture** text_solve;
|
||||
SDL_Texture** text_save; // this one have three textures one white, one black and one green
|
||||
|
||||
bool pressed_restart;
|
||||
bool pressed_undo;
|
||||
bool pressed_redo;
|
||||
bool pressed_solve;
|
||||
bool pressed_save;
|
||||
bool pressed_savED;
|
||||
|
||||
SDL_Rect* rec_game; // rectangle of the grid
|
||||
SDL_Rect* rec_redo; // rectangle of each buttons
|
||||
SDL_Rect* rec_undo;
|
||||
SDL_Rect* rec_restart;
|
||||
SDL_Rect* rec_solve;
|
||||
SDL_Rect* rec_save;
|
||||
|
||||
Mix_Music** lb_music;
|
||||
uint lb_music_cpt;
|
||||
Mix_Music** err_music;
|
||||
@@ -118,6 +125,7 @@ void usage(char* argv[]) {
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
/* Fonction for return a texture of a given text */
|
||||
SDL_Texture* render_blended_text(SDL_Renderer* ren, SDL_Color color, char* text) {
|
||||
TTF_Font* font = TTF_OpenFont(FONT, FONTSIZE); // TO EDIT !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! (ANDROID)
|
||||
if (!font)
|
||||
@@ -132,9 +140,10 @@ SDL_Texture* render_blended_text(SDL_Renderer* ren, SDL_Color color, char* text)
|
||||
return tmp;
|
||||
}
|
||||
|
||||
/* Fonction for allocating automaticly */
|
||||
void init_malloc(void** tab[], unsigned long* sizeof_tab, uint size_tab) {
|
||||
for (uint i = 0; i < size_tab; i++) {
|
||||
*(tab[i]) = malloc(sizeof_tab[i]);
|
||||
*(tab[i]) = malloc(sizeof_tab[i]); //malloc with the corressponding size
|
||||
if (*(tab[i]) == NULL)
|
||||
ERROR("%s", "Not enough memory.\n");
|
||||
}
|
||||
@@ -474,31 +483,32 @@ bool process(SDL_Window* win, Env* env, SDL_Event* e, SDL_Event* prec_e, int* nb
|
||||
if (e->type == SDL_QUIT) {
|
||||
return true;
|
||||
}
|
||||
if (e->type == SDL_KEYDOWN) {
|
||||
/*Tests of the differents types of inputs for interact with the game*/
|
||||
if (e->type == SDL_KEYDOWN) { //differents shortcuts for differents types of actions
|
||||
const Uint8* state = SDL_GetKeyboardState(NULL);
|
||||
if (state[SDL_SCANCODE_F11]) {
|
||||
if (state[SDL_SCANCODE_F11]) { //F11 forr toggle fullscreen (pretty obvious)
|
||||
ToggleFullscreen(win);
|
||||
} else if (state[SDL_SCANCODE_Z]) {
|
||||
} else if (state[SDL_SCANCODE_Z]) { //Z for undo a move only if you have done at least 1 move before
|
||||
if ((*nb_coups) > 0) {
|
||||
game_undo(env->g);
|
||||
(*nb_undo)++;
|
||||
(*nb_coups)--;
|
||||
}
|
||||
} else if (state[SDL_SCANCODE_Y]) {
|
||||
} else if (state[SDL_SCANCODE_Y]) { //Y for redo a move can only be used if u heve done one or many undo before
|
||||
if ((*nb_undo) > 0) {
|
||||
game_redo(env->g);
|
||||
(*nb_undo)--;
|
||||
(*nb_coups)++;
|
||||
}
|
||||
} else if (state[SDL_SCANCODE_S]) {
|
||||
} else if (state[SDL_SCANCODE_S]) { //S for solving the game immediatly
|
||||
game_solve(env->g);
|
||||
(*nb_undo) = 0;
|
||||
(*nb_coups)++;
|
||||
} else if (state[SDL_SCANCODE_R] || state[SDL_SCANCODE_F5]) {
|
||||
} else if (state[SDL_SCANCODE_R] || state[SDL_SCANCODE_F5]) { //R or F5 for restart the game
|
||||
game_restart(env->g);
|
||||
(*nb_undo) = 0;
|
||||
(*nb_coups) = 0;
|
||||
} else if (state[SDL_SCANCODE_W]) {
|
||||
} else if (state[SDL_SCANCODE_W]) { //W for save the game in the save.txt file
|
||||
game_save(env->g, "save.txt");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user