Skip to main content
gamedev.net
🔒 Locked

2D Lighting in Java (Android)

Started by Ioncannon Sep 22, 2010 at 11:39 AM 0 replies 1.2k views
Original Post
Ioncannon
Ioncannon
I am trying to tackle 2d lighting in a new game I am coding. Is it possible to implement it using SurfaceView without OpenGL?

My idea on how to implement it is to cast rays between two angles. As the ray goes down the line, it intensifies the pixel it is over by a certain fade value. If it collides it stops, otherwise it keeps going until a fade value hits 0;

I have never done something like this before (my last games were just regular 2d puzzle/tile games) so it probably is the wrong way to approach this. Two problems I find is

Modifying the pixel: As far as I know there is no way to modify the back buffer in Java correct? Otherwise I'd just run this over whatever was stored there after all tiles and objects were rendered. The other option is to pre-calculate it on the resources before drawing it.

Second problem is it looks like it will be real slow if it is calculated dynamically.

So how would I do this?
ArKano22
ArKano22
Casting rays is probably going to be slow as hell. I´m not an Android developer and i know nothing about SurfaceViews, but chances are you can do this:

http://www.gamedev.net/reference/programming/features/2dsoftshadow/

without having to use directly the OpenGL API.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.