Grace (Alpha 4) - object-oriented framework for LÖVE

Showcase your libraries, tools and other projects that help your fellow love users.
Araqiel
Citizen
Posts: 54
Joined: Sat Oct 30, 2010 7:33 pm

Re: Grace (Alpha 3) - object-oriented framework for LÖVE

Post by Araqiel »

Yep, I've seen it. :P But some things just completely confuse me. For example, what do I pass to Input.define()? I've been experimenting. So far, the closest I've come to getting it to work is this:

Code: Select all

Input.define('turnLeft', {'key', 'a'})
But that doesn't work.

EDIT: I found something that WORKS, but is most likely not what I should be doing:

Code: Select all

Input.define('turnLeft', {'a', 'a'})
EDIT (again): Herpaderp, took a step back to when I didn't know Lua.

I think this is how the code is intended to be used, but there has to be a shorter way?

Code: Select all

keyMap = {}
	keyMap['key'] = 'a'
	Input.define('turnLeft', keyMap)
	keyMap = {}
	keyMap['key'] = 'd'
	Input.define('turnRight', keyMap)
SOLVED:

Code: Select all

	Input.define('turnLeft', {['key']='a'})
	Input.define('turnRight', {['key']='d'}) 
User avatar
BlackBulletIV
Inner party member
Posts: 1261
Joined: Wed Dec 29, 2010 8:19 pm
Location: Queensland, Australia
Contact:

Re: Grace (Alpha 3) - object-oriented framework for LÖVE

Post by BlackBulletIV »

Oh heck, no wonder you're having trouble. That method was only recently added, and for some reason I didn't document it right then and there. That will be fixed. :)

You'll probably want to look inside the physics test, as it has the use of physics, entities, worlds, the camera and all. It's not fully up-to-date with the framework (I don't think it uses Input.define for example) but it should be of help: https://github.com/BlackBulletIV/grace/ ... ts/physics.

EDIT: Taking a look at the Input.define method again, it would probably be more useful in this syntax:

Code: Select all

Input.define{'supershot', key = 'space', key = 'shift', mouse = 'l'}
User avatar
pygy
Citizen
Posts: 98
Joined: Mon Jan 25, 2010 4:06 pm

Re: Grace (Alpha 3) - object-oriented framework for LÖVE

Post by pygy »

BlackBulletIV wrote:

Code: Select all

Input.define{'supershot', key = 'space', key = 'shift', mouse = 'l'}
That won't work (brainfart, I guess ;-))

Code: Select all

Input.define{'supershot', key = {'space', 'shift'}, mouse = 'l'}
Hermaphroditism is not a crime. -- LSB Superstar

All code published with this account is licensed under the Romantic WTF public license unless otherwise stated.
User avatar
BlackBulletIV
Inner party member
Posts: 1261
Joined: Wed Dec 29, 2010 8:19 pm
Location: Queensland, Australia
Contact:

Re: Grace (Alpha 3) - object-oriented framework for LÖVE

Post by BlackBulletIV »

Argh, it wouldn't, and neither would the current method in case of multiple keys. Thanks for that, I'll get onto implementing it soon.

A question (which I'll probably make into a poll), should Grace try to cover up Love with an object-oriented layer? The advantages of this are:

1. It will allow tighter integration between the classes. For example, instead of supplying an (say) Image to the Graphic class, you would just create an instance of the Image class, which would be a subclass of Graphic.
2. It would make the making of games totally object-oriented, making for a consistent presentation.

The disadvantage (so far as I see it) is this: it would add another layer of code (I'm don't think this is a big problem though).

EDIT: The new table syntax has been applied to Input.define (untested though).
User avatar
thelinx
The Strongest
Posts: 857
Joined: Fri Sep 26, 2008 3:56 pm
Location: Sweden

Re: Grace (Alpha 3) - object-oriented framework for LÖVE

Post by thelinx »

Shouldn't the base class for Images and the likes be called Drawable?

That's the naming convention in the LÖVE source code.
User avatar
BlackBulletIV
Inner party member
Posts: 1261
Joined: Wed Dec 29, 2010 8:19 pm
Location: Queensland, Australia
Contact:

Re: Grace (Alpha 3) - object-oriented framework for LÖVE

Post by BlackBulletIV »

I guess it probably should if a wrapper is created.
User avatar
BlackBulletIV
Inner party member
Posts: 1261
Joined: Wed Dec 29, 2010 8:19 pm
Location: Queensland, Australia
Contact:

Re: Grace (Alpha 4) - object-oriented framework for LÖVE

Post by BlackBulletIV »

Alpha 4 has been released, with a number of new things. The main thing is probably that it now supports MiddleClass 1.3, which means a big backward incompatible update.

Here's the changes:
* [Added] Color class now has the grayscale and sepia functions.
* [Added] Graphics can now have color tints as well.
* [Added] Logging to a text file to Debug.
* [Added] The quit() function, a utility to quit the game.
* [Added] Layers can now have color tints. Most useful for setting the alpha of a layer.

* [Changed] Converted to use MiddleClass 1.3.
* [Changed] New table syntax for Input.define.
* [Changed] Requiring debug.init now automatically calls Debug.enable.
* [Changed] Debug now sets the color back to what it was, rather than white.

* [Fixed] Input.define can now take multiple keys and mouse buttons.

Has anyone got any opinion on the poll I've put up there?
User avatar
kikito
Inner party member
Posts: 3153
Joined: Sat Oct 03, 2009 5:22 pm
Location: Madrid, Spain
Contact:

Re: Grace (Alpha 4) - object-oriented framework for LÖVE

Post by kikito »

Nice to see the great pace this lib is having.

Concerning the poll: While I was developing PÄSSION, I asked the same question myself. Both options seemed to have their own advantages and disadvantages, so I ended up not implementing a LÖVE "wrapper" - I concentrated on other stuff.

The same happens now. Both options seem valid, I don't have any preference, and hence I haven't voted. Sorry I can't help more.

Also, I should mention that theLinx has already implemented an oop wrapper. Maybe you can reuse some of his work, if you end up deciding for it.
When I write def I mean function.
User avatar
BlackBulletIV
Inner party member
Posts: 1261
Joined: Wed Dec 29, 2010 8:19 pm
Location: Queensland, Australia
Contact:

Re: Grace (Alpha 4) - object-oriented framework for LÖVE

Post by BlackBulletIV »

Thanks. :) The changes are slowing down though, which is might be a sign of stability creeping its way into the framework.

Yeah, I think a Love wrapper is not very high priority, if I even choose to go ahead with it.

I did see that one, I'll have to check it out in more detail.
User avatar
BlackBulletIV
Inner party member
Posts: 1261
Joined: Wed Dec 29, 2010 8:19 pm
Location: Queensland, Australia
Contact:

Re: Grace (Alpha 4) - object-oriented framework for LÖVE

Post by BlackBulletIV »

A little bit of news. Grace now has it's own separate tests repo. This will be a collection of tests using telescope (with my own test runner so I can use it in Love) to make sure everything is working. So far I've only done most of the Grace module's functions. There's a lot to write, but this will help Grace become more stable (as it's hardly tested right now).

Alpha 5 is in the works, although it won't be done for a while; it's a huge change. I'm creating a Love wrapper, but not your usual kind. This wrapper will integrate seamlessly with the organisational functionality of Grace, not just cover over Love with classes.
Post Reply

Who is online

Users browsing this forum: No registered users and 22 guests