[javascript]Luv.js

Discuss any ports of LÖVE to different platforms.
User avatar
miko
Party member
Posts: 409
Joined: Fri Nov 26, 2010 2:25 pm
Location: PL

Re: [javascript]Luv.js

Post by miko » Tue Apr 16, 2013 7:43 am

kikito wrote:You can see some usage examples on the examples folder. Feel free to comment, I'm still learning the language.
Works OK for me, even on Galaxy S3 default web browser (the only issue being touch input/mousepress). This is so great that it would make me to start playing with JS. Will be watching you ;)
My lovely code lives at GitHub: http://github.com/miko/Love2d-samples

User avatar
kikito
Inner party member
Posts: 3151
Joined: Sat Oct 03, 2009 5:22 pm
Location: Madrid, Spain
Contact:

Re: [javascript]Luv.js

Post by kikito » Tue Apr 16, 2013 7:55 am

Jasoco wrote:Doesn't a JavaScript version of Box2D already exist anyway? It's even included in another JavaScript/HTML5 game creating API system.
Yes, there are several projects that translate Box2d to javascript. The question was (or at least that's how I read it) whether there would be one "included by default" into Luv.js.
miko wrote:Works OK for me, even on Galaxy S3 default web browser (the only issue being touch input/mousepress). This is so great that it would make me to start playing with JS. Will be watching you ;)
I've been able to try it on an Ipad and it works reasonably well, too! There's a branch where've done a touch interface for mobile devices, will let you guys know when it's done.

EDIT: I have now added support for touch events ... and tweening! Touch events are not Internet Explorer-compatible, I'm afraid.

The demo, with some tweening, is here (you will need an ipad or touch-compatible dispositive to see anything, otherwise it will be a black screen):

http://kikito.github.io/luv.js/examples/fingers.html

The touch interface is in luv.touch.

The timing/tweening interface is inside luv.timer, in the form of luv.timer.after, luv.timer.every & luv.timer.tween. Each of them has a specialized submodule inside luv.timer. The tweening one is specially interesting.
When I write def I mean function.

FireZenk
Prole
Posts: 25
Joined: Tue Apr 09, 2013 4:14 pm
Location: Valencia, Spain
Contact:

Re: [javascript]Luv.js

Post by FireZenk » Sun Sep 15, 2013 3:30 pm

Have you decided whether or not to insert sound?

If so, here I leave the source code of an html5 player I created and can serve as a basis for using the HTML5 Audio API :awesome:
https://github.com/FireZenk/html5player

User avatar
kikito
Inner party member
Posts: 3151
Joined: Sat Oct 03, 2009 5:22 pm
Location: Madrid, Spain
Contact:

Re: [javascript]Luv.js

Post by kikito » Sun Sep 15, 2013 6:01 pm

Hi there,

Indeed, Luv.js has sound. Simple example here: http://kikito.github.io/luv.js/examples/#ding and API docs here: http://kikito.github.io/luv.js/docs/audio.html

Development on that lib is on hold at the moment since I needed to find a good way to deal with collisions. I'm doing bump 2.0 in Lua, and then will export it to Luv.

Regards!
When I write def I mean function.

User avatar
Roland_Yonaba
Inner party member
Posts: 1562
Joined: Tue Jun 21, 2011 6:08 pm
Location: Ouagadougou (Burkina Faso)
Contact:

Re: [javascript]Luv.js

Post by Roland_Yonaba » Sun Sep 15, 2013 7:20 pm

That library makes me want to learn JS.
Question: from your own insight, can you say if it is possible to write a kind of wrapper for Löve games, written in Lua ?
I don't know if it will just take to bind the API functions/methods in JS to Löve Lua API...But it would be cool to have this possibility, hopefully when this project will be more complete. :awesome:

FireZenk
Prole
Posts: 25
Joined: Tue Apr 09, 2013 4:14 pm
Location: Valencia, Spain
Contact:

Re: [javascript]Luv.js

Post by FireZenk » Sun Sep 15, 2013 7:43 pm

Thanks Kikito

I've been playing around with Luv.js and the truth is that it preserves the essence of Love2D, thanks for that :awesome:

@Roland_Yonaba: I think we don't need take this way...
Javascript is fairly easy to learn and the syntax is not so different from Lua.
There is also a plugin for Chrome that runs .love files in the browser (is the simplest way to execute love2d in the browser for now)

