From 553532c887c668357040234eebf2bf731f9d1182 Mon Sep 17 00:00:00 2001 From: lecointre Date: Tue, 25 Nov 2025 13:12:45 +0100 Subject: [PATCH] =?UTF-8?q?D=C3=A9but=20de=20la=20sae=C3=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/game.c | 50 ++++++++++++ src/game.c~ | 21 +++++ src/game.h | 34 ++++++++ src/game_view.c | 14 ++++ src/game_view.h | 54 +++++++++++++ src/images.c | 180 +++++++++++++++++++++++++++++++++++++++++ src/images.h | 24 ++++++ src/images.h~ | 24 ++++++ src/input.c | 153 +++++++++++++++++++++++++++++++++++ src/input.h | 18 +++++ src/main.c | 23 ++++++ src/menu_view.c | 30 +++++++ src/menu_view.h | 28 +++++++ src/utils.c | 207 ++++++++++++++++++++++++++++++++++++++++++++++++ src/utils.h | 13 +++ 15 files changed, 873 insertions(+) create mode 100644 src/game.c~ create mode 100644 src/images.h~ diff --git a/src/game.c b/src/game.c index e69de29..b6e2790 100644 --- a/src/game.c +++ b/src/game.c @@ -0,0 +1,50 @@ +#include "game.h" + + +void game_init(struct GameState* state, int rows, int cols) + +{ + + /* TODO */ + +} + + +void game_move(struct GameState* state, int tile) + +{ + + /* TODO */ + +} + + +int game_can_move(const struct GameState* state, int tile) + +{ + + /* TODO */ + + return 0; + +} + + +int game_is_solved(const struct GameState* state) + +{ + + /* TODO */ + + return 0; + +} + + +void game_shuffle(struct GameState* state) + +{ + + /* TODO */ + +} diff --git a/src/game.c~ b/src/game.c~ new file mode 100644 index 0000000..7f8b3b7 --- /dev/null +++ b/src/game.c~ @@ -0,0 +1,21 @@ +#include "game.h" + +#include "game_view.h" + +#include "menu_view.h" + +#include "input.h" + + +int main(void) + +{ + + /* TODO : initialiser la bibliothèque graphique */ + + /* TODO : boucle principale */ + + + return 0; + +} diff --git a/src/game.h b/src/game.h index e69de29..66d0d5a 100644 --- a/src/game.h +++ b/src/game.h @@ -0,0 +1,34 @@ +#ifndef GAME_H + +#define GAME_H + + +struct GameState { + + int rows; + + int cols; + + int empty_index; + + int moves; + + int is_over; + + int *permutation; + +}; + + +void game_init(struct GameState* state, int rows, int cols); + +void game_move(struct GameState* state, int tile); + +int game_can_move(const struct GameState* state, int tile); + +int game_is_solved(const struct GameState* state); + +void game_shuffle(struct GameState* state); + + +#endif diff --git a/src/game_view.c b/src/game_view.c index e69de29..dee2638 100644 --- a/src/game_view.c +++ b/src/game_view.c @@ -0,0 +1,14 @@ +#include "game_view.h" + + +void render_game(const struct GameState* state) + +{ + + /* TODO : dessiner les tuiles */ + +} + + + + diff --git a/src/game_view.h b/src/game_view.h index e69de29..2c52bfa 100644 --- a/src/game_view.h +++ b/src/game_view.h @@ -0,0 +1,54 @@ +Baptiste LECOINTRE + +12:59 (il y a 0 minute) + + +À moi + +#ifndef GAME_H + +#define GAME_H + + +struct GameState { + + int rows; + + int cols; + + int empty_index; + + int moves; + + int is_over; + + int *permutation; + +}; + + +void game_init(struct GameState* state, int rows, int cols); + +void game_move(struct GameState* state, int tile); + +int game_can_move(const struct GameState* state, int tile); + +int game_is_solved(const struct GameState* state); + +void game_shuffle(struct GameState* state); + + +#endif + +#ifndef GAME_VIEW_H + +#define GAME_VIEW_H + + +#include "game.h" + + +void render_game(const struct GameState* state); + + +#endif diff --git a/src/images.c b/src/images.c index e69de29..56a5b70 100644 --- a/src/images.c +++ b/src/images.c @@ -0,0 +1,180 @@ +Baptiste LECOINTRE + +13:01 (il y a 3 minutes) + + +À moi +Ce message semble être en anglais + +#include "game.h" + +#include "game_view.h" + +#include "menu_view.h" + +#include "input.h" + + +int main(void) + +{ + + /* TODO : initialiser la bibliothèque graphique */ + + /* TODO : boucle principale */ + + + return 0; + +} + + + + +#include "game.h" + + +void game_init(struct GameState* state, int rows, int cols) + +{ + + /* TODO */ + +} + + +void game_move(struct GameState* state, int tile) + +{ + + /* TODO */ + +} + + +int game_can_move(const struct GameState* state, int tile) + +{ + + /* TODO */ + + return 0; + +} + + +int game_is_solved(const struct GameState* state) + +{ + + /* TODO */ + + return 0; + +} + + +void game_shuffle(struct GameState* state) + +{ + + /* TODO */ + +} + + + + + +#include "game_view.h" + + +void render_game(const struct GameState* state) + +{ + + /* TODO : dessiner les tuiles */ + +} + + + + +#include "menu_view.h" + + +void render_menu(const struct MenuState* menu) + +{ + + /* TODO */ + +} + + +void menu_handle_mouse(struct MenuState* menu, int x, int y) + +{ + + /* TODO */ + +} + + +void menu_handle_key(struct MenuState* menu, int key) + +{ + + /* TODO */ + +} + + + + +#include "input.h" + + +void input_handle_mouse_game(struct GameState* state, int x, int y) + +{ + + /* TODO */ + +} + + +void input_handle_key_game(struct GameState* state, int key) + +{ + + /* TODO */ + +} + + + + +#include "images.h" + + +Image load_image(const char* path) + +{ + + Image img; + + /* TODO */ + + return img; + +} + + +void slice_image_into_tiles(const Image img, int rows, int cols) + +{ + + /* TODO */ + +} diff --git a/src/images.h b/src/images.h index e69de29..22a3e05 100644 --- a/src/images.h +++ b/src/images.h @@ -0,0 +1,24 @@ +#ifndef IMAGES_H + +#define IMAGES_H + + +typedef struct { + + /* dépend de la bibliothèque de l’IUT */ + + int width; + + int height; + + void* data; + +} Image; + + +Image load_image(const char* path); + +void slice_image_into_tiles(const Image img, int rows, int cols); + + +#endif diff --git a/src/images.h~ b/src/images.h~ new file mode 100644 index 0000000..f120ef9 --- /dev/null +++ b/src/images.h~ @@ -0,0 +1,24 @@ +ifndef IMAGES_H + +#define IMAGES_H + + +typedef struct { + + /* dépend de la bibliothèque de l’IUT */ + + int width; + + int height; + + void* data; + +} Image; + + +Image load_image(const char* path); + +void slice_image_into_tiles(const Image img, int rows, int cols); + + +#endif diff --git a/src/input.c b/src/input.c index e69de29..565476a 100644 --- a/src/input.c +++ b/src/input.c @@ -0,0 +1,153 @@ +Baptiste LECOINTRE + +13:01 (il y a 3 minutes) + + +À moi +Ce message semble être en anglais + +#include "game.h" + +#include "game_view.h" + +#include "menu_view.h" + +#include "input.h" + + +int main(void) + +{ + + /* TODO : initialiser la bibliothèque graphique */ + + /* TODO : boucle principale */ + + + return 0; + +} + + + + +#include "game.h" + + +void game_init(struct GameState* state, int rows, int cols) + +{ + + /* TODO */ + +} + + +void game_move(struct GameState* state, int tile) + +{ + + /* TODO */ + +} + + +int game_can_move(const struct GameState* state, int tile) + +{ + + /* TODO */ + + return 0; + +} + + +int game_is_solved(const struct GameState* state) + +{ + + /* TODO */ + + return 0; + +} + + +void game_shuffle(struct GameState* state) + +{ + + /* TODO */ + +} + + + + + +#include "game_view.h" + + +void render_game(const struct GameState* state) + +{ + + /* TODO : dessiner les tuiles */ + +} + + + + +#include "menu_view.h" + + +void render_menu(const struct MenuState* menu) + +{ + + /* TODO */ + +} + + +void menu_handle_mouse(struct MenuState* menu, int x, int y) + +{ + + /* TODO */ + +} + + +void menu_handle_key(struct MenuState* menu, int key) + +{ + + /* TODO */ + +} + + + + +#include "input.h" + + +void input_handle_mouse_game(struct GameState* state, int x, int y) + +{ + + /* TODO */ + +} + + +void input_handle_key_game(struct GameState* state, int key) + +{ + + /* TODO */ + +} diff --git a/src/input.h b/src/input.h index e69de29..cafd159 100644 --- a/src/input.h +++ b/src/input.h @@ -0,0 +1,18 @@ + + +#ifndef INPUT_H + +#define INPUT_H + + +#include "game.h" + +#include "menu_view.h" + + +void input_handle_mouse_game(struct GameState* state, int x, int y); + +void input_handle_key_game(struct GameState* state, int key); + + +#endif diff --git a/src/main.c b/src/main.c index e69de29..8f59677 100644 --- a/src/main.c +++ b/src/main.c @@ -0,0 +1,23 @@ +#include "game.h" + +#include "game_view.h" + +#include "menu_view.h" + +#include "input.h" + + +int main(void) + +{ + + /* TODO : initialiser la bibliothèque graphique */ + + /* TODO : boucle principale */ + + + return 0; + +} + + diff --git a/src/menu_view.c b/src/menu_view.c index e69de29..8add763 100644 --- a/src/menu_view.c +++ b/src/menu_view.c @@ -0,0 +1,30 @@ + + +#include "menu_view.h" + + +void render_menu(const struct MenuState* menu) + +{ + + /* TODO */ + +} + + +void menu_handle_mouse(struct MenuState* menu, int x, int y) + +{ + + /* TODO */ + +} + + +void menu_handle_key(struct MenuState* menu, int key) + +{ + + /* TODO */ + +} diff --git a/src/menu_view.h b/src/menu_view.h index e69de29..52a0bbe 100644 --- a/src/menu_view.h +++ b/src/menu_view.h @@ -0,0 +1,28 @@ + + +#ifndef MENU_VIEW_H + +#define MENU_VIEW_H + + +struct MenuState { + + int selected_image; + + int rows; + + int cols; + + int ready; + +}; + + +void render_menu(const struct MenuState* menu); + +void menu_handle_mouse(struct MenuState* menu, int x, int y); + +void menu_handle_key(struct MenuState* menu, int key); + + +#endif diff --git a/src/utils.c b/src/utils.c index e69de29..ec22ad0 100644 --- a/src/utils.c +++ b/src/utils.c @@ -0,0 +1,207 @@ +Baptiste LECOINTRE + +13:01 (il y a 4 minutes) + + +À moi +Ce message semble être en anglais + +#include "game.h" + +#include "game_view.h" + +#include "menu_view.h" + +#include "input.h" + + +int main(void) + +{ + + /* TODO : initialiser la bibliothèque graphique */ + + /* TODO : boucle principale */ + + + return 0; + +} + + + + +#include "game.h" + + +void game_init(struct GameState* state, int rows, int cols) + +{ + + /* TODO */ + +} + + +void game_move(struct GameState* state, int tile) + +{ + + /* TODO */ + +} + + +int game_can_move(const struct GameState* state, int tile) + +{ + + /* TODO */ + + return 0; + +} + + +int game_is_solved(const struct GameState* state) + +{ + + /* TODO */ + + return 0; + +} + + +void game_shuffle(struct GameState* state) + +{ + + /* TODO */ + +} + + + + + +#include "game_view.h" + + +void render_game(const struct GameState* state) + +{ + + /* TODO : dessiner les tuiles */ + +} + + + + +#include "menu_view.h" + + +void render_menu(const struct MenuState* menu) + +{ + + /* TODO */ + +} + + +void menu_handle_mouse(struct MenuState* menu, int x, int y) + +{ + + /* TODO */ + +} + + +void menu_handle_key(struct MenuState* menu, int key) + +{ + + /* TODO */ + +} + + + + +#include "input.h" + + +void input_handle_mouse_game(struct GameState* state, int x, int y) + +{ + + /* TODO */ + +} + + +void input_handle_key_game(struct GameState* state, int key) + +{ + + /* TODO */ + +} + + + + +#include "images.h" + + +Image load_image(const char* path) + +{ + + Image img; + + /* TODO */ + + return img; + +} + + +void slice_image_into_tiles(const Image img, int rows, int cols) + +{ + + /* TODO */ + +} + + + + +#include "utils.h" + + +int random_int(int max) + +{ + + return rand() % max; + +} + + +void swap(int* a, int* b) + +{ + + int tmp = *a; + + *a = *b; + + *b = tmp; + +} diff --git a/src/utils.h b/src/utils.h index e69de29..72058a0 100644 --- a/src/utils.h +++ b/src/utils.h @@ -0,0 +1,13 @@ + + +#ifndef UTILS_H + +#define UTILS_H + + +int random_int(int max); + +void swap(int* a, int* b); + + +#endif