Welcome to the Builder Academy

Question Trying to add nw, ne, sw, se.

More
28 Oct 2012 08:06 - 28 Oct 2012 08:07 #949 by Liko
Well guys, I'm stuck trying to add the additional directions to my wld generation. I know it should be something simple, but it keeps slipping my mind.
Code:
#include <stdio.h> #include <stdlib.h> void main() { int WIDTH=180, HEIGHT=180, VNUM_START=100, VNUM_END=WIDTH*HEIGHT+(VNUM_START-1), vnum,n,e,s,w,line_pos; FILE *fp=fopen("2.wld","w"); printf("#*********************************#\n"); printf("# GENERATING %3d BY %3d AREA FILE #\n",WIDTH,HEIGHT ); printf("#*********************************#\n"); for ( vnum=VNUM_START ; vnum<=VNUM_END ; vnum++) { /* for every room */ n=vnum-WIDTH; s=vnum+WIDTH; e=vnum+1; w=vnum-1; /*where it is on the line 0 to (WIDTH-1)*/ 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\nSpace~\nThis room was generated by Liko's world generator.\n~\n1 0 0 0 0 11\n",vnum); fprintf(fp,"D0\n~\n~\n0 0 %d\n",n); fprintf(fp,"D1\n~\n~\n0 0 %d\n",e); fprintf(fp,"D2\n~\n~\n0 0 %d\n",s); fprintf(fp,"D3\n~\n~\n0 0 %d\n",w); fprintf(fp,"S\n"); } fprintf(fp,"$~\n"); }

I know in the saves nw,ne,se,sw using D6-9. I believe I am just missing the simple formula for directions themselves. I have it working for north, east, south, and west. Connects and links them all. I just need the new directions.

Randian(0.0.0)
Owner/Developer
Last edit: 28 Oct 2012 08:07 by Liko.

Please Log in or Create an account to join the conversation.

More
28 Oct 2012 20:46 #950 by Rumble

Rumble
The Builder Academy
tbamud.com 9091
rumble@tbamud.com

Please Log in or Create an account to join the conversation.

More
28 Oct 2012 23:16 #952 by Liko

Rumble wrote: This snippet should help:
tbamud.com/downloads/viewdownload/5-snippets/48-diagonal-exits


I already have them in the mud. What i'm trying to do is add them to my area generator for the ascii map.

Randian(0.0.0)
Owner/Developer

Please Log in or Create an account to join the conversation.

More
29 Oct 2012 02:31 - 29 Oct 2012 02:32 #953 by wifidi
Dear Liko,
Extrapolating from your code, it's:
Code:
int WIDTH=180, HEIGHT=180, VNUM_START=100, VNUM_END=WIDTH*HEIGHT+(VNUM_START-1), vnum,n,e,s,w,nw,ne,se,sw,line_pos;
...
Code:
n=vnum-WIDTH; s=vnum+WIDTH; e=vnum+1; w=vnum-1; nw=vnum-WIDTH-1; ne=vnum-WIDTH+1; se=vnum+WIDTH+1; sw=vnum+WIDTH-1;
...and
Code:
fprintf(fp,"#%d\nSpace~\nThis room was generated by Liko's world generator.\n~\n1 0 0 0 0 11\n",vnum); fprintf(fp,"D0\n~\n~\n0 0 %d\n",n); fprintf(fp,"D1\n~\n~\n0 0 %d\n",e); fprintf(fp,"D2\n~\n~\n0 0 %d\n",s); fprintf(fp,"D3\n~\n~\n0 0 %d\n",w); fprintf(fp,"D6\n~\n~\n0 0 %d\n",nw); // assuming nw is 6 fprintf(fp,"D7\n~\n~\n0 0 %d\n",ne); // assuming ne is 7 fprintf(fp,"D8\n~\n~\n0 0 %d\n",se); // assuming se is 8 fprintf(fp,"D9\n~\n~\n0 0 %d\n",sw); // assuming sw is 9 fprintf(fp,"S\n"); }
Last edit: 29 Oct 2012 02:32 by wifidi. Reason: switch order of variables "se", "sw"

Please Log in or Create an account to join the conversation.

More
29 Oct 2012 02:49 - 29 Oct 2012 02:53 #954 by wifidi
In theory, once adding diagonal directions, any room can exit to 26 different rooms: a 9-room square above, the same level N, NE, E, SE, S, SW, W or NW, and a 9-room square below.
Last edit: 29 Oct 2012 02:53 by wifidi. Reason: use commas and grammar instead of ";"'s

Please Log in or Create an account to join the conversation.

More
29 Oct 2012 03:26 - 29 Oct 2012 03:34 #955 by wifidi
Storing a facing direction between 0 and 25 and calling that direction relative north, it'd be possible to move forward in 1 of 26 directions by typing "n" instead of e.g. continuously having to type "unw" or "nwu". For speed and convenience, it's also possible to combine facing and moving into each directional command except "n": the only command which doesn't change a character's facing, only the character's location.
Optionally, all directional commands face in that direction and "f" moves in that direction. I'm sure there are other configuations to take advantage of this kind of movement. Like telescopes looking at long distances, "what's in between the movements?" might be what programmers have to come up with for plausibility. The "ether" of text MUDs.
Last edit: 29 Oct 2012 03:34 by wifidi. Reason: typo

Please Log in or Create an account to join the conversation.

Time to create page: 0.206 seconds