[pygame] pygame webplugin

2006-07-08 Thread [EMAIL PROTECTED]

hi,

with google i came across various hints that people work on a pygame webplugin. what did happen to these projects?

i think having a python alternative to flash and java applets would be awesome! :)

what are the difficulties involved in doing such a webplugin? i guess if it were easy it already would havebeen done?


Re: [pygame] pygame website - request for suggestions

2006-07-08 Thread Mikael Moutakis

I have a suggestion: Put help  tutorials  documentation on one page
+ subpages and call it help, for that is what you are looking for
when you're stuck and need to read up on the documentation.  And
through in a pygame cookbook.

There are now tutorial links under both tutorials and documentation.

Otherwise it is a nice homepage

/Mikael Moutakis
Sweden

2006/7/8, Phil Hassey [EMAIL PROTECTED]:

Hey,

 It's been one year since I launched the new pygame website.  I hope to have
a bit of time during the next month to do some updates to it.  So if anyone
has:

 - bug reports
 - feature requests
 - etc

 To suggest, now's the time!  If anyone makes a feature request that you
think is great, please reply to their message and say so -- the more people
want a feature the more likely I'll be to implement it.

 Thanks!
 Phil


 
Do you Yahoo!?
 Everyone is raving about the all-new Yahoo! Mail Beta.




Re: [pygame] pygame website - request for suggestions

2006-07-08 Thread Kai Kuehne

Hi,

On 7/8/06, Mikael Moutakis [EMAIL PROTECTED] wrote:

I have a suggestion: Put help  tutorials  documentation on one page
+ subpages and call it help, for that is what you are looking for
when you're stuck and need to read up on the documentation.  And
through in a pygame cookbook.


That's a good suggestion. I didn't see the difference between documentation
and tutorials. And that's for sure: The searched document is always on the
other page. ;-)

Greetings
Kai


Re: [pygame] pygame webplugin

2006-07-08 Thread Luke Paireepinart

[EMAIL PROTECTED] wrote:

hi,
 
with google i came across various hints that people work on a pygame 
webplugin. what did happen to these projects?
 
i think having a python alternative to flash and java applets would be 
awesome! :)
 
what are the difficulties involved in doing such a webplugin? i guess 
if it were easy it already would have been done?

The biggest problem I see is security.
What keeps the web programmer from doing an os.popen(FORMAT C:/) or 
whatever?
you have to go through every function and make sure it's not a security 
risk, and if it is, eliminate it.
Whitelisting would be the answer here I think, blacklisting would take 
too long.

But yeah, being able to do animations in python would roxxor.


Re: [pygame] pygame webplugin

2006-07-08 Thread [EMAIL PROTECTED]
i see. isn't there a way to block modules from being importable somehow? and only allow the absolutely needed and secure ones?

the same problem also exists with standalone pygame applications though, or not? someone could make a game that formats your harddisk? but with a webplugin it would be more serious since you potentially reach a bigger audience and it runs automatically?

On 7/8/06, Luke Paireepinart [EMAIL PROTECTED] wrote:
[EMAIL PROTECTED] wrote: hi, with google i came across various hints that people work on a pygame
 webplugin. what did happen to these projects? i think having a python alternative to flash and java applets would be awesome! :) what are the difficulties involved in doing such a webplugin? i guess
 if it were easy it already would have been done?The biggest problem I see is security.What keeps the web programmer from doing an os.popen(FORMAT C:/) orwhatever?you have to go through every function and make sure it's not a security
risk, and if it is, eliminate it.Whitelisting would be the answer here I think, blacklisting would taketoo long.But yeah, being able to do animations in python would roxxor.


Re: [pygame] pygame webplugin

2006-07-08 Thread Rikard Bosnjakovic

On 7/8/06, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:


but with a
webplugin it would be more serious since you potentially reach a bigger
audience and it runs automatically?


Also, you would not be able to peek the code, which you would be able
to with a local application.

--
- Rikard.


Re: [pygame] pygame webplugin

2006-07-08 Thread Bob Ippolito
The C Python implementation can not currently be sandboxed in a way that makes this feasible. Brett Cannon has recently started working on a dissertation for a new restricted execution design [1], but don't hold your breath.A more viable solution would probably be to write a Python to haXe [2] translator (maybe a PyPy backend). Then you could compile down to ActionScript and run it in the Flash player, which has extremely high penetration and would be much better than trying to get users to install some crap just to play your game in a browser. The ActionScript 3 VM in Flash 9 is quite fast and would be suitable for pygame-like applications. This is of course non-trivial, but it would be a really exciting project if someone is so inclined. ActionScript 3 bytecode could also be used directly, but haXe would give you _javascript_ support for free as well.This of course wouldn't get you SDL/pygame, but it wouldn't be hard to write something API compatible with pygame that used something else as a backend.A somewhat easier alternative might be to write something API compatible with pygame that worked on top of Java via Jython. However, Java applets are much more annoying than Flash (longer load time, etc.).[1] http://mail.python.org/pipermail/python-dev/2006-June/066344.html[2] http://www.haxe.org/-bobOn Jul 8, 2006, at 2:45 PM, [EMAIL PROTECTED] wrote:i see. isn't there a way to block modules from being importable somehow? and only allow the absolutely needed and secure ones?   the same problem also exists with standalone pygame applications though, or not? someone could make a game that formats your harddisk? but with a webplugin it would be more serious since you potentially reach a bigger audience and it runs automatically?   On 7/8/06, Luke Paireepinart [EMAIL PROTECTED] wrote: [EMAIL PROTECTED] wrote: hi, with google i came across various hints that people work on a pygame  webplugin. what did happen to these projects? i think having a python alternative to flash and java applets would be awesome! :) what are the difficulties involved in doing such a webplugin? i guess  if it were easy it already would have been done?The biggest problem I see is security.What keeps the web programmer from doing an os.popen("FORMAT C:/") orwhatever?you have to go through every function and make sure it's not a security risk, and if it is, eliminate it.Whitelisting would be the answer here I think, blacklisting would taketoo long.But yeah, being able to do animations in python would roxxor.

Re: [pygame] pygame webplugin

2006-07-08 Thread [EMAIL PROTECTED]
thanks for the links! python in firefox sounds nice.

python together with the canvas html element (canvas opengl support is also planned if i remember correctly) maybe the problem will solve itself? :) i think this would almost be like pygame...
On 7/9/06, Bob Ippolito [EMAIL PROTECTED] wrote:


The C Python implementation can not currently be sandboxed in a way that makes this feasible. Brett Cannon has recently started working on a dissertation for a new restricted execution design [1], but don't hold your breath. 



A more viable solution would probably be to write a Python to haXe [2] translator (maybe a PyPy backend). Then you could compile down to ActionScript and run it in the Flash player, which has extremely high penetration and would be much better than trying to get users to install some crap just to play your game in a browser. The ActionScript 3 VM in Flash 9 is quite fast and would be suitable for pygame-like applications. This is of course non-trivial, but it would be a really exciting project if someone is so inclined. ActionScript 3 bytecode could also be used directly, but haXe would give you _javascript_ support for free as well.


This of course wouldn't get you SDL/pygame, but it wouldn't be hard to write something API compatible with pygame that used something else as a backend.

A somewhat easier alternative might be to write something API compatible with pygame that worked on top of Java via Jython. However, Java applets are much more annoying than Flash (longer load time, etc.).

[1] http://mail.python.org/pipermail/python-dev/2006-June/066344.html

[2]http://www.haxe.org/


-bob



On Jul 8, 2006, at 2:45 PM, [EMAIL PROTECTED] wrote:

i see. isn't there a way to block modules from being importable somehow? and only allow the absolutely needed and secure ones?

