While developing a streaming app for Pythonista I noticed that it usually crashes after some time. Turns out it's somehow related to loading/unloading images with
scene. Here is a minimal example that crashes Pythonista reliably:
import scene import random from cStringIO import StringIO import Image def raw_jpeg(img): buf = StringIO() img.save(buf, 'JPEG', quality=50) data = buf.getvalue()[::] buf.close() return data imglist = [raw_jpeg(img) for img in [ Image.new('RGB', (512, 384), 'red'), Image.new('RGB', (512, 384), 'yellow'), Image.new('RGB', (512, 384), 'green'), Image.new('RGB', (512, 384), 'blue'), Image.new('RGB', (512, 384), 'gray'), ]] imgnames =  while True: name = scene.load_image_data(random.choice(imglist)) if len(imgnames) == 16: scene.unload_image(imgnames.pop(0)) imgnames.append(name) print name
It takes a variable amount of time, somewhere between a second and a minute I'd say. And using
scene.load_pil_imageinstead does not help, but only makes the loading process slower.
Am I missing something?
scene.unload_imageshould free memory, and since this example never exceeds 16 images loaded at once it should have plenty of that.
EDIT: I am using iPad 4 and what seems to be the latest version of Pythonista.
I tried using it with a simple ellipse, but I still have no idea how it works and where actually is the rotation point. It seems as the ellipse is not rotated along its own rotation point (center).
P. S. A side question: scene.translate just moves objects on the x and y axises by the specified number, right?
Gonna advertise GamePie some more :)
Here is a video of a game I am working on (PieRPG): https://www.youtube.com/watch?v=N3cKMUwPd_g.
It uses GamePie as game engine and runs fine on Linux and iOS.
P. S. Incase anybody wants to take a look at the code it is here: https://github.com/Vik2015/pierpg. Please note that PieRPG is using a dev version of GamePie (0.2) which is not available yet.
I finally made something that works! :)
GamePie allows you to create games which can be ran on many platforms. The project was created to allow creation of cross-platform games - those that can run on both iOS devices and PCs. It's licensed under zlib license.
Git repository is here: https://github.com/Vik2015/gamepie. For PC you need
gamepie-pc/and for iOS -
gamepie-ios/. Just put it in the site-packages folder and rename to
examples/folder to see some examples. Currently it contains
planes.pywhich is a shooting game where you control the player and your goal is to shoot down as many enemy planes as possible. Player can be controlled via keyboard on PC (
escapequits) and mouse/touches on PC and iOS. Nothing fancy :)
If you have any ideas about what can I add to it please post them here.
Hey guys. Is it possible to draw 3D objects in Pythonista? I know it doesn't have 3D libraries, but AFAIK Doom was made in DOS without 3D libraries (2.5 D or something). Is it possible to do such stuff in Pythonista (and if it is, what's the estimated speed?). Thanks.