示例#1
0
文件: zone.c 项目: Grissess/iiag
zone * zone_new(int w, int h)
{
	int i, j;
	zone * z;

	z = malloc(sizeof(zone));
	z->width = w;
	z->height = h;

	z->tiles = malloc(sizeof(tile *) * w);
	for (i = 0; i < w; i++) {
		z->tiles[i] = malloc(sizeof(tile) * h);
		for (j = 0; j < h; j++) {
			z->tiles[i][j].show = 0;
			z->tiles[i][j].impassible = 0;
			z->tiles[i][j].crtr = NULL;
			z->tiles[i][j].inv = inv_new(TILE_MAX_WEIGHT);
		}
	}

	vector_init(&z->crtrs);
	generate(z);

	return z;
}
示例#2
0
文件: world.c 项目: oftn-oswg/iiag
void init_world(void)
{
	int x, y;
	cform * f;

	world.zones = malloc(sizeof(zone *));

	load_iforms();
	load_cforms();

	*world.zones = zone_new(500, 300);

	f = cform_new('@' | A_BOLD);
	f->weight = TILE_MAX_WEIGHT / 2;
	f->max_health = 10;

	crtr_init(&world.plyr, f);
	world.plyr.nofree = 1;
	world.plyr.inv = inv_new(500);
	world.plyr.attack = 5;

	do {
		x = random() % get_dispw();
		y = random() % get_disph();
	} while (!crtr_tele(&world.plyr, x, y, *world.zones));

	zone_update(world.plyr.z, x, y);
}