Page 1 of 1
Distorting image to form shadow on wall [fake perspective.]
Posted: Sat Sep 22, 2012 2:44 pm
by Ohsin
Hello love2d
This is my first post and in this I want to share and seek some information.I got introduced to love2d through game 'Journey to the center of Hawkthorne (fan made game based on community TV show) and I wanted to create an effect of shadow on wall for fun
after some head banging i came up with this solution.
Divide screen into zones(canvas) like Floor ,Ceiling and Wall.For each zone Draw shadow image separately but for 'Ceiling' and 'Floor' skew image according to perspective and for 'Wall' keep it as it is.
My very first love file so code may be ugly ,I have very basic knowledge of Lua .
ScreenShot :
- xshVA.png (24.38 KiB) Viewed 354 times
Please tell if it can be done some other way.Thank you!
Re: Distorting image to form shadow on wall [fake perspectiv
Posted: Sat Sep 22, 2012 6:58 pm
by jonyzz
Just an idea: Use love.graphics.setScissor to limit drawing area (floor/ceiling/wall) instead of using canvas.
Re: Distorting image to form shadow on wall [fake perspectiv
Posted: Wed Sep 26, 2012 3:06 pm
by Ohsin
How can I use 'scissors' method to create more than one independently drawable area on screen? It seems it can only define an ractangular area to draw on but that's it.I also tried using Quads but i don't know if i can skew them like images.
Re: Distorting image to form shadow on wall [fake perspectiv
Posted: Wed Sep 26, 2012 3:09 pm
by Nixola
You can use a scissor to define an area and draw into it, then use a new scissor to define a new area and draw into it and a last scissor to define a third area to draw into
Re: Distorting image to form shadow on wall [fake perspectiv
Posted: Wed Sep 26, 2012 3:54 pm
by Ohsin
Nixola wrote:You can use a scissor to define an area and draw into it, then use a new scissor to define a new area and draw into it and a last scissor to define a third area to draw into
That is exactly what I want ! But if i setScissors then draw then setScissors and draw again.The very first draw area gives weird results.Like in following example ball draws fine in second area but in first it starts to 'paint' the area.
Code: Select all
function love.update()
mx = love.mouse.getX()
my = love.mouse.getY()
end
function love.draw()
love.graphics.setScissor( 0, 0,200,200 )
love.graphics.setColor(255,0,0)
love.graphics.circle("fill", mx, my,50,25)
love.graphics.setScissor( 0, 200,200,200 )
love.graphics.setColor(0,255,0)
love.graphics.circle("fill", mx, my,50,25)
end
too new so sorry for if it is silly .
Re: Distorting image to form shadow on wall [fake perspectiv
Posted: Wed Sep 26, 2012 3:56 pm
by Boolsheet
You have to disable the scissor or love.graphics.clear (called just before love.draw) will only clear that part of the screen. Just call love.graphics.setScissor without arguments to do that:
Re: Distorting image to form shadow on wall [fake perspectiv
Posted: Wed Sep 26, 2012 3:58 pm
by Ohsin
That did it! Thank you very much.
I should have used it just like setCanvas ...silly me