2D Lights
by Ben Versaw · in General Discussion · 09/22/2004 (3:20 pm) · 3 replies
I'm working on a side view 2d puzzle/action game. One of the ideas for the game I have is that since the game takes place in a wizard's castle I could have torches lining the wall. Well the map is just a set of tiles that scrolls around. Using c++ and opengl I'm trying to think of an efficent way of putting in dymatic lighting from torches that will work on any tile without recoding.
I have thought of using animated sprites and will do that if no other solutions are possible but I think that it will be a waste I would need a sprite animation for every single tile and the surrounding tiles also bringing the file size count up unneeded.
Basically I'm looking for a generic way of applying a torch lighting affect to a 2d tile that does not require recoding for each tile.
NOTE: I'm using pure c++ and opengl I'm not using any sort of engine so please keep that in mind when answering.
-WizRealms
I have thought of using animated sprites and will do that if no other solutions are possible but I think that it will be a waste I would need a sprite animation for every single tile and the surrounding tiles also bringing the file size count up unneeded.
Basically I'm looking for a generic way of applying a torch lighting affect to a 2d tile that does not require recoding for each tile.
NOTE: I'm using pure c++ and opengl I'm not using any sort of engine so please keep that in mind when answering.
-WizRealms
#2
Thanks, WizRealms
09/22/2004 (4:38 pm)
I'll try using the square polygon with transparently and report the results.Thanks, WizRealms
#3
Usually, I'll use something like 64 + 3 * oldValue / 4 instead of just a multiplication. This prevents the color from overflowing. Of course, you'll have to use different numbers depending upon what color depth you're using.
Increasing the value of each component increases the brightness, and lowering it lowers the brightness.
All you would have to do is change the colors of the pixels in a circle around the torch.
Depending upon how have things set up, this could be easy, or it could be impossible. I suspect that it would be hard with OpenGL. It would be easiest if you had the video data stored in main memory and then copied it all to video memory after you were completely done changing the data.
09/23/2004 (6:24 pm)
If you decide not to use alpha channel transparency, you can also change the brightness of a pixel by multiplying each of its color components (i.e. red, green, and blue) by a specific amount.Usually, I'll use something like 64 + 3 * oldValue / 4 instead of just a multiplication. This prevents the color from overflowing. Of course, you'll have to use different numbers depending upon what color depth you're using.
Increasing the value of each component increases the brightness, and lowering it lowers the brightness.
All you would have to do is change the colors of the pixels in a circle around the torch.
Depending upon how have things set up, this could be easy, or it could be impossible. I suspect that it would be hard with OpenGL. It would be easiest if you had the video data stored in main memory and then copied it all to video memory after you were completely done changing the data.
Associate Orion Elenzil
Real Life Plus
i don't know much about coding tile games,
but it seems like if you've got openGL available,
just make a simple square polygon with a transparent texture of the torch's light on it,
and render it with blendmode set to something like ADD.
or, if textures & polygons aren't going on in tiled openGL,
a blit with transparency...