[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] Pygame_sdl2



For now, you have to use a pair of packaging tools we've written to package Ren'Py apps for Android and iOS. Despite the names, they're both intended to package arbitrary pygame_sdl2 apps. (For now, there is some Ren'Py branding, especially in the iOS tool, but that branding should probably be changed before release anyway.)

You can get them both fromÂhttp://nightly.renpy.org/current/ , as <version>-rapt.zip and <version>-renios.zip.

RAPT (Ren'Py Android Packaging Tool) still works approximately as documented atÂhttp://pygame.renpy.org/, especially when it comes to building android applications. The big change is that the lifecycle events are now different Â- see below. (Some other modules, like lifecycle management, are also different.)

Renios is the iOS packaging tool. You can create a new project by runningÂ

  ./ios.py create MyProject

That will copy the prototype directory to MyProject, and make some changes to the various plist files. You can then place a main.py in MyProject/base, and use Xcode to build the project.


We've exposed the SDL2 application lifecycle events to pygame_sdl2 users:

https://wiki.libsdl.org/SDL_EventType#Android_and_iOS_Events

The mapping is pretty straightforward -ÂSDL_APP_TERMINATING becomes pygame_sdl2.APP_TERMINATING. In Ren'Py, I handle these as follows:

On APP_TERMINATING, we save the game (in a special save file) and immediately quit.

On APP_WILLENTERBACKGROUND, we stop all sound, timers, and screen updates; save the game (in a special save file), and sit in a tight pygame.event.wait() loop. If that loop gets an APP_DIDENTERFOREGROUND event, we delete the save file, and resume screen updates and sound. If the loop gets an APP_TERMINATING event, we just quit.

When Ren'Py starts, it checks for the special save file, and if found loads it, restoring the player's state.


Right now, the mobile stuff is still somewhat raw. RAPT has been used to ship a number of Android apps, so it works well enough - but I haven't spent a lot of time trying it with arbitrary pygame_sdl2 games, so there might be some minor problems there. Renios is still quite beta. Both are Python 2.7-only at the moment - making the version of python configurable will be a challenge.




On Wed, Apr 8, 2015 at 2:13 AM Gino Ingras <ginoingras@xxxxxxxxx> wrote:
you mentioned that it is better to use pygame_sdl2 for mobile apps.
how do you do that?

2015-04-08 5:01 GMT+02:00 Michael Lutynski <michael@xxxxxxxxxxxxxxxxxxxxxxxxx>:

I too am very stoked to hear about the pygame1 release and the pygame_sdl2! This is wonderful!!

Â

~ Michael

Â

On Tue : Apr 7, 2015 3:13:02 PM you wrote:

> pps. yes, I think it would be nice to join forces. Including testing,

> porting, doing missing modules, and re-licensing or rewriting LGPL code

> where needed. Maybe moving the repo under the pygame organisation on

> bitbucket (perhaps?).

>

> I have holidays in 3 weeks, which I've planned to try and push the pygame1

> release out the door. Probably the last major pygame 1 release.

>

> Trying to port existing games to pygame_sdl2 is probably a nice effort

> everyone can do to help :) I'll report back on my games later.

>

>

> best,