creer un fichier nouveau pour lediteur de map
This commit is contained in:
11
maps/custom_4.txt
Normal file
11
maps/custom_4.txt
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
###################
|
||||||
|
#P #
|
||||||
|
# #
|
||||||
|
# #
|
||||||
|
# #
|
||||||
|
# C #
|
||||||
|
# #
|
||||||
|
# I #
|
||||||
|
# #
|
||||||
|
# #
|
||||||
|
###################
|
||||||
11
maps/viergemap.txt
Normal file
11
maps/viergemap.txt
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
###################
|
||||||
|
#P #
|
||||||
|
# #
|
||||||
|
# #
|
||||||
|
# #
|
||||||
|
# C #
|
||||||
|
# #
|
||||||
|
# I #
|
||||||
|
# #
|
||||||
|
# #
|
||||||
|
###################
|
||||||
@@ -10,6 +10,7 @@
|
|||||||
#include <SDL2/SDL_image.h>
|
#include <SDL2/SDL_image.h>
|
||||||
#include <SDL2/SDL_render.h>
|
#include <SDL2/SDL_render.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <unistd.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#define SIZE_PLAY 20
|
#define SIZE_PLAY 20
|
||||||
@@ -60,10 +61,13 @@ int main ()
|
|||||||
}
|
}
|
||||||
else if(output == -2)
|
else if(output == -2)
|
||||||
{
|
{
|
||||||
|
printf("editeur de map");
|
||||||
|
//newmap
|
||||||
output = inEditorLoop(menu, &dim_menu, &pos, &null, 1, &display_user, &score_user);
|
output = inEditorLoop(menu, &dim_menu, &pos, &null, 1, &display_user, &score_user);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
printf("editeur de map : %d" ,output);
|
||||||
score_user.before = time(NULL);
|
score_user.before = time(NULL);
|
||||||
char txt[30] = "";
|
char txt[30] = "";
|
||||||
if(output <= 3)
|
if(output <= 3)
|
||||||
@@ -74,6 +78,8 @@ int main ()
|
|||||||
{
|
{
|
||||||
snprintf(txt, 30, "maps/custom_%d.txt", output - 4);
|
snprintf(txt, 30, "maps/custom_%d.txt", output - 4);
|
||||||
}
|
}
|
||||||
|
if(access(txt, F_OK)==0)
|
||||||
|
{
|
||||||
if (targets != NULL) free(targets);
|
if (targets != NULL) free(targets);
|
||||||
if (tab2d != NULL) free2D(tab2d, SIZE_PLAY);
|
if (tab2d != NULL) free2D(tab2d, SIZE_PLAY);
|
||||||
tab2d = creatArea2D(SIZE_PLAY, SIZE_PLAY);
|
tab2d = creatArea2D(SIZE_PLAY, SIZE_PLAY);
|
||||||
@@ -84,6 +90,26 @@ int main ()
|
|||||||
if(output != -1000) winOrLoseLoop(&display_user, &score_user, output==1);
|
if(output != -1000) winOrLoseLoop(&display_user, &score_user, output==1);
|
||||||
output = -1;
|
output = -1;
|
||||||
}
|
}
|
||||||
|
else{
|
||||||
|
char path[256];
|
||||||
|
snprintf(path, sizeof(path), "maps/custom_%d.txt", output-4);
|
||||||
|
FILE *src = fopen("maps/viergemap.txt", "r");
|
||||||
|
FILE *file = fopen(path, "w");
|
||||||
|
|
||||||
|
|
||||||
|
char buffer[1024]; // Tampon pour lire le contenu
|
||||||
|
size_t bytesRead;
|
||||||
|
|
||||||
|
// Lire le contenu du fichier source et l'écrire dans le fichier destination
|
||||||
|
while ((bytesRead = fread(buffer, 1, sizeof(buffer), src)) > 0) {
|
||||||
|
fwrite(buffer, 1, bytesRead, file);
|
||||||
|
}
|
||||||
|
|
||||||
|
fclose(src);
|
||||||
|
fclose(file);
|
||||||
|
output = -2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user