Car "headlight" effect

Monkey Forums/Monkey Programming/Car "headlight" effect

silentshark(Posted 2013) [#1]
Hello guys,

I'm looking to do a nighttime level on our up and coming driving game. The following shows the kind of headlight effect I'm after (daytime vs nighttime):

Day time:



Night time:



I've been scratching my head on the best way to deal with this. The car with the headlights can rotate 360, so that's another headache.

Any pointers, oh gurus?


Playniax(Posted 2013) [#2]
I think you can use a bitmap with alpha mask of the headlight shape.

The bitmap would have to cover the whole screen.


Paul - Taiphoz(Posted 2013) [#3]
If your only using lights on the player car then as Playniax said, create a black image bigger than the screen with the headlight alpha-ed in the middle and then position and rotate that image to give the car a light.

Where you might run into problems are if you want to add lights to more than one car, where they overlap you might not get the effect your expecting.

Not sure how you might go about it , but you might with code be able to create a black image and then paste in the alpha for each of the cars lights into a single image but honestly im not sure exactly how you might do that.


silentshark(Posted 2013) [#4]
thanks for the ideas, guys. That's going to need to be a big bitmap, 'cos I'm working at 1280x720..

I know before I hit issues before with some Android devices when I tried to use bitmaps bigger than 2000 x whatever (think it was the HTC1X). Nevertheless, it sounds like it's worth a whirl.

Many thanks for taking the time to think and respond :-)


Tibit(Posted 2013) [#5]
You could have a tile of black-fog squares and then you turn the alpha up if they collide with the "head-light-cone". It will be squary edges depending on how big you make the tile-grid, but for many games it could look really cool! Seen that effect in terraria maybe?


Shinkiro1(Posted 2013) [#6]
Instead of using a fullscreen image, use an image that's as big as the radius of the cone. Fill the rest of the screen with DrawRect.


silentshark(Posted 2013) [#7]
Cheers, guys, getting somewhere with a single big bitmap with a transparent, blurred cone..



to overcome my fear of too big bitmaps, it's scaled up at runtime..


Tibit(Posted 2013) [#8]
looks great!


Playniax(Posted 2013) [#9]
Nice!


silentshark(Posted 2013) [#10]
Cheers for the encouragement :-)


Gerry Quinn(Posted 2013) [#11]
There's a thread called 'Spotlighting' that covers similar ground.