Skip to content
Snippets Groups Projects
Commit 07068bb0 authored by vautrin33u's avatar vautrin33u
Browse files

Erreur désallocation

parent 25ad633c
Branches
No related tags found
No related merge requests found
Source diff could not be displayed: it is too large. Options to address this: view the blob.
......@@ -12,12 +12,12 @@
/**
* \brief Largeur de l'écran
*/
#define SCREEN_WIDTH 800
#define SCREEN_WIDTH 80
/**
* \brief Hauteur de l'écran
*/
#define SCREEN_HEIGHT 600
#define SCREEN_HEIGHT 60
/**
* \brief Titre
......
......@@ -70,7 +70,7 @@ char** lire_fichier (const char* nomFichier){ //malfonctionne
int ligne = 0;
int colonne = 0;
taille_fichier(nomFichier, &ligne, &colonne);
printf("\n Taille ligne: %d | colonne : %d \n", ligne, colonne);
//printf("\n Taille ligne: %d | colonne : %d \n", ligne, colonne);
char** tab = allouer_tab_2D(colonne, ligne);//inversion ligne
for (int i=0; i<ligne; i++){
......
......@@ -17,11 +17,10 @@ void init_data(world_t * world){ //faux
world->attente = 0;
//Initialise le sprite du joueur en haut à gauche de l'écran, en état 0
//init_sprite(&world->joueur, SCREEN_WIDTH*0.1, SCREEN_HEIGHT*0.1, SIZE_JOUEUR, SIZE_JOUEUR, SIZE_JOUEUR/2, 0);
init_sprite(&world->joueur, 'J', SCREEN_WIDTH*0.1, SCREEN_HEIGHT*0.1, SIZE_JOUEUR, SIZE_JOUEUR, SIZE_JOUEUR/2, 0);
//Charge la carte
world->level = init_map();
world-> map = world->level;
world->map = init_map();
/*
......@@ -143,7 +142,6 @@ void deplace_sprite (sprite_t *sprite, world_t *world){
switch (return_state(sprite)){
case 0:
//déplace vers le bas
sprite->y += sprite->v;
if (world->map[sprite->y + SIZE_JOUEUR][sprite->x] != ' ' || world->map[sprite->y + SIZE_JOUEUR][sprite->x + SIZE_JOUEUR] != ' '){
//Compter le nombre d'espace avant d'arriver au bloc, et placer le joueur contre le bloc interdit
for (int y= sprite->y; y<SIZE_JOUEUR; y++){
......@@ -156,7 +154,6 @@ void deplace_sprite (sprite_t *sprite, world_t *world){
break;
case 1:
//déplace vers le haut
sprite->y -= sprite->v;
if (world->map[sprite->y][sprite->x] != ' ' || world->map[sprite->y][sprite->x + SIZE_JOUEUR] != ' '){
//Compter le nombre d'espace avant d'arriver au bloc, et placer le joueur contre le bloc interdit
for (int y= sprite->y; y<SIZE_JOUEUR; y++){
......@@ -169,7 +166,6 @@ void deplace_sprite (sprite_t *sprite, world_t *world){
break;
case 2:
//déplace vers la droite
sprite->x += sprite->v;
if (world->map[sprite->y][sprite->x + SIZE_JOUEUR] != ' ' || world->map[sprite->y + SIZE_JOUEUR][sprite->x + SIZE_JOUEUR] != ' '){
//Compter le nombre d'espace avant d'arriver au bloc, et placer le joueur contre le bloc interdit
for (int x= sprite->x; x<SIZE_JOUEUR; x++){
......@@ -182,7 +178,6 @@ void deplace_sprite (sprite_t *sprite, world_t *world){
break;
case 3:
//déplace vers la gauche
sprite->x -= sprite->v;
if (world->map[sprite->y][sprite->x] != ' ' || world->map[sprite->y + SIZE_JOUEUR][sprite->x] != ' '){
//Compter le nombre d'espace avant d'arriver au bloc, et placer le joueur contre le bloc interdit
for (int x= sprite->x; x<SIZE_JOUEUR; x++){
......@@ -197,8 +192,6 @@ void deplace_sprite (sprite_t *sprite, world_t *world){
limites_externes(sprite, world);
place_sprite_on_map(sprite, world);
}
void gestion_events(SDL_Event *event, world_t *world){
......@@ -214,15 +207,20 @@ void gestion_events(SDL_Event *event, world_t *world){
//Déplacement du joueur
case SDLK_z:
set_haut(&world->joueur);
world->joueur.y -= world->joueur.v;
break;
case SDLK_s:
set_bas(&world->joueur);
world->joueur.y += world->joueur.v;
break;
case SDLK_d:
set_droite(&world->joueur);
world->joueur.x += world->joueur.v;
break;
case SDLK_q:
set_gauche(&world->joueur);
world->joueur.x -= world->joueur.v;
break;
//case SDLK_SPACE:
......
......@@ -46,7 +46,6 @@ struct world_s{
int compteur_plats; /*!< Nombre d'ennemis étant sorti de l'écran */
int attente; /*!< Compte le nombre de tours avant la fin de la partie*/
char** map; /*!< tableau de caractère correspondant à l'état de la map actuel */
char** level; /*!< tableau de car correspondant à l'architecture du niveau */
};
/**
......
......@@ -57,9 +57,8 @@ while (estFini(&world)==0){
SDL_RenderPresent(ecran); // Récupère les infos actualisés de render et les affiches
}
SDL_Delay(1500);
SDL_DestroyRenderer(ecran);
SDL_Delay(150);
SDL_DestroyRenderer(ecran);
SDL_DestroyWindow(windows);
SDL_Quit();
}
\ No newline at end of file
......@@ -66,17 +66,7 @@ void test_lire_fichier(){
void test_generer_map(){
char ** tab = init_map();
desallouer_tab_2D(tab, SCREEN_HEIGHT/10);
//afficher_tab_2D(tab, SCREEN_HEIGHT/10, SCREEN_WIDTH/10);
}
void test_handle_collision(){
char ** source = init_map();
int n = SCREEN_HEIGHT/10;
int m = SCREEN_WIDTH/10;
desallouer_tab_2D(source, SCREEN_WIDTH/10);
desallouer_tab_2D(tab, SCREEN_HEIGHT);
}
void test_lecture_map(){
......@@ -86,7 +76,13 @@ void test_lecture_map(){
taille_fichier("Ressources/map.txt", &n, &m);
printf("Taille: %d / %d \n", n,m);
//afficher_tab_2D(source, n, m);
desallouer_tab_2D(source, n); //pose pb - plus mtn x)
desallouer_tab_2D(source, n); //pose pb
}
void test_limite(){
world_t world;
init_data(&world);
afficher_tab_2D(world.map, SCREEN_HEIGHT, SCREEN_WIDTH);
}
......@@ -99,5 +95,6 @@ test_genere_fichiers();
test_lire_fichier();
test_generer_map();
test_lecture_map();
test_limite();
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment