コード例 #1
0
ファイル: lvlgen.c プロジェクト: chrissexton/mid
static int stairlocs(Lvl *lvl, Loc ls[])
{
	int nls = 0;
	for (int z = 0; z < lvl->d; z++)
	for (int x = 1; x < lvl->w-1; x++)
	for (int y = 1; y < lvl->h-2; y++) {
		if (reachable(lvl, x, y, z) &&  tileinfo(lvl, x, y+1, z).flags & Tcollide
			&& !(tileinfo(lvl, x, y, z).flags & (Tfdoor | Tbdoor | Tup))) {
			ls[nls] = (Loc){ x, y, z };
			nls++;
		}
	}
	return nls;
}
コード例 #2
0
ファイル: lvlgen.c プロジェクト: chrissexton/mid
static void stairs(Rng *r, Lvl *lvl, unsigned int x0, unsigned int y0)
{
	if (tileinfo(lvl, x0, y0, 0).flags & Twater)
		blk(lvl, x0, y0, 0)->tile = 'U';
	else
		blk(lvl, x0, y0, 0)->tile = 'u';
	setreach(lvl, x0, y0, 0);

	Loc ls[lvl->w * lvl->h * lvl->d];
	int nls = stairlocs(lvl, ls);
	if (nls == 0)
		fatal("No stair locations");

	Loc l = ls[rnd(0, nls - 1)];
	if (tileinfo(lvl, l.x, l.y, l.z).flags & Twater)
		blk(lvl, l.x, l.y, l.z)->tile = 'D';
	else
		blk(lvl, l.x, l.y, l.z)->tile = 'd';
	setreach(lvl, l.x, l.y, l.z);
}
コード例 #3
0
ファイル: zone.c プロジェクト: velour/mid
Tileinfo zonedstairs(Zone *zn)
{
	Tileinfo bi;

	for (int z = 0; z < zn->lvl->d; z++) {
	for (int x = 0; x < zn->lvl->w; x++) {
	for (int y = 0; y < zn->lvl->h; y++) {
		bi = tileinfo(zn->lvl, x, y, z);
		if (bi.flags & Tdown)
			return bi;
	}
	}
	}
	fatal("No down stairs found in this zone");
}