Reputation: 3
I try for some time to create a game. But at the very beginning, I am stuck. I just want to draw a black screen with a transparent circle overlaying it. I have searched a solution on a lot of french sites, but no responses
I drew you two images to show you what I want.
** Thank you for taking the time to read, and your help**
Upvotes: 0
Views: 443
Reputation: 1310
You (physically) can't have a PNG with a transparent hole that moves around.
I mean, try it yourself. Take a piece of paper, cut out a hole in the paper. While you can do that, you can't move the hole around. You'd need a new piece of paper.
You'll need to use a shader for this, that renders everything on the screen black, apart from a circle at the players position. Pretty basic post-processing shader.
Pseudo code (in C#, needs to be translated to HLSL):
foreach (var pixel in allPixels)
{
bool drawAsBlack = pixel.Position.DistanceFrom(player.PositionCenter) > RANGE_RADIUS;
if (drawAsBlack)
return Color.Black;
else
return pixel.Color;
}
Something like that, obviously translated into HLSL, but you get the idea.
Upvotes: 1