Пример #1
0
void updateLighting() {
	short i, j, k;
	enum dungeonLayers layer;
	enum tileType tile;
	creature *monst;

	// copy Light over oldLight and then zero out Light.
	for (i = 0; i < DCOLS; i++) {
		for (j = 0; j < DROWS; j++) {
			for (k=0; k<3; k++) {
				tmap[i][j].oldLight[k] = tmap[i][j].light[k];
				tmap[i][j].light[k] = 0;
			}
			pmap[i][j].flags |= IS_IN_SHADOW;
		}
	}
	
	// go through all glowing tiles
	for (i = 0; i < DCOLS; i++) {
		for (j = 0; j < DROWS; j++) {
			for (layer = 0; layer < NUMBER_TERRAIN_LAYERS; layer++) {
				tile = pmap[i][j].layers[layer];
				if (tileCatalog[tile].glowLight) {
					paintLight(&(lightCatalog[tileCatalog[tile].glowLight]), i, j, false);
				}
			}
		}
	}
	
	// Cycle through monsters and paint their lights:
	CYCLE_MONSTERS_AND_PLAYERS(monst) {	
		if (monst->info.flags & MONST_INTRINSIC_LIGHT) {
			paintLight(&lightCatalog[monst->info.intrinsicLightType], monst->xLoc, monst->yLoc, false);
		}
		
		if (monst->status.burning && !(monst->info.flags & MONST_FIERY)) {
			paintLight(&lightCatalog[BURNING_CREATURE_LIGHT], monst->xLoc, monst->yLoc, false);
		}
	}
	
	// Miner's light:
	paintLight(&rogue.minersLight, player.xLoc, player.yLoc, true);

	if (playerInDarkness()) {
		player.info.foreColor = &playerInDarknessColor;
	} else if (pmap[player.xLoc][player.yLoc].flags & IS_IN_SHADOW) {
		player.info.foreColor = &playerInShadowColor;
	} else {
		player.info.foreColor = &playerInLightColor;
	}
}
Пример #2
0
void updateLighting() {
	short i, j, k;
	enum dungeonLayers layer;
	enum tileType tile;
	creature *monst;
    
	// Copy Light over oldLight
    recordOldLights();
    
    // and then zero out Light.
	for (i = 0; i < DCOLS; i++) {
		for (j = 0; j < DROWS; j++) {
			for (k=0; k<3; k++) {
				tmap[i][j].light[k] = 0;
			}
			pmap[i][j].flags |= IS_IN_SHADOW;
		}
	}
	
	// Paint all glowing tiles.
	for (i = 0; i < DCOLS; i++) {
		for (j = 0; j < DROWS; j++) {
			for (layer = 0; layer < NUMBER_TERRAIN_LAYERS; layer++) {
				tile = pmap[i][j].layers[layer];
				if (tileCatalog[tile].glowLight) {
					paintLight(&(lightCatalog[tileCatalog[tile].glowLight]), i, j, false, false);
				}
			}
		}
	}
	
	// Cycle through monsters and paint their lights:
	CYCLE_MONSTERS_AND_PLAYERS(monst) {
		if (monst->info.flags & MONST_INTRINSIC_LIGHT) {
			paintLight(&lightCatalog[monst->info.intrinsicLightType], monst->xLoc, monst->yLoc, false, false);
		}
		
		if (monst->status[STATUS_BURNING] && !(monst->info.flags & MONST_FIERY)) {
			paintLight(&lightCatalog[BURNING_CREATURE_LIGHT], monst->xLoc, monst->yLoc, false, false);
		}
		
		if (monsterRevealed(monst)) {
			paintLight(&lightCatalog[TELEPATHY_LIGHT], monst->xLoc, monst->yLoc, false, true);
		}
	}
	
	// Also paint telepathy lights for dormant monsters.
    for (monst = dormantMonsters->nextCreature; monst != NULL; monst = monst->nextCreature) {
        if (monsterRevealed(monst)) {
            paintLight(&lightCatalog[TELEPATHY_LIGHT], monst->xLoc, monst->yLoc, false, true);
        }
    }
	
	updateDisplayDetail();
	
	// Miner's light:
	paintLight(&rogue.minersLight, player.xLoc, player.yLoc, true, true);
    
    if (player.status[STATUS_INVISIBLE]) {
        player.info.foreColor = &playerInvisibleColor;
	} else if (playerInDarkness()) {
		player.info.foreColor = &playerInDarknessColor;
	} else if (pmap[player.xLoc][player.yLoc].flags & IS_IN_SHADOW) {
		player.info.foreColor = &playerInShadowColor;
	} else {
		player.info.foreColor = &playerInLightColor;
	}
}