klikklak
Oh neat, it's a ... field.
what's the status of python currently? And specifically of pygame? It's an alternative to GLbasic and Fenix I'd rather learn, because python would be generally useful for scripting, while basic is not.
#!/bin/sh
PYTHONHOME=/mnt/sd/python # does not have to be there, change this to wherever your python install is
export PYTHONHOME
PYTHONPATH=${PYTHONHOME}/lib/python2.6/site-packages:$PYTHONPATH
PYTHONPATH=${PYTHONHOME}/lib/python2.6/lib-dynload:$PYTHONPATH
PYTHONPATH=${PYTHONHOME}/lib/python2.6:$PYTHONPATH
PYTHONPATH=${PYTHONHOME}:$PYTHONPATH
export PYTHONPATH
LD_LIBRARY_PATH=${PYTHONHOME}/extras:${LD_LIBRARY_PATH}
export LD_LIBRARY_PATH
${PYTHONHOME}/python2.6 -OOu example.py > ./example.log 2>&1
sync
cd /usr/gp2x
./gp2xmenu
torpor said:Man, this is great .. one more step towards pyglet!![]()
aho said:Didn't work here with the 1.1.0 FW by the way.Edit: Bad line endings. It does work.
>can only load BMP files
That's clearly the biggest issue. Well, there are 32bit BMPs, but support for that is generally pretty poor (pygame for example doesn't support it). TGA is a very simple format and covers most things one might need.
import pygame
from struct import unpack
def load(filename):
try:
print 'reading %s' % filename
f=open(filename,'rb')
data=f.read()
f.close()
header=unpack('hhBB',data[12:18])
w=header[0]
h=header[1]
bpp=header[2]
bpc=header[3]
surface=pygame.Surface((w,h),pygame.SRCALPHA,32)
surface.lock()
offset=18
try:
for y in xrange(h):
yf=h-y-1
for x in xrange(w):
surface.set_at((x,yf),(
ord(data[offset+2]), #r
ord(data[offset+1]), #g
ord(data[offset+0]), #b
ord(data[offset+3]) #a
))
offset+=4
finally:
surface.unlock()
except:
raise
return surface
#import:
import tga
#load:
img=tga.load('foo32bit.tga') #only handles uncompressed 32bit tgas and nothing else
#draw:
screen.blit(img,(x,y))
Traceback (most recent call last):
File "wizbutton.py", line 11, in <module>
import pyz
File "/mnt/sd/wizbutton3/pyz.py", line 1, in <module>
import pygame,gzip
File "/mnt/sd/python/lib/python2.6/gzip.py", line 9, in <module>
import zlib
ImportError: /mnt/sd/python/lib/python2.6/lib-dynload/zlib.so: undefined symbol: inflateEnd
import pygame
from struct import unpack
#import gzip
import subprocess
def load(filename):
try:
print 'reading %s' % filename
'
f=gzip.open(filename,'rb')
data=f.read()
f.close()
'
p=subprocess.Popen('gunzip -cd %s' % filename,bufsize=4096,stdout=subprocess.PIPE,shell=True)
data=p.stdout.read()
p.stdout.close()
header=unpack('hh',data[:4])
w=header[0]
h=header[1]
surface=pygame.image.frombuffer(data[4:],(w,h),'RGBA').convert_alpha()
except:
raise
return surface