Level editor help

Hello i am making a text based level editor in C
for another text based game and so far have got a
simple editor and i can save the levels

but i am having trouble with loading the map

here is my load and save functions
if i can give all the source files if
anyone wants them but its alot of code for one
question thanks in advance!
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
void save()//working
{
     short i;
     short j;
     Clear_Screen();/*a function using the windows.h header file to replace system("cls");*/
     printf("Saving..."); 
     FILE *fp;
     fp=fopen("Map.TTXT", "w");
     for (i = 0;i < MAXX;i++)
     {
      for(j = 0;j < MAXY;j++)
      {fprintf(fp, "%d\n", Map.Map[i][j]);}/*map is a struct and Map.Map
is a 2d array in the struct */
     }
     fclose(fp);
     printf("\nSaved!\nHit enter to continue");
     getch();        
}


void load()//sort of working
{
 short i;
 short j;
 char ch[85];
 char File[9] = "Map.TTXT";
 Clear_Screen();
 printf("loading...\n");
 FILE *fp;
 fp=fopen(File, "r");
 for (i = 0;i < MAXX;i++)
     {
      for(j = 0;j < MAXY;j++)
      {
            while(fgets(ch, 85, fp)){Map.Map[i][j] = ch[i];}}
               }
     fclose(fp);
 printf("\nfinished\n");
 getch();
}
also i know this is a cpp forum but as C is basically part of c++ i think its resolvent
Last edited on
Topic archived. No new replies allowed.