Menu
This commit is contained in:
@@ -1,8 +1,9 @@
|
|||||||
|
|
||||||
CC = gcc
|
CC = gcc
|
||||||
CFLAGS = -Wall -Wextra -std=c89
|
CFLAGS = -Wall -Wextra -std=c89
|
||||||
|
LIBS = -lgraph
|
||||||
SRC_DIR = src
|
|
||||||
OBJ_DIR = obj
|
OBJ_DIR = obj
|
||||||
|
SRC_DIR = src
|
||||||
|
|
||||||
SRC = $(wildcard $(SRC_DIR)/*.c)
|
SRC = $(wildcard $(SRC_DIR)/*.c)
|
||||||
OBJ = $(SRC:$(SRC_DIR)/%.c=$(OBJ_DIR)/%.o)
|
OBJ = $(SRC:$(SRC_DIR)/%.c=$(OBJ_DIR)/%.o)
|
||||||
@@ -12,14 +13,16 @@ EXEC = taquin
|
|||||||
all: $(EXEC)
|
all: $(EXEC)
|
||||||
|
|
||||||
$(EXEC): $(OBJ)
|
$(EXEC): $(OBJ)
|
||||||
$(CC) $(CFLAGS) -o $@ $^
|
$(CC) $(CFLAGS) -o $@ $^ $(LIBS)
|
||||||
|
|
||||||
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.c
|
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.c
|
||||||
mkdir -p $(OBJ_DIR)
|
@mkdir -p $(OBJ_DIR)
|
||||||
$(CC) $(CFLAGS) -c $< -o $@
|
$(CC) $(CFLAGS) -c $< -o $@
|
||||||
|
|
||||||
run: $(EXEC)
|
run: $(EXEC)
|
||||||
./$(EXEC)
|
./$(EXEC)
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -rf $(OBJ_DIR) *.o $(EXEC)
|
rm -rf $(OBJ_DIR) $(EXEC)
|
||||||
|
|
||||||
|
.PHONY : all clean run
|
||||||
|
|||||||
-115
@@ -1,115 +0,0 @@
|
|||||||
#include "game.h"
|
|
||||||
#include "utils.h"
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
static void index_to_coords(int index, int cols, int *r, int *c)
|
|
||||||
{
|
|
||||||
*r = index / cols;
|
|
||||||
*c = index % cols;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int game_can_move(const game_state_t *state, int index_to_move)
|
|
||||||
{
|
|
||||||
int r_tile, c_tile;
|
|
||||||
int r_empty, c_empty;
|
|
||||||
int num_tiles = state->rows * state->cols;
|
|
||||||
|
|
||||||
if (index_to_move < 0 || index_to_move >= num_tiles) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (state->permutation[index_to_move] == -1) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
index_to_coords(index_to_move, state->cols, &r_tile, &c_tile);
|
|
||||||
index_to_coords(state->empty_index, state->cols, &r_empty, &c_empty);
|
|
||||||
|
|
||||||
if (abs_val(r_tile - r_empty) + abs_val(c_tile - c_empty) == 1) {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void game_init(game_state_t *state, int rows, int cols, tile_t **tiles)
|
|
||||||
{
|
|
||||||
int num_tiles = rows * cols;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
state->rows = rows;
|
|
||||||
state->cols = cols;
|
|
||||||
state->moves = 0UL;
|
|
||||||
state->is_solved = 1; /
|
|
||||||
state->all_tiles = tiles;
|
|
||||||
|
|
||||||
state->permutation = (int *)malloc(num_tiles * sizeof(int));
|
|
||||||
if (state->permutation == NULL) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0; i < num_tiles - 1; i++) {
|
|
||||||
state->permutation[i] = i;
|
|
||||||
}
|
|
||||||
|
|
||||||
state->permutation[num_tiles - 1] = -1;
|
|
||||||
state->empty_index = num_tiles - 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
void game_free(game_state_t *state)
|
|
||||||
{
|
|
||||||
if (state->permutation != NULL) {
|
|
||||||
free(state->permutation);
|
|
||||||
state->permutation = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int game_move_tile(game_state_t *state, int index_to_move)
|
|
||||||
{
|
|
||||||
int temp_tile_id;
|
|
||||||
|
|
||||||
if (!game_can_move(state, index_to_move)) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
temp_tile_id = state->permutation[index_to_move];
|
|
||||||
state->permutation[index_to_move] = state->permutation[state->empty_index];
|
|
||||||
state->permutation[state->empty_index] = temp_tile_id;
|
|
||||||
|
|
||||||
state->empty_index = index_to_move;
|
|
||||||
|
|
||||||
state->moves++;
|
|
||||||
state->is_solved = game_is_solved(state);
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int game_is_solved(const game_state_t *state)
|
|
||||||
{
|
|
||||||
int num_tiles = state->rows * state->cols;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
for (i = 0; i < num_tiles - 1; i++) {
|
|
||||||
if (state->permutation[i] != i) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (state->permutation[num_tiles - 1] != -1) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 1; /
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void game_shuffle_safe(game_state_t *state, int steps)
|
|
||||||
{
|
|
||||||
(void)state;
|
|
||||||
(void)steps;
|
|
||||||
}
|
|
||||||
-32
@@ -1,32 +0,0 @@
|
|||||||
#ifndef GAME_H
|
|
||||||
#define GAME_H
|
|
||||||
|
|
||||||
#include
|
|
||||||
#include
|
|
||||||
|
|
||||||
#define MAX_SIZE 8
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
int rows;
|
|
||||||
int cols;
|
|
||||||
|
|
||||||
int *permutation;
|
|
||||||
|
|
||||||
int empty_index;
|
|
||||||
unsigned long moves;
|
|
||||||
int is_solved;
|
|
||||||
|
|
||||||
tile_t **all_tiles;
|
|
||||||
} game_state_t;
|
|
||||||
|
|
||||||
void game_init(game_state_t *state, int rows, int cols, tile_t **tiles);
|
|
||||||
|
|
||||||
void game_free(game_state_t *state);
|
|
||||||
|
|
||||||
int game_move_tile(game_state_t *state, int index_to_move);
|
|
||||||
|
|
||||||
int game_is_solved(const game_state_t *state);
|
|
||||||
|
|
||||||
void game_shuffle_safe(game_state_t *state, int steps);
|
|
||||||
|
|
||||||
#endif /* GAME_H */
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
#include "game_view.h"
|
|
||||||
|
|
||||||
|
|
||||||
void render_game(const struct GameState* state)
|
|
||||||
|
|
||||||
{
|
|
||||||
|
|
||||||
/* TODO : dessiner les tuiles */
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,54 +0,0 @@
|
|||||||
Baptiste LECOINTRE <baptou.lecointre@gmail.com>
|
|
||||||
|
|
||||||
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
|
|
||||||
-180
@@ -1,180 +0,0 @@
|
|||||||
Baptiste LECOINTRE <baptou.lecointre@gmail.com>
|
|
||||||
|
|
||||||
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 */
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
#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
|
|
||||||
-153
@@ -1,153 +0,0 @@
|
|||||||
Baptiste LECOINTRE <baptou.lecointre@gmail.com>
|
|
||||||
|
|
||||||
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 */
|
|
||||||
|
|
||||||
}
|
|
||||||
-18
@@ -1,18 +0,0 @@
|
|||||||
|
|
||||||
|
|
||||||
#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
|
|
||||||
-23
@@ -1,23 +0,0 @@
|
|||||||
#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;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,30 +0,0 @@
|
|||||||
|
|
||||||
|
|
||||||
#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 */
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,28 +0,0 @@
|
|||||||
|
|
||||||
|
|
||||||
#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
|
|
||||||
|
|||||||
-207
@@ -1,207 +0,0 @@
|
|||||||
Baptiste LECOINTRE <baptou.lecointre@gmail.com>
|
|
||||||
|
|
||||||
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;
|
|
||||||
|
|
||||||
}
|
|
||||||
-13
@@ -1,13 +0,0 @@
|
|||||||
|
|
||||||
|
|
||||||
#ifndef UTILS_H
|
|
||||||
|
|
||||||
#define UTILS_H
|
|
||||||
|
|
||||||
|
|
||||||
int random_int(int max);
|
|
||||||
|
|
||||||
void swap(int* a, int* b);
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|||||||
Reference in New Issue
Block a user