the same problem also exists with standalone pygame applications though, or not? someone could make a game that formats your harddisk? but with a webplugin it would be more serious since you potentially reach a bigger audience and it runs automatically? 

On 7/8/06, Luke Paireepinart [EMAIL PROTECTED]
 wrote: 

[EMAIL PROTECTED] wrote: hi, with google i came across various hints that people work on a pygame  webplugin. what did happen to these projects? i think having a python alternative to flash and java applets would be
 awesome! :) what are the difficulties involved in doing such a webplugin? i guess  if it were easy it already would have been done?The biggest problem I see is security.What keeps the web programmer from doing an 
os.popen(FORMAT C:/) orwhatever?you have to go through every function and make sure it's not a security risk, and if it is, eliminate it.Whitelisting would be the answer here I think, blacklisting would take
too long.But yeah, being able to do animations in python would roxxor.



Re: [pygame] My prototype - testers needed

2006-07-08 Thread Adeola Bannis

Adam... test it... please that 166 sounds great.

On 6/5/06, Adam [EMAIL PROTECTED] wrote:

On 05/06/06, Adeola Bannis [EMAIL PROTECTED] wrote:

 Okay..

 Now, could people test this code for me please? Tell me if it runs
 smoothly... no flicker, slowdown etc... and take out the clock in
 game.py and tell me how many fps you get, if possible...

 I would especially like if someone runs it on the oldest machine [with
 colour monitor :) ] possible. Looking for about 200Mhz

 Thanks


If you can wait a week or twoish, I hope :p I should be able to test on a
166.





Re: [pygame] Optimizing a noise-maker

2006-07-08 Thread Peter Shinners
On Sat, 2006-07-08 at 22:48 +0200, Rikard Bosnjakovic wrote:
 At the end of each level for my game, the screen is supposed to become
 noisy (like a TV with no show on). Currently, I'm doing this:

If you dig through the archaology of the old pygame sites you can find
the code.

http://www.pygame.org/pcr/static_text/index.php




[pygame] Numeric Question

2006-07-08 Thread Kamilche

Hey Pete, I have another Numeric question for you, if you've got the time.

Let's say I have a bunch of data in RGBA format, where  is an 
arbitrary floating point number, and RGBA are unsigned bytes. The 
following routine will convert that to an RGBA picture, but it takes a 
long, time.


What's the magical incantation to get Numeric to assign the data 
directly to the pixels of the surface?


--Kamilche

---

import pygame
import Numeric
import Image
import struct
import math
import os
import sys

pathname, scriptname = os.path.split(sys.argv[0])
pathname = os.path.abspath(pathname)
os.chdir(pathname)


def Convert(filename):
if filename[-3:] != 'zbf':
return
print Converting %s % filename
fd = open(filename, 'rb')
header = fd.read(34)
data = fd.read()
fd.close()
numpixels = len(data)/8
w = h = math.sqrt(numpixels)
if int(w) != w:
print int(w), w
raise Exception(The picture must be totally square, and 
rendered 3x the desired size without antialiasing!)

w = int(w)
h = int(h)
pic = pygame.Surface((w, h), pygame.SRCALPHA, 32).convert_alpha()
ctr = 0
for y in range(h):
for x in range(w):
d, r, g, b, a = struct.unpack(f, data[ctr:ctr+8])
if d  10:
a = 255
else:
a = 0
pic.set_at((x, y), [r, g, b, a])
ctr += 8
smallpic = pygame.transform.rotozoom(pic, 0, .33)
neww, newh = smallpic.get_size()

s = pygame.image.tostring(smallpic, RGBA)
im = Image.fromstring(RGBA, (neww, newh), s)
newfilename = filename[:-3] + 'png'
im.save(newfilename)
print New file saved to %s, shrunk to %dx%d % (newfilename, neww, 
newh)


Re: [pygame] Numeric Question

