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

Showcase your libraries, tools and other projects that help your fellow love users.
Post Reply
User avatar
Wesleyyy
Prole
Posts: 4
Joined: Mon Oct 28, 2013 7:08 pm
Location: Netherlands
Contact:

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

Post by Wesleyyy »

This is absolutely fantastic!

After a few hours of modifying code, I got it to work with a tower defense game I'm making. I have next to no experience with LÖVE but it was super easy to implement!
Image
SNK1337
Prole
Posts: 16
Joined: Sun Jan 05, 2014 2:30 pm

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

Post by SNK1337 »

When trying the example.lua, I get this error:

Code: Select all

Error

light.lua:90: Value size of 2 does not match variable size of 3.


Traceback

[C]: in function 'send'
light.lua:90: in function 'update'
main.lua:49: in function 'draw'
[C]: in function 'xpcall'
(Here's a screenshot: http://puu.sh/7YJ6t.png)

I noticed that this error does not occur when I comment out

Code: Select all

lightMouse.setPosition(love.mouse.getX(), love.mouse.getY()) 
in love.update(). However, I obviously can't move the light then. It also happens if I try to set the position to static values such as 5, 5. The main.lua does work, by the way.


EDIT: Just found it a moment after posting this, while comparing main.lua and example.lua (because main.lua works). The function lightMouse.setPosition() needs 3 values instead of 2, because one is required for the z-value (height) of the light.

This should also be changed in the example code in the wiki, as the code there also only uses 2 values.


Also, any tips on how to implement this when using love.graphics.scale()?
User avatar
Luke100000
Party member
Posts: 232
Joined: Mon Jul 22, 2013 9:17 am
Location: Austria
Contact:

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

Post by Luke100000 »

Great work! Maybe I can use this in my current game.
I found here an error: if light is exatly near a small object, there will be a strange shadow.
strange shadow.jpg
strange shadow.jpg (39.03 KiB) Viewed 5895 times
(bad resulution, but you know what I mean)
davisdude
Party member
Posts: 1154
Joined: Sun Apr 28, 2013 3:29 am
Location: North Carolina

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

Post by davisdude »

I think that could be the "z-level" of the light- imagine a sunrise. The light is "peaking" over the top of the box.
Or it could just be a bug. :)
GitHub | MLib - Math and shape intersections library | Walt - Animation library | Brady - Camera library with parallax scrolling | Vim-love-docs - Help files and syntax coloring for Vim
SNK1337
Prole
Posts: 16
Joined: Sun Jan 05, 2014 2:30 pm

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

Post by SNK1337 »

davisdude wrote:I think that could be the "z-level" of the light- imagine a sunrise. The light is "peaking" over the top of the box.
Or it could just be a bug. :)
It also happens when z is 0. I don't really know how the shader works yet, but I assume the shadow just isn't drawn far enough because it has a restriction on how big the surface of the shadow can be, or something similar to that.
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 »

Luke100000 wrote:I found here an error: if light is exatly near a small object, there will be a strange shadow.
strange shadow.jpg
This problem is fixed now.

I also implemented the love2d browser for the examples.
Image
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 »

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?
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 »

You will need to use lightWorld.setTranslation() if you are using love's translation. Some more information around here: viewtopic.php?f=5&t=77418&start=20#p164433
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:You will need to use lightWorld.setTranslation() if you are using love's translation. Some more information around here: viewtopic.php?f=5&t=77418&start=20#p164433


I still get very strange results with this. Do I have to use love's translation too? If so, when? And do I use the standard values there, or the ones your function returns?

I'm not using the Hump camera by the way, I'm using my own which is basically just love.graphics.translate() packed into nice functions and smooth movement.
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 »

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.
Post Reply

Who is online

Users browsing this forum: No registered users and 156 guests