Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void recursiveLightCalculation(int x, int y, double lightLevel, LightMap & lightMap, SolidMap & solid)
- {
- //if the light is brighter here, then it already calculated all that this would
- if (lightLevel <= lightMap.get(x, y))
- return;
- lightMap.set(x, y, lightLevel);
- if (x - 1 >= 0 && !solid.isSolid(x - 1, y))
- recursiveLightCalculation(x - 1, y, lightLevel - 1, lightMap, solid);
- if (y - 1 >= 0 && !solid.isSolid(x, y - 1))
- recursiveLightCalculation(x, y - 1, lightLevel - 1, lightMap, solid);
- if (x + 1 < lightMap.getSize().x && !solid.isSolid(x + 1, y))
- recursiveLightCalculation(x + 1, y, lightLevel - 1, lightMap, solid);
- if (y + 1 < lightMap.getSize().y && !solid.isSolid(x, y + 1))
- recursiveLightCalculation(x, y + 1, lightLevel - 1, lightMap, solid);
- if (x - 1 >= 0 && y - 1 >= 0 && !solid.isSolid(x - 1, y - 1))
- recursiveLightCalculation(x - 1, y - 1, lightLevel - std::sqrt(2), lightMap, solid);
- if (x - 1 >= 0 && y + 1 < lightMap.getSize().y && !solid.isSolid(x - 1, y + 1))
- recursiveLightCalculation(x - 1, y + 1, lightLevel - std::sqrt(2), lightMap, solid);
- if (x + 1 < lightMap.getSize().x && y - 1 >= 0 && !solid.isSolid(x + 1, y - 1))
- recursiveLightCalculation(x + 1, y - 1, lightLevel - std::sqrt(2), lightMap, solid);
- if (x + 1 < lightMap.getSize().x && y + 1 < lightMap.getSize().y && !solid.isSolid(x + 1, y + 1))
- recursiveLightCalculation(x + 1, y + 1, lightLevel - std::sqrt(2), lightMap, solid);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement