Page 1 of 7
lQuery
Posted: Wed Mar 02, 2011 5:26 am
by RPG
lQuery (luaQuery or loveQuery) - tiny framework similar to jQuery in JavaScript.
Documentation:
http://lquery.scriptumplus.ru
Downloads: https://github.com/scriptum/lQuery/downloads
Key features:
integrated scene graph manager - all objects merged into one, easy-to-manipulate scene graph.
entity-based - all in the game are entities: menu, widgets, objects, mouse, players. You can specify entity's behavior. Example:
Code: Select all
circle = Entity:new(screen)
:move(400,300)
:draw(function(s) --function that displays entity
G.circle("fill", s.x, s.y, s.R, 2*s.R)
end)
Code: Select all
mouse = Entity:new(screen):draw(function(s) --unusual type of entity: mouse cursor position, useful for demonstrations
love.mouse.setPosition( s.x, s.y )
end)
asynchronous programming - don't think about time, just write rules for the game
animate anything - small and powerful animation library, multi-queue animation. Example:
Code: Select all
circle:animate({x=100, y=100}) -- move circle from current position to 100, 100
Code: Select all
mouse:animate({x=100, y=100}) -- move mouse cursor from current position to 100, 100
Code: Select all
player:animate({health=100}) -- increase player's health (you can animate any parameter of the entity)
chain methods
Code: Select all
box = Entity:new():move(10,10):animate({x=100}):animate({y=100})
events - specify events for entities similar to JavaScript, multiple handlers per event
Code: Select all
circle:click(function()
--some action here
end)
Animation queue See below
Small demonstration: animations, events (hover mouse on circle, click on circle)
Repository:
http://github.com/scriptum/lQuery
Re: lQuery
Posted: Wed Mar 02, 2011 6:24 am
by TechnoCat
Well, you are certainly chaining events like JQuery. That is for sure.
Re: lQuery
Posted: Wed Mar 02, 2011 7:38 am
by BlackBulletIV
Looks good. Method chaining looks cool.
Using entities is a good practice, I use the idea inside of my
Grace framework (although inside of Worlds, with Layers and Tags as well).
Good luck!
Re: lQuery
Posted: Wed Mar 02, 2011 12:24 pm
by RPG
BlackBulletIV wrote:Looks good. Method chaining looks cool.
Using entities is a good practice, I use the idea inside of my
Grace framework (although inside of Worlds, with Layers and Tags as well).
Good luck!
Your work looks great, but... unfortunatly, Grace framework isn't working on my system (Linux). I think this is due to case-sensitive filesystem.
Re: lQuery
Posted: Wed Mar 02, 2011 8:55 pm
by BlackBulletIV
Mine would be a case-sensitive filesystem (I'm on a Mac) too. If you're grabbing the latest development version (up and coming alpha 5, in branch wrapper) it probably won't work. I haven't tested it in a while because of a huge paradigm shift in the code. But if you've got alpha 4, it should work without crashing on first try. Can you give me the error so I can know where the problem's coming from?
Re: lQuery
Posted: Wed Mar 02, 2011 10:45 pm
by RPG
Code: Select all
bash-4.1$ love image/
Error: [string "main.lua"]:1: module '../../src.init' not found:
no field package.preload['../../src.init']
no file './//////src/init.lua'
no file '/usr/share/lua/5.1///////src/init.lua'
no file '/usr/share/lua/5.1///////src/init/init.lua'
no file '/usr/lib/lua/5.1///////src/init.lua'
no file '/usr/lib/lua/5.1///////src/init/init.lua'
no file '/usr/share/lua/5.1///////src/init.lua'
no file '/usr/share/lua/5.1///////src/init/init.lua'
no file './//////src/init.so'
no file '/usr/lib/lua/5.1///////src/init.so'
no file '/usr/lib64/lua/5.1///////src/init.so'
no file '/usr/lib/lua/5.1/loadall.so'
no file './.so'
no file '/usr/lib/lua/5.1/.so'
no file '/usr/lib64/lua/5.1/.so'
no file '/usr/lib/lua/5.1/loadall.so'
no file "//////src/init" in LOVE game directories.
stack traceback:
[C]: in function 'require'
[string "main.lua"]:1: in main chunk
[C]: in function 'require'
[string "boot.lua"]:293: in function <[string "boot.lua"]:219>
[C]: in function 'xpcall'
For all versions:)
Re: lQuery
Posted: Thu Mar 03, 2011 12:58 am
by BlackBulletIV
Oh yeah, those don't work because Lua converts the dots to slashes, therefore being unable to locate them. You can fix it by bringing the folders out of the tests/examples folder, to the top level, and changing the require to 'src.init'.
(BTW: The image test won't work unless you have some of the image processing code I wrote in the (rather old) image branch)
EDIT: 300 posts! Yay!
Re: lQuery
Posted: Thu Mar 03, 2011 2:38 am
by RPG
BlackBulletIV wrote:You can fix it by bringing the folders out of the tests/examples folder, to the top level, and changing the require to 'src.init'.
I tried... another errors was there.
New in lQuery
Animation queue. Original feature for incredible animation effects. Animation frames in queue runs in sequence: when previous animation ends, playing next animation frame. If you want to play two different animations simultaneously, just put animation frames into separate queues and they will be independent.
Example:
Code: Select all
ball = Entity:new_circle()
:move(400,300)
:animate({x=30}, {speed=0.5,queue='x'})
:animate({x=500}, {speed=0.5,queue='x'})
:animate({y=30}, {speed=0.8,queue='y'})
:animate({y=500}, {speed=0.2,queue='y'}) --cool animation effect
See in action:
Re: lQuery
Posted: Thu Mar 03, 2011 3:24 am
by BlackBulletIV
RPG wrote:BlackBulletIV wrote:You can fix it by bringing the folders out of the tests/examples folder, to the top level, and changing the require to 'src.init'.
I tried... another errors was there.
Well, um, could you say what they are? As said, if you're trying the image test, it won't work unless you have the image processing code.
Re: lQuery
Posted: Thu Mar 03, 2011 7:12 am
by RPG
Code: Select all
bash-4.1$ love physics/
Error: Syntax error: [string "src/data/Vector2.lua"]:27: 'then' expected near 'return'
stack traceback:
[C]: ?
[C]: in function 'require'
[string "src/data/init.lua"]:4: in main chunk
[C]: in function 'require'
[string "src/init.lua"]:19: in main chunk
[C]: in function 'require'
[string "main.lua"]:1: in main chunk
[C]: in function 'require'
[string "boot.lua"]:293: in function <[string "boot.lua"]:219>
[C]: in function 'xpcall'