Page 1 of 1

RenPy in the browser... with PYGJS?

Posted: Tue Jun 20, 2017 1:55 am
by asherwunk
I have developed a rough draft of something I call PYGJS, basically it's Pygame in the Browser.

I know RenPy is based on Python and as I understood it at one point or another (though I may be wrong) it used pygame as one of it's libraries.

Using Brython (Python in the browser) from http://brython.info/, a pygame like JavaScript library GameJS from http://gamejs.org/ , as well as opentype.js, a joystick javascript library, and Howler.js I was able to make a frankenstein of a creation:

Python 3 running in a browser (or NodeWebkit) that can import pygame (or basically a recreation of pygame that really wraps itself around GameJS) and use pygame functionality like you might use it outside of the browser.

It's NOT an emulator, you DO have to reprogram certain parts of your pygame for it to work in the browser version, but much of pygame's functionality is kept in tact (except for a few unsupported functions). For information on my thoughts and journey here check out: http://wunk.me/announcing-pygjs-pygame- ... odewebkit/ For the complete code for this abomination go to my github repository: https://github.com/asherwunk/pygjs

In any case, could this possibly be a step towards getting Python based (and potentially pygame based) RenPY to the browser? I don't know if there's any other utility that does that, but I'm unaware of it.

I programmed this as a work of love by hand, but if you're interested in helping encourage me I do have a Ko-Fi link (https://ko-fi.com/A18224XC) and a patreon (https://www.patreon.com/asherwolfstein)

For more information I'll keep a page on my blog updated with future information (all it has now is the readme) at: http://wunk.me/programming-projects/pygjs

Asher
(http://wunk.me/)

Re: RenPy in the browser... with PYGJS?

Posted: Tue Jun 20, 2017 4:07 am
by Imperf3kt
Ren'Py also uses C (well actually Cython)
Is there any way to emulate Cython code in a web browser?

Does this support VPython? http://vpython.org

Re: RenPy in the browser... with PYGJS?

Posted: Tue Jun 20, 2017 5:24 pm
by asherwunk
Imperf3kt wrote:Ren'Py also uses C (well actually Cython)
Is there any way to emulate Cython code in a web browser?
C-Extensions? I am unfamiliar with these, but, it wouldn't be necessarily impossible to port C code to JavaScript code. Basically provide JavaScript objects that potentially did the same thing as whatever the C extension did. Of course, it depends on what the C extension did and if it is possible to emulate it in JavaScript.
Imperf3kt wrote:Does this support VPython? http://vpython.org
It looks like to me if you want to support vpython you'd have to what I kind of did for pygame, that is recreate the library with a wrapper to a capable javascript library, such as maybe three.js (for 3d stuff)? 3d is something I'll be looking into in the future. For an idea of how you might wrap the vpython library onto a three.js, look how I did it for pygame and GameJS.

This is of course, if I'm understanding VPython correctly, which, to be honest, is a little confusing.

Thanks!
Asher

Re: RenPy in the browser... with PYGJS?

Posted: Tue Jun 20, 2017 7:33 pm
by PyTom
How do you handle pygame.event.wait()? I'm seeing this as the main problem stopping there from being a browser version of Ren'Py - taking something as complex as Ren'Py and trying to convert it to being event driven seems very difficult. Ren'Py also make substantial use of special python methods, like __getattr__. I'm not sure how well those are supported.

What's likely to work is webassembly, and the threading work that's part of it. When it takes off, it seems like it will be "easy" to port CPython over to it, and get into the browser that way.

Re: RenPy in the browser... with PYGJS?

Posted: Wed Jun 21, 2017 1:08 am
by asherwunk
It's not EXACTLY pygame, unfortunately. If you wanted to run a pygame construction in my browser version you DO have to re-program or restructure things a bit. Unfortunately, pygame.event.wait() was one of those large difficulties that I couldn't exactly overcome in the land of JavaScript. In the index file of the git repository is an example of how you might set up a simple python game using the provided "mainloop" function I added to pygame.event.

I don't know much of the internal construction of RenPy to be honest, this was just a wild conjecture, but I imagine something could potentially be possible.

I believe __getattr__ would work fine in Brython, but you'd have to check with Brython.

But yeah, in the end, you do have to restructure the code to be more "event driven" than you might in pygame where most people use pygame.event.wait() or an infinite while loop.

Anyways,
Asher

Re: RenPy in the browser... with PYGJS?

Posted: Wed Oct 17, 2018 4:04 pm
by Beuc
I'm pointing out the current webassembly effort:
viewtopic.php?f=32&t=52015