#include <stdio.h>
char *map[50][50];
int main(void) {
char exit[100];
char *desc;
strcpy(exit, "East");
map[0][0] = exit;
desc = map[0][0];
strcat(desc, " - To Tom Bombidil's house.");
printf("%s <- updated.", map[0][0]);
return 0;
}
const char* RANGED_WEAPON_NAMES[WEAPON_TYPE_NUMBER][20] = {
/*RANGED_BOW*/ {"bow","longbow","compound bow","flatbow","recurve bow","reflex bow",NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL},
/*RANGED_CROSSBOW*/ {"crossbow","repeating crossbow","recurve crossbow","arbalest",NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL},
/*RANGED_GUN*/ {"musket","arquebus","flintlock pistol",NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL},
};
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
char *map[50][50];
void remove_from_map(int x, int y)
{
free(map[x][y]);
map[x][y] = NULL;
}
void insert_into_map(int x, int y, char *str)
{
free(map[x][y]);
map[x][y] = strdup(str);
}
const char *get_from_map(int x, int y)
{
return map[x][y];
}
int main()
{
insert_into_map(45, 30, "map[45][30]");
printf("\"%s\"\n", get_from_map(45, 30));
remove_from_map(45, 30);
if (get_from_map(45, 30) != NULL)
{
printf("Universe is broken.\n");
}
}
enum {MP_FOREST, MP_RIVER, MP_MOUNTAIN, MP_LINKHOR, MP_LINKVERT};
const char* glyphs[] = {"#", "~", "^", "-", "|"}; // may have color codes added
// assignment
map[x][y] = MP_FOREST;
map[x][y+1] = MP_LINKVERT;
#include <stdio.h>
#define MAP_WIDTH 32
#define MAP_HEIGHT 32
int main()
{
char * map=0;
char value=0;
int offset_y=0;
int offset_x=0;
map = (char *) malloc(MAP_WIDTH * MAP_HEIGHT);
memset(map,0,MAP_WIDTH*MAP_HEIGHT);
for(y = offset_y; y < 8; y++)
{
for(x = offset_x; x < 8; x++)
{
value = map[(x)+ ((y)*MAP_WIDTH)];
select(value)
{
/*0 - 2 boarder pieces */
case 0: printf("+"); break;
case 1: printf("-"); break;
case 2: printf("|"); break;
/*3-9 terain pieces - water, mountain, forest, plains, road,city */
case 3: printf("~");break;
case 4: printf("^");break;
case 5: printf("#");break;
case 6: printf(";");break;
case 7: printf(" ");break;
case 8: printf("*");break;
default: printf("!"); break; /*shouldn't see this*/
}
printf("\n\r"); /* end of the line needs to drop down one */
}
}
free(map);
return 0;
}
void change_tile(int x, int y, char * map, char tile);
{
if(!((x >= 0 && y >= 0 ) && ( x < MAP_WIDTH && y < MAP_HEIGHT)))
{
printf("index (x,y) (%i,%i) is out of range\n\r",x ,y);
}
else
{
memset(map+(x+(y*MAP_WIDTH)), tile,1);
/* you could also probably use this which is more or less what i have above
map[x+(y*MAP_WIDTH)] = tile;
*/
}
}