Description
Issue №727 opened by illume at 2019-01-09 10:12:34
There are various different ways to run pygame on android.
They are mostly based on the code by renpytom and pygame subset for android.
Browser based pygame should also be able to run on android.
- https://github.com/kivy/python-for-android
- https://play.google.com/store/apps/details?id=ru.iiec.pydroid3
- pydroid3
- qpython
- pygame for android subset
- pygame_sdl2
Comments
# # robertpfeiffer commented at 2019-10-27 19:00:50
I got something to run
Next steps:
- submit recipe to kivy/p4a
- figure out packaging and loading music/sprites from APK
- get bigger game working on android
- get more examples/ working on android
- write tutorial about SCALED
- write tutorial about on-screen controls
- write tutorial/docs about swipe controls
- write tutorial/docs about tilt controls
- write tutorial about when to use android on-screen keyboard vs rolling your own
- document android button key codes
- compile portmidi for Android or find replacement
- compile libpng for Android
- compile freetype on android
- (optional) expose SCALED renderer to user
- (optional) pygame.event API for on-screen touch controls
- write example that makes use of android-specific functionality
- investigate ctypes/cffi situation
- investigate pygame_sdl2 on p4a
-
do OpenGL things with pyOpenGLpyOpenGL is married to ctypes and libc - port useful modules (modernGl, libnoise)
- port moderngl.glcontext
- get glcontext recipe merged into kivy p4a
- add libnoise recipe to kivy p4a
- make modernGL work on OpenGL ES
- exclude docs, tests from packaging in in APK
- refactor pygame build system?
- tag stable verion
- merge into master
- make pull request on kivy side
-
make seamless on-screen controls with event SDL_SetEventFilter + SDL_Renderer - bump pygame version on kivy side
- run test suite on Android device or in emulator (could be termux also)
- build test runner APK that runs selected parts of the test suite on android
- tag test suite for android/mobile so this can be automated in the future
# # robertpfeiffer commented at 2020-04-09 14:16:54
ModernGL uses several OpenGL 3.X and OpenGL4 features that necessitate changes before it can work on Android. CTypes doesn't work on android, but cffi does. So PyOpenGL is also out. That leaves https://github.com/FabriceSalvaire/PyOpenGLng, which I haven't tested yet.
It works well enough though.
@MightyJosip has made a reddit post https://www.reddit.com/r/pygame/comments/ft92jz/pygame_community_need_testers_for_making_the/
# # illume commented at 2020-09-09 05:48:32
The android PR was split up into other PRs (pygame/pygame#727), the remaining part left is the setup.py and buildconfig/Setup.Android.SDL2.in
# # robertpfeiffer commented at 2020-11-26 16:57:03
cf # 2337
# # robertpfeiffer commented at 2021-02-09 07:58:06
cf # 2187
# # ricardoV94 commented at 2021-05-22 07:14:04
Any updates on this? There seems to be no official documentation related to the new functionality
# # robertpfeiffer commented at 2021-05-22 10:40:17
Any updates on this? There seems to be no official documentation related to the new functionality
You'd need to refer to kivy pythonforandroid documentation. It works, but not everything works.
# # robertpfeiffer commented at 2021-05-22 20:51:12
I think what's next is
- bump the pygame version to 2.0.1 on the kivy side
- write a tutorial for touch controls
EDIT: Somebody bumped the PyGame version late in July, but their SDL2 and Python3 versions are still behind the official releases, and P4A had not had a release this year.
# # Pixelsuft commented at 2021-07-29 01:38:19
I've runned pygame on android!
1)You need to use FULLSCREEN flag.
2)Screen is auto resizing on android (surface.get_size())
3) Detect is it android:
is_android = True
try:
import android
except ImportError:
is_android = False
4)Use this code for paths:
import os
cur_path = os.getcwd()
def get_path(path):
return os.path.join(cur_path, path) if is_android else path
-
I'm don't know, how android.show_keyboard() works, so, use pygame-vkeyboard module.
-
In buildozer.spec, line requirements set to python3,pygame
-
to debug (after installing apk in setting make access to file storage):
try:
your_func()
except Exception as e:
open('/storage/emulated/0/error.txt').write(str(e))
# # robertpfeiffer commented at 2021-08-03 11:53:04
You need to use FULLSCREEN flag
Yes, I made it like this on purpose. Maybe we will change this if SDL2 ever supports Samsung Dex or something like that.
I'm don't know, how android.show_keyboard() works
use pygame.key.start_text_input()
and pygame.key.stop_text_input()
https://www.pygame.org/docs/ref/key.html# pygame.key.start_text_input
to debug
adb logcat
on the dev machine
# # robertpfeiffer commented at 2021-08-04 10:38:14
Ok, I think I am ready to write a tutorial for touch controls and touchscreen keyboard input. All the cool things are there, we just need to release a new release and point the kivy version to that.
# # robertpfeiffer commented at 2021-08-24 15:19:57
Also, I got GLContext to run, but never to do anything useful. Newer versions of modernGL do things that don't work with the OpenGL ES profile on my phone. I'll need to look into this at some point.