Love2D WebPlayer (WebGL)

Discuss any ports of LÖVE to different platforms.
User avatar
ghoulsblade
Party member
Posts: 111
Joined: Sun Oct 31, 2010 6:11 pm

Re: Love2D WebPlayer (WebGL)

Post by ghoulsblade »

i'm currently working on getting box2d phyics (0.8 api) to run in webplayer using http://code.google.com/p/box2dweb/

one physics heavy game is already starting to work in webplayer : http://ghoulsblade.schattenkind.net/lov ... ia2012veh/
still some slowness due to some memleak that i didn't manage to pin down yet (so much for garbage collection preventing them, heh),
and missing joints, but definitely progress =)

win and love here if anyone wants to give the working native version a try, made on devmania gamejam and extended a bit =)
* http://ghoulsblade.schattenkind.net/fil ... t-v1.4.zip
* http://ghoulsblade.schattenkind.net/fil ... -v1.4.love

I could use some help : that memleak bug needs pinning down.
My prime suspect is a lot of body s being created and destroyed on a regular basis (shots, enemies and ground spawning and despawning),
so i refactored the lua-wrapper part to use prototype and metatable to reduce love-wrapper-object creation and size to a minimum -> didn't help =(
Setting a bunch of refs to null on object destruction didn't help either.
Next up will probably be constructing a js-only minimal test case to see if it happens in pure box2dweb also, but if that doesn't work i'm running out of ideas -> please help =)
Attachments
absveh.png
absveh.png (23.85 KiB) Viewed 11855 times
love-android - gamejams
User avatar
ghoulsblade
Party member
Posts: 111
Joined: Sun Oct 31, 2010 6:11 pm

Re: Love2D WebPlayer (WebGL)

Post by ghoulsblade »

webplayer physics demo works a lot better now : http://ghoulsblade.schattenkind.net/lov ... ia2012veh/

new in webplayer-physics support : revoluteJoint, weldJoint, body:setBullet, fixture:setMask and setCategory,

Workaround for slowness has been found, it seems the primary objectlist var in lua was the cause rather than box2dweb.
Periodically making a new array and copying the values prevents the slowness.
Not ideal, but works for now. might be related to javascript splice implementation that is used by js-lua when using objects as keys in tables.
Should be investigated further at some point.
love-android - gamejams
User avatar
SiENcE
Party member
Posts: 792
Joined: Thu Jul 24, 2008 2:25 pm
Location: Berlin/Germany
Contact:

Re: Love2D WebPlayer (WebGL)

Post by SiENcE »

@ghoulsblade great!

Thx for keep working on it. I hope it gets official love2d one day.
User avatar
SimonLarsen
Party member
Posts: 100
Joined: Thu Mar 31, 2011 4:47 pm
Location: Denmark
Contact:

Re: Love2D WebPlayer (WebGL)

Post by SimonLarsen »

Found an API mismatch. When calling love.graphics.scale with only one argument (e.g. love.graphics.scale(2)) LÖVE scales in both axes, while the webplayer only scales in the X-axis. It's a simple fix in the game but I suppose it's better to fix it in the webplayer.

Wanted to make a pull request but a bit unsure how the arguments are evaluated at line 134:

Code: Select all

t.str['scale'] = function (sx,sy) { GLModelViewScale(sx || 1,sy || 1,1); return LuaNil; }
Or rather, unsure how to change it to the wanted behavior.
User avatar
Nixola
Inner party member
Posts: 1949
Joined: Tue Dec 06, 2011 7:11 pm
Location: Italy

Re: Love2D WebPlayer (WebGL)

Post by Nixola »

MAYBE (maybe) this could work? (I don't know, uh)

Code: Select all

t.str['scale'] = function (sx,sy) { GLModelViewScale(sx || sx,sy || 1,1); return LuaNil; }
lf = love.filesystem
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
User avatar
ghoulsblade
Party member
Posts: 111
Joined: Sun Oct 31, 2010 6:11 pm

Re: Love2D WebPlayer (WebGL)

Post by ghoulsblade »

thanks, i think it should be

Code: Select all

t.str['scale'] = function (sx,sy) { GLModelViewScale((sx || 1) ,(sy || sx || 1),1); return LuaNil; }
since "||" behaves roughly like "or" in lua , GLModelViewScale takes 3 parameters: sx,sy,sz. (braces added for clarity above)
or better yet

Code: Select all

t.str['scale'] = function (sx,sy) {
  if (sx == null) sx = 1;
  if (sy == null) sy = sx;
  GLModelViewScale(sx,sy,1); 
  return LuaNil; 
}
love-android - gamejams
User avatar
SiENcE
Party member
Posts: 792
Joined: Thu Jul 24, 2008 2:25 pm
Location: Berlin/Germany
Contact:

Re: Love2D WebPlayer (WebGL)

Post by SiENcE »

New demo that works with webplayer from the l3d thread: http://sience.schattenkind.net/love2d/l3d/

cheers
User avatar
bartoleo
Party member
Posts: 118
Joined: Wed Jul 14, 2010 10:57 am
Location: Savigliano

Re: Love2D WebPlayer (WebGL)

Post by bartoleo »

I found this... it's a game competition made by GitHub
https://github.com/blog/1303-github-game-off
GitHub Game Off
The Challenge
You have the entire month of November to create a web-based game loosely built around one or more of the following themes:
  • forking (or forks)
  • branching (or branches)
  • cloning (or clones)
  • pushing
  • pulling
What do we mean by loosely based on these concepts? We literally mean, loosely based. Some examples might be a FPS where you throw forks at water balloons, an educational game about DNA cloning, or perhaps a platformer where you push and pull objects.
Your game. Your rules. You can participate as an individual or as a team. You're encouraged to use open source libraries, frameworks, graphics, and sounds.
....
etc etc
Bartoleo
User avatar
rokit boy
Party member
Posts: 198
Joined: Wed Jan 18, 2012 7:40 pm

Re: Love2D WebPlayer (WebGL)

Post by rokit boy »

I've tried to put PHP vars in there in every way I can, how can I put PHP vars in there?
u wot m8
User avatar
ghoulsblade
Party member
Posts: 111
Joined: Sun Oct 31, 2010 6:11 pm

Re: Love2D WebPlayer (WebGL)

Post by ghoulsblade »

Not sure what you mean by PHP vars so:
PHP is executed on the server, Webplayer/javascript is executed in the players browser.
If you want to pass some variable you calculate on the server in php to the game running in the browser, you'll need to use some javascript:

for example with clouds : https://github.com/ghoulsblade/love-web ... index.html
change index.html to index.php

add a script block inside the "head" tag :

Code: Select all

<script type="text/javascript">
gMyVarFromPHP = <?php echo 100+23;?>;
</script>
then in love.load do

Code: Select all

gMyVarInLua = love.web.javascript("gMyVarFromPHP")
or to call php at runtime, something like this should also work :

Code: Select all

local jscode = [[
var url = "bla.php?blub=4";
var gMyResult;
UtilAjaxGet(url,function () { gMyResult = res; },true);
return gMyResult;
]]
gMyVarInLua = love.web.javascript(jscode)
love-android - gamejams
Post Reply

Who is online

Users browsing this forum: No registered users and 10 guests