RenPy in the browser... with PYGJS?

In this forum we discuss the future of Ren'Py, both bug fixes and longer-term development. Pre-releases are announced and discussed here.
Post Reply
Message
Author
asherwunk
Newbie
Posts: 3
Joined: Tue Jun 20, 2017 1:44 am
Github: asherwunk
Contact:

RenPy in the browser... with PYGJS?

#1 Post by asherwunk » Tue Jun 20, 2017 1:55 am

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/)

Imperf3kt
Miko-Class Veteran
Posts: 816
Joined: Mon Dec 14, 2015 5:05 am
Location: Your monitor
Contact:

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

#2 Post by Imperf3kt » Tue Jun 20, 2017 4:07 am

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
Image

Warning: May contain trace amounts of gratuitous plot.

asherwunk
Newbie
Posts: 3
Joined: Tue Jun 20, 2017 1:44 am
Github: asherwunk
Contact:

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

#3 Post by asherwunk » Tue Jun 20, 2017 5:24 pm

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

User avatar
PyTom
Ren'Py Creator
Posts: 14777
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

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

#4 Post by PyTom » Tue Jun 20, 2017 7:33 pm

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.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
Software > Drama
https://www.patreon.com/renpytom

asherwunk
Newbie
Posts: 3
Joined: Tue Jun 20, 2017 1:44 am
Github: asherwunk
Contact:

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

#5 Post by asherwunk » Wed Jun 21, 2017 1:08 am

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

Post Reply

Who is online

Users browsing this forum: No registered users