Files
Sokoban/include/function.h
2025-01-07 22:30:41 +01:00

62 lines
1.5 KiB
C

#ifndef FONCTION_H
#define FONCTION_H
#include <SDL2/SDL.h>
#include <SDL2/SDL_render.h>
#include <SDL2/SDL_video.h>
#include <stdbool.h>
#include <stdlib.h>
#include <time.h>
#define EMPTY 1
#define WALL 0
#define BOX 2
#define TARGET 3
#define BOX_ON_TARGET 4
#define PLAYER 5
#define PLAYER_ON_TARGET 6
#define BUTTON 7
#define PLAYER_ON_BUTTON 8
#define BUTTON_CUSTOM 9
typedef struct Vecteur
{
int x;
int y;
} vect;
typedef struct Score
{
time_t before;
time_t after;
unsigned int move_player;
unsigned int move_box;
} score;
typedef struct essential_sdl
{
SDL_Window *window;
SDL_Renderer *renderer;
unsigned int size_window;
unsigned int size_box;
unsigned int size_menu;
} dis;
char **creatArea2D (const int x, const int y);
void free2D (char **tab, int x);
bool isWin (char **tab2d, vect *targets, int nbr_targets);
bool islose (char **tab2d, const int N);
bool blockBox (char **tab2d, vect box_coor);
vect plusVect (vect one, vect two);
int inGameLoop (char **tab2d, vect *dim_tab, vect *playerPos, vect *targets,
int nbr_targets, dis *display_user, score *score_user, bool menu);
char *timeToText(time_t time);
void nullScore(score *player_score);
void winOrLoseLoop(dis *display_user,score *score_user, bool win);
unsigned int scoreCalculator(score *score_user, bool win);
int inEditorLoop (char **tab2d, vect *dim_tab, vect *playerPos, vect *targets,
int nbr_targets, dis *display_user,score *score_user, int num_fichier);
int titleScreen (dis *display_user);
#endif // FONCTION_H