Beispiel #1
0
void map_init()
{
	memset(items, 0, sizeof(point_node*) * ITEM_COUNT);
	memset(storage, 0, sizeof(unsigned) * ITEM_COUNT);
	tcod_map = TCOD_map_new(MAP_COLS, MAP_ROWS);
	TCOD_map_clear(tcod_map, true, true);
}
Beispiel #2
0
void TCODMap::clear(bool transparent, bool walkable) {
	TCOD_map_clear(data,transparent,walkable);
}
Beispiel #3
0
void _drawDynamicLight(light *lght) {
	int x, y, penalty, r_tint, g_tint, b_tint;
	float distMod, alpha;
	character *player = getPlayer();
	TCOD_map_t levelMap = getLevelMap();
	
	if (!lght->lightMap) {
		return;
	}
	
	TCOD_map_clear(lght->lightMap, 0, 0);
	
	if (!lght->fuel) {
		return;
	}
	
	for (y = lght->y - 32; y < lght->y + 32; y++) {
		for (x = lght->x - 32; x < lght->x + 32; x++) {
			if (x < 0 || x >= WINDOW_WIDTH || y < 0 || y >= WINDOW_HEIGHT) {
				continue;
			}
			
			if (TCOD_map_is_in_fov(lght->fov, x, y)) {
				if (lght->fuel < lght->size) {
					penalty = lght->size - lght->fuel;
				} else {
					penalty = 0;
				}
				
				distMod = lght->size - (distanceFloat(lght->x, lght->y, x, y) + penalty);
				
				if (distMod <= 0) {
					TCOD_map_set_properties(lght->lightMap, x, y, 0, 0);
				} else {
					TCOD_map_set_properties(lght->lightMap, x, y, 1, 1);
				}

				if (isPositionWalkable(x, y)) {
					distMod -= getRandomFloat(0, lght->flickerRate);
				}
				
				if (distMod < 0) {
					distMod = 0;
				} else if (distMod > lght->size / 2) {
					distMod = lght->size / 2;
				}
				
				alpha = (distMod / (float) lght->size);
				alpha *= lght->sizeMod;

				if (lght->noTint) {
					r_tint = 1;
					g_tint = 1;
					b_tint = 1;
				} else {
					if (!TCOD_map_is_walkable(levelMap, x, y)) {
						r_tint = 55 + RED_SHIFT;
						g_tint = 55;
						b_tint = 55;

						if (alpha > .45) {
							alpha = .45;
						}
					} else {
						r_tint = lght->r_tint + RED_SHIFT;
						g_tint = lght->g_tint;
						b_tint = lght->b_tint;

						alpha = clipFloat(alpha, 0, lght->brightness);
					}
				}
				
				if (!player || TCOD_map_is_in_fov(player->fov, x, y)) {
					drawCharBackEx(DYNAMIC_LIGHT_CONSOLE, x, y, TCOD_color_RGB(r_tint, g_tint, b_tint), TCOD_BKGND_ADDALPHA(alpha));
				}
			}
		}
	}
}
Beispiel #4
0
void TCODMap::clear() {
	TCOD_map_clear(data);
}