Sunday, March 24, 2019

xna - 2D lighting theory: day-and-night cycle, spot lights at night



I am writing a rogue-like 'zombie' management game. The game map will be similar to Prison Architect. A top-down 50 X 50 grid.


I want to implemented a day night cycle and during the night I would like the player to be able to position lights.


I would like to be able to lighten and dark to whole map to display the day and night cycle.


Then lights would be a circle of light blocked by game entities such as walls, players, trees etc.


How would I achieve and what is the standard way of achieving this?



Answer



Sorry for posting a collection of links but your problem has many possible solutions! :)


Various gridbased lighting algorithms traditionally used by roguelikes: http://roguebasin.roguelikedevelopment.org/index.php?title=Category:LOS http://roguebasin.roguelikedevelopment.org/index.php?title=Field_of_Vision


A solution I developed to support partial occlusion of grid cells: http://blog.pixelpracht.net/?p=340


Rather complicated pixel-perfect approach that calculates the Field of View as a Polygon: http://www.redblobgames.com/articles/visibility/



A game I wrote a while ago using a similar math based approach: http://runehunt.pixelpracht.net/


Projecting each face outwards, kinda what Carmack did in Doom3 but in 2d space. Causes a lot of overdraw which doesn't matter so much if you have access to hardware acceleration. http://forums.tigsource.com/index.php?topic=8803.0


No comments:

Post a Comment

Simple past, Present perfect Past perfect

Can you tell me which form of the following sentences is the correct one please? Imagine two friends discussing the gym... I was in a good s...