I am having some trouble adding the addition(ne, nw, se, sw) directions to the world_generator.
Now this is another block that I have stumped myself on. I wrote north, east, south, and west quite easily.
Code:
#include <stdio.h>
#include <stdlib.h>
void main()
{
int WIDTH = 55,
HEIGHT = 55,
VNUM_START = 100,
VNUM_END = WIDTH*HEIGHT+(VNUM_START-1),
ZONE_NUM = 1,
vnum, n, e, s, w, line_pos;
FILE *fp=fopen("1.wld", "w"); /*change per area*/
printf("#*****************************#\n");
printf("# Generating %3d by %3d world #\n", WIDTH, HEIGHT);
printf("# Generating %5d rooms #\n", VNUM_END);
printf("#*****************************#\n");
for(vnum = VNUM_START; vnum <=VNUM_END; vnum++)
{
n=vnum-WIDTH;
s=vnum+WIDTH;
e=vnum+1;
w=vnum-1;
/*Where is it on line 0.*/
line_pos=(vnum-VNUM_START+1)%(WIDTH);
if(line_pos==0) line_pos=WIDTH;
/*North Border*/
if ( (vnum >= VNUM_START) && (vnum < VNUM_START+WIDTH) )
{
n=(VNUM_END-WIDTH)+(line_pos);
}
/*South Border*/
if ( (vnum > VNUM_END-WIDTH) && (vnum <= VNUM_END) ) {
s=(VNUM_START)+(line_pos-1);
}
/*East Border*/
if ( (vnum-VNUM_START+1)%(WIDTH)==0 ) {
e=vnum-WIDTH+1;
}
/*West Border*/
if ( (vnum-VNUM_START+1)%(WIDTH)==1 ) {
w=vnum+WIDTH-1;
}
fprintf(fp, "#%d\n", vnum); /*Rooms Vnum*/
fprintf(fp, "Earth %d~\n", vnum); /*Rooms Name and Vnum*/
fprintf(fp, "You are on planet earth.\n~\n"); /*Rooms Desc*/
fprintf(fp, "0 0 0 0 0 0\n"); /*Zone Number, Room Flag, Room Flag, Room Flag, Room Flag, Room Sector*/
fprintf(fp, "D0\n~\n~\n0 0 %d\n", n); /*North Exit*/
fprintf(fp, "D1\n~\n~\n0 0 %d\n", e); /* East Exit */
fprintf(fp, "D2\n~\n~\n0 0 %d\n", s); /* South Exit*/
fprintf(fp, "D3\n~\n~\n0 0 %d\n", w); /* West Exit*/
fprintf(fp, "S\n");
}
fprintf(fp, "$\n");
fclose(fp);
/*Generate a .zon file*/
FILE *fp2=fopen("../zon/1.zon", "w"); /*Change for new area*/
fprintf(fp2, "#%d\nDragon Ball Tournament~\nEarth~\n%d %d 30 2 g 0 0 0 -1 -1\nS\n$\n",ZONE_NUM, VNUM_START, VNUM_END);
fclose(fp2);
FILE *fp3=fopen("../mob/1.mob", "w"); /*Change for new area*/
fprintf(fp3, "$\n");
fclose(fp3);
FILE *fp4=fopen("../obj/1.obj", "w"); /*Change for new area*/
fprintf(fp4, "$\n");
fclose(fp4);
FILE *fp5=fopen("../shp/1.shp", "w"); /*Change these per new area*/
fprintf(fp5, "$~\n");
fclose(fp5);
FILE *fp6=fopen("../qst/1.qst", "w"); /*change these per new area*/
fprintf(fp6, "$~\n");
fclose(fp6);
FILE *fp7=fopen("../trg/1.trg", "w"); /*change these per new area*/
fprintf(fp7, "$~\n");
fclose(fp7);
}