/*********************************************************************** * Map * addIntensity ***********************************************************************/ void Map::addIntensity(sf::Vector2i index, char intensity, sf::Color color) { if (index.x < 0 || index.x >= MAP_SIZE_X || index.y < 0 || index.y >= MAP_SIZE_X) return; color = applyIntensity(color, intensity); tiles[index.x][index.y].light = mixColors(tiles[index.x][index.y].light, color); if (tiles[index.x][index.y].intensity < intensity) tiles[index.x][index.y].intensity = intensity; }
/*********************************************************************** * Map * resetLight ***********************************************************************/ void Map::resetLight() { sf::Vector2i from(0, 0); sf::Vector2i to(MAP_SIZE_X, MAP_SIZE_Y); sf::Color color = applyIntensity(ambientColor, ambientIntensity); for (int i = 0; i < LIGHT_MAX_LIGHTLEVEL; lightCounts[i++] = 0); for (int i = from.x; i < to.x; i++) for (int j = from.y; j < to.y; j++) if (tiles[i][j].type == mtAir) { tiles[i][j].intensity = ambientIntensity; tiles[i][j].light = color; } else { tiles[i][j].intensity = 0; tiles[i][j].light = sf::Color::Black; } }
//! [1] void VibrationSurface::mouseMoveEvent(QMouseEvent *event) { applyIntensity(event->x(), event->y()); }
//! [0] void VibrationSurface::mousePressEvent(QMouseEvent *event) { applyIntensity(event->x(), event->y()); vibra->start(); }