Löve "Light vs. Shadow" Engine [0.4.3]

Showcase your libraries, tools and other projects that help your fellow love users.
Post Reply
SNK1337
Prole
Posts: 16
Joined: Sun Jan 05, 2014 2:30 pm

Re: Löve "Light vs. Shadow" Engine [0.4.3]

Post by SNK1337 »

WetDesertRock wrote:If you set the light worlds translation by the same value you set loves translation, and it messes up, then its a bug I think. But you should set both values to the same.
I put this at the start of my love.draw() just to test:

Code: Select all

love.graphics.translate(100, 100)
lightWorld.setTranslation(getLightTranslation(100, 100, 1))
Oh, and this is the code I used in getLightTranslation, basically just some modified variables:

Code: Select all

function getLightTranslation(x, y, scale)
    local tx,ty = width/(2*scale), height/(2*scale)
    tx = tx-x
    ty = ty-y
    return -tx,-ty
end
And this is the result: http://puu.sh/83p9e.png
What am I doing wrong? Again, there's a picture of what it should look like in my earlier post above.
Last edited by SNK1337 on Thu Apr 10, 2014 4:30 pm, edited 1 time in total.
WetDesertRock
Citizen
Posts: 67
Joined: Fri Mar 07, 2014 8:16 pm

Re: Löve "Light vs. Shadow" Engine [0.4.3]

Post by WetDesertRock »

Whats wrong with:

Code: Select all

love.graphics.translate(100, 100)
lightWorld.setTranslation(100,100)
Shouldn't that work?
SNK1337
Prole
Posts: 16
Joined: Sun Jan 05, 2014 2:30 pm

Re: Löve "Light vs. Shadow" Engine [0.4.3]

Post by SNK1337 »

WetDesertRock wrote:Whats wrong with:

Code: Select all

love.graphics.translate(100, 100)
lightWorld.setTranslation(100,100)
Shouldn't that work?
Nope, that definitely doesn't work at all http://puu.sh/83psb.jpg
User avatar
PriorBlue
Prole
Posts: 43
Joined: Fri Feb 28, 2014 3:46 am
Location: Munich, Germany

Re: Löve "Light vs. Shadow" Engine [0.4.3]

Post by PriorBlue »

SNK1337 wrote:How exactly is translation used with this? If I use the lightWorld.setTranslation() before drawing everything, I get this: http://puu.sh/82uxo.jpg while it's supposed to look like this: http://puu.sh/82uyY.jpg

Do I also have to use love.graphics.translate() at some point? Or are there any other functions I need to get it working properly?
can you post or send me a little code example with your translation functions for testing. I personally don't use camera translations in my projects, because it cause many problems :), so maybe there is a tiny bug in the engine.
SNK1337
Prole
Posts: 16
Joined: Sun Jan 05, 2014 2:30 pm

Re: Löve "Light vs. Shadow" Engine [0.4.3]

Post by SNK1337 »

PriorBlue wrote:
SNK1337 wrote:How exactly is translation used with this? If I use the lightWorld.setTranslation() before drawing everything, I get this: http://puu.sh/82uxo.jpg while it's supposed to look like this: http://puu.sh/82uyY.jpg

Do I also have to use love.graphics.translate() at some point? Or are there any other functions I need to get it working properly?
can you post or send me a little code example with your translation functions for testing. I personally don't use camera translations in my projects, because it cause many problems :), so maybe there is a tiny bug in the engine.
I just created a little example .love that should let you translate by (10, 10) by holding k. Not really a camera, but I suppose it should be enough for demonstration purposes.

I have the feeling I'm just misunderstanding something and doing it wrong, so please tell me if there's some mistake I'm making. I also tried the getLightTranslation function above by the way, and got similar results, which is why I didn't include it.

My actual camera does pretty much the same thing as this: push, translate, draw stuff, pop. I just felt it'd be easier to make something simpler here for testing.
Attachments
Light Translation.love
(18.29 KiB) Downloaded 203 times
User avatar
ArchAngel075
Party member
Posts: 319
Joined: Mon Jun 24, 2013 5:16 am

Re: Löve "Light vs. Shadow" Engine [0.4.3]

Post by ArchAngel075 »

Is there any way to specify a larger light "shape"?

For instance, a space-ship themed game with lasers, the lasers are continuous rather than a short beams.
Each laser is a light source all over its "body", almost like a long rectangular light source.

I can achieve the effect using many sources in increments but that can be stressful in the long run and can create odd shadows...
giann
Prole
Posts: 42
Joined: Fri Jun 28, 2013 11:38 am

Re: Löve "Light vs. Shadow" Engine [0.4.3]

Post by giann »

Great work ! I can't thank you enough for this !

My game is a top-down point of view.
So shadowType image is not quite what I want to cast shadows for my sprites.
I'm trying to use polygon shadowType instead but I'm still getting a rectangle shadow.

Here is the code:

Code: Select all

    vehicle = love.graphics.newImage('data/img/ships/explorer.png')
    vehicleGlow = love.graphics.newImage('data/img/ships/explorer-glow.png')
    vehicleImage = game.light.newImage(vehicle, 200, 130)
    vehicleImage.setGlowMap(vehicleGlow)
    vehicleImage.setShadowType('polygon', 0, vehicle:getHeight()/2, vehicle:getWidth(), 0, vehicle:getWidth(), vehicle:getHeight());
Any idea why ?
User avatar
Jeeper
Party member
Posts: 611
Joined: Tue Mar 12, 2013 7:11 pm
Contact:

Re: Löve "Light vs. Shadow" Engine [0.4.3]

Post by Jeeper »

Anyone know how to make a shadow based on an image(Like this http://onepixelahead.de/love2d_polyshadow18.png)? The documentation is not super clear on that yet (understandable as this is still quite early on).

Also, would this work on something animated?
giann
Prole
Posts: 42
Joined: Fri Jun 28, 2013 11:38 am

Re: Löve "Light vs. Shadow" Engine [0.4.3]

Post by giann »

You set the shadow type to image like that:

Code: Select all

lightImage.setShadowType('image')
User avatar
Jeeper
Party member
Posts: 611
Joined: Tue Mar 12, 2013 7:11 pm
Contact:

Re: Löve "Light vs. Shadow" Engine [0.4.3]

Post by Jeeper »

giann wrote:You set the shadow type to image like that:

Code: Select all

lightImage.setShadowType('image')
Yeah, but if you have a transparent image with like a circle or triangle, then the shadow is still a square. It just takes the dimensions of the image without accomplishing the effect that I linked to.
Post Reply

Who is online

Users browsing this forum: No registered users and 29 guests