6
\$\begingroup\$

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?

\$\endgroup\$

2 Answers 2

4
\$\begingroup\$

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

\$\endgroup\$
1
  • 1
    \$\begingroup\$ Byte56 is right we should include answers in the posts for future readers but that is the reading i need thank you lithander. \$\endgroup\$
    – LoveofSnow
    Commented Oct 23, 2012 at 18:08
0
\$\begingroup\$

http://www.catalinzima.com/2010/07/my-technique-for-the-shader-based-dynamic-2d-shadows/

there is also a link at teh bottom of the comments to an 'improved' version of this

\$\endgroup\$
1
  • 5
    \$\begingroup\$ Typically, answers with just a link are not very good. If the link were to go down, this answer would be useless. Creating a summary of the process here would make a much better answer. \$\endgroup\$
    – House
    Commented Oct 23, 2012 at 16:22

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .