Anybody know how this could be achieved?
So that everything is very dark except from where the flashlight beam is?
Making a flashlight
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Re: Making a flashlight
Draw a flashlight beam(image?) under the zombies?
Re: Making a flashlight
I don't see how that would work? I want to zombies to be dark too unless the flashlight is over them.
Re: Making a flashlight
Not sure how optimized this would be, but you could have a giant image for the flashlight, it would have to be 4 times the screen size, and have a transparent hole in the middle of it. Then move that, and make sure the zombies are drawn under that layer.
Re: Making a flashlight
Didn't think of that! Well done! Thanks.
Re: Making a flashlight
Here's some code that does what I think you want:
Basically it draws just the rectangle under the flashlight, and then a flashlight mask on top of it.
Is that what you wanted?
Code: Select all
function load()
background = love.graphics.newImage("background.jpg")
flashlight = love.graphics.newImage("flashlight.png")
fw = flashlight:getWidth()
fh = flashlight:getHeight()
end
function draw()
local x, y = love.mouse.getPosition()
love.graphics.draws(background, x, y, x-fw/2, y-fh/2, fw, fh)
love.graphics.draw(flashlight, x, y)
end
Is that what you wanted?
- Attachments
-
- flashlight.love
- (115.83 KiB) Downloaded 349 times
Re: Making a flashlight
Oh my... that is perfect! Thank you very much!
I don't really understand how you achieved that though, I mean with the flashlight image?
I don't really understand how you achieved that though, I mean with the flashlight image?
Re: Making a flashlight
The image is just black with a blurred hole(transparent) in the centerKudomiku wrote:Oh my... that is perfect! Thank you very much!
I don't really understand how you achieved that though, I mean with the flashlight image?
Re: Making a flashlight
How does it cut through the previous image though to make a hole? Pretty clever
Oh... it doesn't:
Hmm... This is kind of what I need but, hmm.
Guess I could just use setScissor to the size of the flashlight image.
Oh... it doesn't:
Code: Select all
love.graphics.draws(background, x, y, x-fw/2, y-fh/2, fw, fh)
Guess I could just use setScissor to the size of the flashlight image.
Re: Making a flashlight
That or draw black around it. 4 rectangles)Kudomiku wrote:How does it cut through the previous image though to make a hole? Pretty clever
Oh... it doesn't:
Hmm... This is kind of what I need but, hmm.Code: Select all
love.graphics.draws(background, x, y, x-fw/2, y-fh/2, fw, fh)
Guess I could just use setScissor to the size of the flashlight image.
Who is online
Users browsing this forum: Google [Bot] and 3 guests