ËNVY (LÖVE Framework)

Showcase your libraries, tools and other projects that help your fellow love users.
User avatar
Voker57
Prole
Posts: 29
Joined: Mon Nov 03, 2008 9:38 am
Location: Russia, Krasnodar
Contact:

Re: ËNVY (LÖVE Framework)

Post by Voker57 »

Cool, and this one has Wrath version that really works!
User avatar
Borsty
Citizen
Posts: 66
Joined: Sun Oct 19, 2008 10:29 pm
Location: Hamburg, Germany
Contact:

Re: ËNVY (LÖVE Framework)

Post 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

:P

[Edit]
Check this: http://love2d.org/forum/viewtopic.php?f ... 2850#p2850
User avatar
Kuromeku
Party member
Posts: 166
Joined: Sun Jul 20, 2008 5:45 pm

Re: ËNVY (LÖVE Framework)

Post 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).
User avatar
Borsty
Citizen
Posts: 66
Joined: Sun Oct 19, 2008 10:29 pm
Location: Hamburg, Germany
Contact:

Re: ËNVY (LÖVE Framework)

Post 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.
User avatar
Kuromeku
Party member
Posts: 166
Joined: Sun Jul 20, 2008 5:45 pm

Re: ËNVY (LÖVE Framework)

Post by Kuromeku »

Yeah, add me to Steam Friends, spec_soldier so we can discuss this :D

I'd love to work with you on some things, you're clearly a guy who knows what he's doing :)
User avatar
Borsty
Citizen
Posts: 66
Joined: Sun Oct 19, 2008 10:29 pm
Location: Hamburg, Germany
Contact:

Re: ËNVY (LÖVE Framework)

Post 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 ;)
User avatar
Kuromeku
Party member
Posts: 166
Joined: Sun Jul 20, 2008 5:45 pm

Re: ËNVY (LÖVE Framework)

Post by Kuromeku »

Thank ye.
User avatar
Kuromeku
Party member
Posts: 166
Joined: Sun Jul 20, 2008 5:45 pm

Re: ËNVY (LÖVE Framework)

Post by Kuromeku »

Wait, isn't that just like rotateAround?
User avatar
Borsty
Citizen
Posts: 66
Joined: Sun Oct 19, 2008 10:29 pm
Location: Hamburg, Germany
Contact:

Re: ËNVY (LÖVE Framework)

Post by Borsty »

Kinda, but I can't be arsed to define a null vector just to rotate something :P
User avatar
Kuromeku
Party member
Posts: 166
Joined: Sun Jul 20, 2008 5:45 pm

Re: ËNVY (LÖVE Framework)

Post by Kuromeku »

Interesting, I could always make it an optional argument?

:)
Post Reply

Who is online

Users browsing this forum: No registered users and 24 guests