Page 4 of 9
Re: ËNVY (LÖVE Framework)
Posted: Sun Nov 23, 2008 4:40 pm
by Voker57
Cool, and this one has Wrath version that really works!
Re: ËNVY (LÖVE Framework)
Posted: Mon Nov 24, 2008 10:29 pm
by Borsty
Hey Kudomiku, I just came across a problem with doing maths on a shape's points. And since the getPoints() function returns a stack rather than a table I wrote a small util function:
Code: Select all
local function getShapeTable( ... )
local result = {}
for i = 0, ( math.floor( #arg / 2 ) - 1 ) do
local x = arg[i*2 + 1] or 0
local y = arg[i*2 + 2] or 0
result[i+1] = envy.vector:new( x, y )
end
return result
end
function envy.entity.class:getShapeTable()
return getShapeTable( self:getShape():getPoints() )
end
function envy.entities.class:getEdges()
local points = self:getShapeTable()
local result = {}
for i = 1, #points do
local cp = points[ i ]
local np = points[i + 1] or points[ 1 ]
local vec = ( np - cp )
local normal = envy.vector:newFromAngle( vec:angle() + 90 )
result[i] = { origin = cp, vector = vec, normal = normal }
end
return result
end
If you wonder why I wrote this, you asked for shadows huh.. I'm writing a shadow "engine" based on this article:
http://www.gamedev.net/reference/articl ... le2032.asp
[Edit]
Check this:
http://love2d.org/forum/viewtopic.php?f ... 2850#p2850
Re: ËNVY (LÖVE Framework)
Posted: Mon Nov 24, 2008 11:55 pm
by Kuromeku
Oh my! I was reading that SAME article, I was going to do it too.
But as you're doing it I'll leave it to you.
Mind if I add that function to ËNVY's util library (credit to you, of course).
Re: ËNVY (LÖVE Framework)
Posted: Tue Nov 25, 2008 12:01 am
by Borsty
Sure, but it's a little more than just utility functions, it needs further implementation. You basically have to add all shapes and remove em before they get removed. Dunno, we'll find a good solution
I'll add a quick and nasty quadtree thingy to speedup shadow-ray-collision-detection, so you can set the shadow's alpha which makes it look a little better.
Re: ËNVY (LÖVE Framework)
Posted: Tue Nov 25, 2008 12:05 am
by Kuromeku
Yeah, add me to Steam Friends, spec_soldier so we can discuss this
I'd love to work with you on some things, you're clearly a guy who knows what he's doing
Re: ËNVY (LÖVE Framework)
Posted: Tue Nov 25, 2008 1:13 pm
by Borsty
Will add you when I'm home later today, here's another vector function that could come in handy:
Code: Select all
function envy.vector.class:rotate( angle )
angle = math.rad( angle )
local ca = math.cos( angle )
local sa = math.sin( angle )
return envy.vector:new( ( self.x * ca - self.y * sa ), ( self.x * sa + self.y * ca ) )
end
If you just want to rotate something
Re: ËNVY (LÖVE Framework)
Posted: Tue Nov 25, 2008 2:57 pm
by Kuromeku
Thank ye.
Re: ËNVY (LÖVE Framework)
Posted: Tue Nov 25, 2008 2:57 pm
by Kuromeku
Wait, isn't that just like rotateAround?
Re: ËNVY (LÖVE Framework)
Posted: Tue Nov 25, 2008 4:37 pm
by Borsty
Kinda, but I can't be arsed to define a null vector just to rotate something
Re: ËNVY (LÖVE Framework)
Posted: Tue Nov 25, 2008 5:32 pm
by Kuromeku
Interesting, I could always make it an optional argument?