From d763abfc80405ff729204052114e6790dbda61fe Mon Sep 17 00:00:00 2001 From: klmp200 Date: Sun, 1 Jan 2017 16:43:40 +0100 Subject: [PATCH] Renommage complet des fonctions --- LibGui/gui.c | 30 ++++++------- LibGui/gui.h | 16 +++---- LibMatrix/matrix.c | 103 ++++++++++++++++++++++----------------------- LibMatrix/matrix.h | 34 +++++++-------- matrixmain.c | 22 +++++----- report.md | 2 +- 6 files changed, 103 insertions(+), 104 deletions(-) diff --git a/LibGui/gui.c b/LibGui/gui.c index 2071b66..b3bc2dc 100644 --- a/LibGui/gui.c +++ b/LibGui/gui.c @@ -27,7 +27,7 @@ #include #include -void SetPixel(SDL_Renderer *renderer, int x, int y, bool value){ +void setPixel(SDL_Renderer *renderer, int x, int y, bool value){ if (value){ SDL_SetRenderDrawColor(renderer, 255, 255, 255, 255); @@ -37,7 +37,7 @@ void SetPixel(SDL_Renderer *renderer, int x, int y, bool value){ SDL_RenderDrawPoint(renderer, x, y); } -void DisplayMatrixSDL(SCREEN *screen, Matrix m){ +void displayMatrixSDL(SCREEN *screen, Matrix m){ int i; int j; @@ -46,13 +46,13 @@ void DisplayMatrixSDL(SCREEN *screen, Matrix m){ for (i=0;irenderer, i, j, GetCellValue(m, j, i)); + setPixel(screen->renderer, i, j, getCellValue(m, j, i)); } } SDL_RenderPresent(screen->renderer); } -void WaitUntilEnter(SCREEN * screen){ +void waitUntilEnter(SCREEN * screen){ int keypress = 0; while (!keypress){ @@ -72,7 +72,7 @@ void WaitUntilEnter(SCREEN * screen){ } } -int NewWindowFromMatrix(Matrix m){ +int newWindowFromMatrix(Matrix m){ SCREEN screen; screen.WIDTH = m.colCount; @@ -92,9 +92,9 @@ int NewWindowFromMatrix(Matrix m){ return 1; } - DisplayMatrixSDL(&screen, m); + displayMatrixSDL(&screen, m); - WaitUntilEnter(&screen); + waitUntilEnter(&screen); SDL_DestroyRenderer(screen.renderer); SDL_DestroyWindow(screen.window); @@ -104,12 +104,12 @@ int NewWindowFromMatrix(Matrix m){ return 0; } -bool YesOrNo(char message[]){ +bool inputYesOrNo(char message[]){ char response; printf("%s (Y/n)\n", message); response = getchar(); - ClearBuffer(); + clearBuffer(); if (response == 'n'){ return false; @@ -119,33 +119,33 @@ bool YesOrNo(char message[]){ } -void ClearBuffer(){ +void clearBuffer(){ char c; while ((c = getchar()) != '\n' && c != EOF) { } } -void DisplayMatrixGUI(Matrix m, bool useSDL){ +void displayMatrixGUI(Matrix m, bool useSDL){ if (useSDL){ printf("Press ENTER or the red cross to exit the window and continue.\n"); - NewWindowFromMatrix(m); + newWindowFromMatrix(m); } else { printMatrix(m); } } -int SafeNumberInput(int min, int max){ +int safeNumberInput(int min, int max){ char str[30]; int input; fgets(str, 29, stdin); - ClearBuffer(); + clearBuffer(); input = atoi(str); while (input < min || input > max){ printf("The number should be between %d and %d\n", min, max); fgets(str, 29, stdin); - ClearBuffer(); + clearBuffer(); input = atoi(str); } diff --git a/LibGui/gui.h b/LibGui/gui.h index c3c7e99..d0e6c34 100644 --- a/LibGui/gui.h +++ b/LibGui/gui.h @@ -41,7 +41,7 @@ typedef struct { * @param value display white if true and black if false * @return */ -void SetPixel(SDL_Renderer *renderer, int x, int y, bool value); +void setPixel(SDL_Renderer *renderer, int x, int y, bool value); /** * Display an entire matrix on a given screen @@ -49,28 +49,28 @@ void SetPixel(SDL_Renderer *renderer, int x, int y, bool value); * @param m a Matrix * @return */ -void DisplayMatrixSDL(SCREEN *screen, Matrix m); +void displayMatrixSDL(SCREEN *screen, Matrix m); /** * Wait until the user press the enter key * @param screen the screen where the renderer is * @return */ -void WaitUntilEnter(SCREEN * screen); +void waitUntilEnter(SCREEN * screen); /** * Print a matrix in a new SDL window * @param Matrix the matrix to display * @return int error code */ -int NewWindowFromMatrix(Matrix m); +int newWindowFromMatrix(Matrix m); /** * Display a message and ask for yes or no to the user * @param message the message to display * @return bool the answer */ -bool YesOrNo(char message[]); +bool inputYesOrNo(char message[]); /** * Display matrix choosing the right function @@ -78,7 +78,7 @@ bool YesOrNo(char message[]); * @param useSDL a bool * @return */ -void DisplayMatrixGUI(Matrix m, bool useSDL); +void displayMatrixGUI(Matrix m, bool useSDL); /** * Get a number from the user safely @@ -86,12 +86,12 @@ void DisplayMatrixGUI(Matrix m, bool useSDL); * @param max the maximal authorized number * @return int the input number */ -int SafeNumberInput(int min, int max); +int safeNumberInput(int min, int max); /** * Clears the buffer of stdin * @return */ -void ClearBuffer(); +void clearBuffer(); #endif diff --git a/LibMatrix/matrix.c b/LibMatrix/matrix.c index e6ed707..36d47f2 100644 --- a/LibMatrix/matrix.c +++ b/LibMatrix/matrix.c @@ -51,7 +51,6 @@ Matrix applyRules (Matrix matrix,int Rules, int N){ tempMatrix1 = matrixFromRules(matrix, i, RulesMatrix); for (j=1;j= 0 ){ + if ( deleteMatrixElem(matrix,ColPos,RowPos) >= 0 ){ return true; }else{ return false; @@ -275,7 +274,7 @@ void printMatrix(Matrix matrix){ printf("| "); for (j=0;j