User avatar
kikito
Inner party member
Posts: 3151
Joined: Sat Oct 03, 2009 5:22 pm
Location: Madrid, Spain
Contact:

Re: [javascript]Luv.js

Post by kikito » Sun Sep 15, 2013 8:05 pm

Roland_Yonaba wrote:That library makes me want to learn JS.
Question: from your own insight, can you say if it is possible to write a kind of wrapper for Löve games, written in Lua ?
It is possible to write most of it. For certain definitions of possible.
  • Browsers certainly have the graphical prowness, at least modern ones. They even have shaders.
  • Audio support is still shaky. Chrome is able to do everything LÖVE does and then some more. The rest can do very basic stuff (play, pause, rewind). Handling multiple simultaneous sources is a pain (just like in LÖVE, yay!). And the available formats depend on the browser. The safest bet is providing at least mp3 and ogg (or only ogg, if you don't care about IE).
  • Lua is already working on the browser.
  • It is possible to download and unzip a file to memory in js.
That said:
  • It would always lag behind canonical LÖVE, since it would be a reimplementation.
  • Expect platform flakiness, especially regarding execution speed (mobile browsers!)
  • Sound issues will happen
  • I also have concerns about speed.
  • While I have tried to mimic the spirit of LÖVE in Luv, it is definitively not a 1-to-1 relation. Some of the design decisions I made are different from the ones the LÖVE team took (and that's alright).
So while it is possible, I'm not sure it is even practical. Especially since the love-nacl plugin works so well.
FireZenk wrote:I've been playing around with Luv.js and the truth is that it preserves the essence of Love2D, thanks for that :awesome:
You are too kind ^^. Beware that I'm going to move all the drawing operations to canvas and have a luv.canvas object created at the beginning. luv.graphics will still be used to create graphics-related stuff. That will be different from what happens now (everything is done in luv.graphics) but I think it will be a cleaner solution. It will also make it easier to implement a webgl-based canvas in the future.
When I write def I mean function.

User avatar
kikito
Inner party member
Posts: 3151
Joined: Sat Oct 03, 2009 5:22 pm
Location: Madrid, Spain
Contact:

Re: [javascript]Luv.js

Post by kikito » Wed Nov 06, 2013 11:47 am

Just an update:

Yesterday I made a significant change in how the main canvas is managed in Luv.js.

Before it was done like in LÖVE: you had luv.graphics.line(...), luv.graphics.arc(...), etc drawing on the screen by default, unless you called luv.graphics.setCanvas(otherCanvas).

Now I have decided to have the default canvas in a fixed position: luv.canvas. So you can draw lines on the screen with luv.canvas.line(...), luv.canvas.arc(...) etc. Since the draw methods are now on the Canvas class, to draw in otherCanvas you just do otherCanvas.line(...). When you are finished drawing in an off-screen canvas, you can do luv.canvas.draw(otherCanvas, x, y) to show it on the screen. You can also draw an off-screen canvas to another offscreen canvas with otherCanvas.draw(yetAnotherCanvas, x, y)

This is a change I wanted to get out of my chest since a long time ago. I like this api more than LÖVE's (at least in <=0.8, I don't know what these guys are doing for 0.9). There is less tension in the code; luv.graphics is only in charge of building graphical stuff (Images, Animations, other Canvases) while the drawing itself happens on the Canvas class.

Now, to the collision :)
When I write def I mean function.

User avatar
Davidobot
Party member
Posts: 1146
Joined: Sat Mar 31, 2012 5:18 am
Location: Game-Dev. Land
Contact:

Re: [javascript]Luv.js

Post by Davidobot » Sun Nov 10, 2013 7:31 pm

Great work!

But I have a question: can you set the color for an image? I can't seem to be able to do that.
My library:
LovelyMoon

Check out my current project:
Raycaster

Oh hey, I have a website now!

User avatar
kikito
Inner party member
Posts: 3151
Joined: Sat Oct 03, 2009 5:22 pm
Location: Madrid, Spain
Contact:

Re: [javascript]Luv.js

Post by kikito » Sun Nov 10, 2013 7:44 pm

Hi, image tinting is on my list. The recent change I made to the canvas system was in order to facilitate this change (which in turn would be useful for particle systems as well as for image fonts). But it's still not done. For now the best you can do is drawing semi-transparent colored rectangles over the images (which sucks, I know).
When I write def I mean function.

Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests