The SDL forums have moved to discourse.libsdl.org.
This is just a read-only archive of the previous forums, to keep old links working.


SDL Forum Index
SDL
Simple Directmedia Layer Forums
Fixed Rate Pig - A decade later
David Olofson
Guest

Playing around a bit with Emscripten
(http://kripken.github.io/emscripten-site/), and figured my ancient
playable SDL example "Fixed Rate Pig" might be fun in the browser:

http://olofson.net/pig/

Source code available; same old, with a few minor tweaks for Emscripten.

http://olofson.net/pig/pig-1.1.tar.bz2

Tested in Chrome and Firefox on Linux. There's no SDL_SetClipRect(),
so clipping is broken; you can see sprites over the dashboard. And of
course, the game logic is still running at 20 fps (deliberately, to
demonstrate the interpolation/"tweening"), so controls feel a bit
sluggish.


--
//David Olofson - Consultant, Developer, Artist, Open Source Advocate

.--- Games, examples, libraries, scripting, sound, music, graphics ---.
| http://consulting.olofson.net http://olofsonarcade.com |
'---------------------------------------------------------------------'
_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
Fixed Rate Pig - A decade later
Pallav Nawani


Joined: 19 May 2011
Posts: 122
Location: Dehradun, India
Looks great.
Was it much trouble to use emscripten to port fixed rate pig to javascript?

Pallav Nawani
IronCode Gaming Private Limited
Website: http://www.ironcode.com
Twitter:  http://twitter.com/Ironcode_Gaming
Facebook: http://www.facebook.com/Ironcode.Gaming
Mobile: 9997478768


On Sun, Oct 12, 2014 at 4:52 AM, David Olofson wrote:
Quote:
Playing around a bit with Emscripten
(http://kripken.github.io/emscripten-site/), and figured my ancient
playable SDL example "Fixed Rate Pig" might be fun in the browser:

    http://olofson.net/pig/

Source code available; same old, with a few minor tweaks for Emscripten.

    http://olofson.net/pig/pig-1.1.tar.bz2

Tested in Chrome and Firefox on Linux. There's no SDL_SetClipRect(),
so clipping is broken; you can see sprites over the dashboard. And of
course, the game logic is still running at 20 fps (deliberately, to
demonstrate the interpolation/"tweening"), so controls feel a bit
sluggish.


--
//David Olofson - Consultant, Developer, Artist, Open Source Advocate

.--- Games, examples, libraries, scripting, sound, music, graphics ---.
|   http://consulting.olofson.net          http://olofsonarcade.com   |
'---------------------------------------------------------------------'
_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
Fixed Rate Pig - A decade later
David Olofson
Guest

On Mon, Oct 13, 2014 at 7:12 AM, Pallav Nawani wrote:
Quote:
Looks great.
Was it much trouble to use emscripten to port fixed rate pig to javascript?

Thanks!

It was quite straightforward, really. You have proper C and C++
compilers, and you're presented with something very much like an OS
with SDL and some other useful stuff present, so for a simple SDL
application, it's pretty much business as usual.

Apart from details like SDL_SetAlpha() not working as expected, and
SDL_DisplayFormat() missing (the SDK SDL version is somewhere between
1.2 and 2.0, apparently), the only structural change is that you need
to switch from a main loop to event based execution. (See
emscripten_set_main_loop().)

I'm sure there are quite a few optimizations that can be done, though.
Pig is using the legacy SDL 1.2 2D API, and I'd expect there to be a
few performance issues in mapping that over the browser APIs, just
like when implementing it over OpenGL or similar. Using a WebGL
friendly subset of OpenGL is probably the best bet for performance and
compatibility - and not just for Emscripten, but when targetting
pretty much anything these days. Using the SDL 2.0 2D API would
probably be a good alternative too, as it's designed for hardware
accelerated targets like OpenGL.


--
//David Olofson - Consultant, Developer, Artist, Open Source Advocate

.--- Games, examples, libraries, scripting, sound, music, graphics ---.
| http://consulting.olofson.net http://olofsonarcade.com |
'---------------------------------------------------------------------'
_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
Fixed Rate Pig - A decade later
Martin Gerhardy
Guest

Cool. Nice job.

While we are on it, did anyone have a working sdl2 port of one of its
games with emscripten?

I tried my games recently - and got them working to some extend - but it
feels laggy without async io (which I plan to do next for nacl and
emscripten).

Once I can show something where I am pleased with, I will also post the
results here.

Regards
Martin

Am 13.10.2014 um 10:17 schrieb David Olofson:
Quote:
On Mon, Oct 13, 2014 at 7:12 AM, Pallav Nawani wrote:
Quote:
Looks great.
Was it much trouble to use emscripten to port fixed rate pig to javascript?
Thanks!

It was quite straightforward, really. You have proper C and C++
compilers, and you're presented with something very much like an OS
with SDL and some other useful stuff present, so for a simple SDL
application, it's pretty much business as usual.

Apart from details like SDL_SetAlpha() not working as expected, and
SDL_DisplayFormat() missing (the SDK SDL version is somewhere between
1.2 and 2.0, apparently), the only structural change is that you need
to switch from a main loop to event based execution. (See
emscripten_set_main_loop().)

I'm sure there are quite a few optimizations that can be done, though.
Pig is using the legacy SDL 1.2 2D API, and I'd expect there to be a
few performance issues in mapping that over the browser APIs, just
like when implementing it over OpenGL or similar. Using a WebGL
friendly subset of OpenGL is probably the best bet for performance and
compatibility - and not just for Emscripten, but when targetting
pretty much anything these days. Using the SDL 2.0 2D API would
probably be a good alternative too, as it's designed for hardware
accelerated targets like OpenGL.



--

http://www.caveproductions.org
http://twitter.com/MartinGerhardy

_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org