2006-07-08 Thread Peter Shinners
On Sat, 2006-07-08 at 20:04 -0700, Kamilche wrote:
 Hey Pete, I have another Numeric question for you, if you've got the time.
 
 Let's say I have a bunch of data in RGBA format, where  is an 
 arbitrary floating point number, and RGBA are unsigned bytes. The 
 following routine will convert that to an RGBA picture, but it takes a 
 long, time.
 
 What's the magical incantation to get Numeric to assign the data 
 directly to the pixels of the surface?

I'm not sure if that can be done actually. Numeric may have a way to do
casting between data types, but I'm not really sure. I was thinking
Numeric.array_constructor could bind an arbitrary sized and typed array
onto a string buffer of data. But it looks like that does not work.

You'll need a function like that in order for this to work. I know in
Python 2.5 the struct module can precompile your formatting codes, which
would speed this up. I also see that you unpack an a value out of the
binary data, but then throw it away.

Also, since you are doing such simple handling of the float data, you
could probably just treat the whole pixel as a bunch of bytes. All this
will help a bit, but won't make it orders of magnitude faster.

xspan = range(w)
ordfunc = ord
setfunc = pic.set_at
for y in range(h):
for x in xspan:
a = (ordfunc(data[ctr + 3])  0x7f  0x46 and 255 or 0
setfunc((x, y), (
ordfunc(data[ctr + 4],
ordfunc(data[ctr + 5],
ordfunc(data[ctr + 6],
a))
ctr += 8


Sadly, I'm kind of wildly guessing here if that code to compare with
0x46 will match a floating point value with less than 6 digits left of
the decimal. But it works in some simplish tests.





Re: [pygame] Numeric Question

2006-07-08 Thread Kamilche

Peter Shinners wrote:

On Sat, 2006-07-08 at 20:04 -0700, Kamilche wrote:

Hey Pete, I have another Numeric question for you, if you've got the time.

Let's say I have a bunch of data in RGBA format, where  is an 
arbitrary floating point number, and RGBA are unsigned bytes. The 
following routine will convert that to an RGBA picture, but it takes a 
long, time.


What's the magical incantation to get Numeric to assign the data 
directly to the pixels of the surface?


I'm not sure if that can be done actually. Numeric may have a way to do
casting between data types, but I'm not really sure. I was thinking
Numeric.array_constructor could bind an arbitrary sized and typed array
onto a string buffer of data. But it looks like that does not work.

You'll need a function like that in order for this to work. I know in
Python 2.5 the struct module can precompile your formatting codes, which
would speed this up. I also see that you unpack an a value out of the
binary data, but then throw it away.

Also, since you are doing such simple handling of the float data, you
could probably just treat the whole pixel as a bunch of bytes. All this
will help a bit, but won't make it orders of magnitude faster.

xspan = range(w)
ordfunc = ord
setfunc = pic.set_at
for y in range(h):
for x in xspan:
a = (ordfunc(data[ctr + 3])  0x7f  0x46 and 255 or 0
setfunc((x, y), (
ordfunc(data[ctr + 4],
ordfunc(data[ctr + 5],
ordfunc(data[ctr + 6],
a))
ctr += 8


Sadly, I'm kind of wildly guessing here if that code to compare with
0x46 will match a floating point value with less than 6 digits left of
the decimal. But it works in some simplish tests.






Darn. Well, that explains why my attempts to get it to work failed, 
then. Thanks for the info!


This is the file format for WorldBuilder ZBF files. There's no way to 
render an alpha channel, but there IS a way to render with depth 
information. That's that  float number embedded in there. (The alpha 
channel contains all 0's, even if you specify 'render with alpha 
channels.') That simple check is in essence saying 'if the pixel is 
near, it's opaque; if it's far, it's transparent', but that doesn't give 
you antialiasing on the picture. So, I render it too big by a factor of 
3, apply the near/far algorithm, then shrink the result down. Then, 
FINALLY, it gives me what I want.


It would be far easier if WorldBuilder would just render with alpha 
channels in the first place. :-P


--Kamilche