[pygame] pgreloaded documentation moved to sphinx

2009-01-22 Thread Marcus von Appen
Hi,

those of you keeping an eye on pgreloaded will hopefully be delighted to
hear that the XML documentation sources are now converted into
reStructuredText to be used by the sphinx[0] documentation system (the
system used by Python = 2.6).

Using reStructuredText as intermediate format and sphinx as
documentation system should ease the process of creating and writing a
clean documentation without dealing too much with all the HTML and
layout stuff.

It's in an early stage for now and just performs some simple
preprocessing, so the generated HTML is not all that shiny. Suggestions
about the documenation structure, layout and design are greatly welcome
(especially in conjunction with the proposed website redesign).

[0] http://sphinx.pocoo.org/

Regards
Marcus


pgpWWXxPlM3Aj.pgp
Description: PGP signature


[pygame] How to get text from a surface

2009-01-22 Thread sibteym
Hi,

I am loading an image into pygame.i am trying to get the text from the
surface. I used pyTesser to read the text from a surface but if the font
size of the text is less then 16, it doesn't give me back the correct text
from the surface.

Is there any other way to get the text from the pygame surface.

Thanks,
Sibtey




Re: [pygame] pgreloaded documentation moved to sphinx

2009-01-22 Thread Nicholas Dudfield

Nice


Hi,

those of you keeping an eye on pgreloaded will hopefully be delighted to
hear that the XML documentation sources are now converted into
reStructuredText to be used by the sphinx[0] documentation system (the
system used by Python = 2.6).

Using reStructuredText as intermediate format and sphinx as
documentation system should ease the process of creating and writing a
clean documentation without dealing too much with all the HTML and
layout stuff.

It's in an early stage for now and just performs some simple
preprocessing, so the generated HTML is not all that shiny. Suggestions
about the documenation structure, layout and design are greatly welcome
(especially in conjunction with the proposed website redesign).

[0] http://sphinx.pocoo.org/

Regards
Marcus
  




Re: [pygame] fast sqrt? and profiling

2009-01-22 Thread Emile Kroeger
On Thu, Jan 22, 2009 at 3:28 AM, Jake b ninmonk...@gmail.com wrote:
 On Wed, Jan 21, 2009 at 11:11 AM, Casey Duncan ca...@pandora.com wrote:

 Others have made good suggestions about reducing the amount of work you do
 detecting collision (i.e., partitioning) and using complex numbers instead
 of euclid for 2d vectors. The latter made a big performance difference for
 me in a vector-heavy game I was working on.

 1) How do you use complex(imaginary) numbers in place of euclid vectors? I
 tried searching for a tut/article, but, not having luck.

Just use complex numbers as the standard data format for all your 2D
vectors (positions, speeds, accelerations, directions ...)

So you're making asteroids, you may have a spaceship that looks like this:

class Spaceship:
def __init__(self, pos, max_accel):
self.pos = pos
self.speed = 0j
self.direction = 1j
self.boosters_on = False
self.max_accel = max_accel

def update(self, dt):
if self.boosters_on:
self.speed += self.direction * self.max_accel * dt
self.pos += self.speed * dt

def render(self):
screen_coords = self.pos.real, self.pos.imag
# (Have somthing that draws the right sprite or polygon there)


... it's missing a lot of code, like turning the boosters on or off
when you press buttons, turning (a bit more painful), and drawing, but
you can at least see that the physics logic is pretty
straightfoward, more than it would be if you were using tuples or
something like that to represent vectors.

Cheers,

Emile


Re: [pygame] How to get text from a surface

2009-01-22 Thread Thiago Chaves
Well, the problem you ran into is more like a problem of Optical
Character Recognition (OCR) than a Pygame problem.

Maybe you should look for better OCR algorithms. Which one are you
currently using, by the way?

-Thiago

On Thu, Jan 22, 2009 at 11:33 AM,  sibt...@infotechsw.com wrote:
 Hi,

 I am loading an image into pygame.i am trying to get the text from the
 surface. I used pyTesser to read the text from a surface but if the font
 size of the text is less then 16, it doesn't give me back the correct text
 from the surface.

 Is there any other way to get the text from the pygame surface.

 Thanks,
 Sibtey





Re: [pygame] Status of Iphone pygame?

2009-01-22 Thread Alejandro J. Cura
Hey, hi Illume!

There are already a few games on the iphone appstore made with Lua:
http://www.idevgames.com/forum/showthread.php?t=15984

You are not supposed to download and run additional scripts, since
that would bypass apple's controls, but (and IANAL) you can run
scripts included in your app.

cheers,
-- 
alecu

On Tue, Jan 20, 2009 at 23:38, René Dudfield ren...@gmail.com wrote:
 If you want to release it on the app store, you're not allowed to use python.

 I don't think anyone has been working on it.  The SDL 1.3 port to
 iphone is in a semi-complete state.

 If you want to do an iphone game for the app store, best to use something 
 else.



 On Wed, Jan 21, 2009 at 12:34 PM, Scott Beckstead
 scotthbeckst...@gmail.com wrote:
 Since Apple modified their non disclosure on the iphone has there been
 any change in the iphone availability.  I have a game I need to port
 and I've been waiting for that to happen.




[pygame] Events and X

2009-01-22 Thread Peter Gebauer
Hi guys!

I was writing a quick test that use pygame.key.get_pressed, but had
had no window and the keys won't get updated.
After browsing the source code for the various event implementations
under src/video and looking at the X11 code I realized that the code
checks for a focused window before even processing events.

Is it impossible to get the X11 input events without a window with
the current implementation? Is it possible to get X11 input events
without a window in the current X implementation at all?
The svga implementation is using ioctl, but I don't really want to
venture down that road and reimplement keyboard completely.

/Peter


Re: [pygame] fast sqrt? and profiling

2009-01-22 Thread Jake b
Still confused on the difference between complex and euclid.Vector2 [ doc:
http://www.partiallydisassembled.net/euclid/vector-classes.html ]

On Wed, Jan 21, 2009 at 9:24 PM, Casey Duncan ca...@pandora.com wrote:

 Here's some example code with some commonly used functions. Addition and
 subtraction are built into the complex type and work as expected (I use the
 real part


So far, this looks like euclid.Vector2. Are you doing the same thing, only
using 'real as the x component, and 'imag' as y? ( Meaning you are using
complex instead of tuple, equivalent to using vector2 instead of tuple ? )

Or, I think i'm missing something. What is the advantage to to use this over
euclid.Vector2? [ more below ]

for x and the imaginary part for y). complex multiply can be used to rotate
 vectors:


Does complex multiply behind the scenes do something like this?

def rad2v(rad,mag=1.): # convert radians to vector with magnitude
return mag*Vector2(cos(rad), sin(rad))

def v2rad(v): return atan2(v.y, v.x) # convert vector to radians

def mod_angle(v,rad): # add radians to vector's orientation
r = v2rad(v)
r+=rad
return rad2v( r, v.magnitude() )

 v = rad2v( radians(142.8),2.5)
# now equals: deg=142.8, mag=2.5, v=Vector2(-1.99, 1.51)
 v = mod_angle( v, radians(3.))
# now equals: deg=145.8, mag=2.5, v=Vector2(-2.07, 1.41)


 # 2D vectors using python complex numbers

 def radians(vector):
return atan2(vector.imag, vector.real)

 def unit(radians):
return cmath.exp(radians * 1j)

 def normal(vector):
L = length(vector)
if L == 0:
return vector2()
else:
return vector / L

 def clamp(vector, max_length):
L = length(vector)
if L  max_length:
return vector * (max_length / L)
else:
return vector


At first, this code looks the same, except there are new functions:
.radians(v) and unit(r). Radians looks like a 'convert vector to euler
radians angle'.

But whatis .unit()? I'm guessing it's to create a new unit vector in the
angle of 'radians.' But calling it with a few values, I'm not getting what I
was expecting.

Is it the equivalent of rad2v(r) for Vector2, but unit(r) does the same for
complex numbers?



 def distance(vector1, vector2):
return length(vector1 - vector2)This is good if the list may change
 during iteration. If you do this repeatedly in a given frame, it might be
 better to create a custom class (perhaps subclass set) that contains a
 stable set of the actors. When you add or remove, these are stored in
 ancillary sets rather than changing the stable set immediately. An update
 method called at the beginning of each frame adds and removes the items from
 the ancillary sets to update the stable set. These ancillary sets are then
 cleared. This mean less memory allocation/cleanup and work copying the lists

 class StableSet(set):

I'll try it out.

@emile: ( continued from above ), I'm trying to understand how/why complex
numbers are used.

Here is my Vector2 equivalent to your code.

It looks like you treat complex same way I treat  euclid.Vector2 ? Am I
missing something?

from euclid import Vector2
class Spaceship():
def __init__(self, pos=Vector2(0,0), max_accel=100):
self.pos = pos
self.vel = Vector2(0, 0) # or'speed'. changed named to not be
confused as Scalar
self.accel = Vector2(0, 1.) # or 'direction'
self.boosters_on = False
self.max_accel = max_accel

def update(self, dt):
if self.boosters_on:
self.vel += self.accel * self.max_accel * dt
self.pos += self.vel * dt
-- 
Jake


Re: [pygame] Python 2.6

2009-01-22 Thread Yanom Mobis
can't I get all of that with 

from __future__ import x

?

--- On Wed, 1/21/09, Brian Fisher br...@hamsterrepublic.com wrote:

From: Brian Fisher br...@hamsterrepublic.com
Subject: Re: [pygame] Python 2.6
To: pygame-users@seul.org
Date: Wednesday, January 21, 2009, 9:22 PM

On Wed, Jan 21, 2009 at 6:53 PM, Yanom Mobis ya...@rocketmail.com wrote:

Is there any good reason to switch to python 2.6, even though 2.5 is the 
supported python on my Linux distro?



one good reason is because you want most of the goodness that you can get 
from 3.0 with very little of the breakage:
http://docs.python.org/whatsnew/2.6.html


nothing in particular there is worth it to me, personally.




  

Re: [pygame] Python 2.6

2009-01-22 Thread Yanom Mobis

thanks.
and about installing 2.5.4 over 2.5.2? 
--- On Wed, 1/21/09René Dudfield ren...@gmail.com wrote:

From: René Dudfield ren...@gmail.com
Subject: Re: [pygame] Python 2.6
To: pygame-users@seul.org
Date: Wednesday, January 21, 2009, 9:15 PM

hi,

yeah, python 2.5 is the best python at the moment -- because it's more
portable, and there are more libraries for it.

Best not to overwrite your system python, as then it could break
system tools.  It seems new enough to use :)


chairs,


On Thu, Jan 22, 2009 at 1:53 PM, Yanom Mobis ya...@rocketmail.com wrote:
 Is there any good reason to switch to python 2.6, even though 2.5 is the 
 supported python on my Linux distro?

 If I do stick with Python 2.5, is it safe to override python2.5.2 with 
 python2.5.4 ( $ cd Python-2.5.4  ./configure  make  sudo make install )?








  

Re: [pygame] fast sqrt? and profiling

2009-01-22 Thread Emile Kroeger
Oh, I guess they are pretty much equivalent, even though Casey seems
to say complex have better performance than euclid.

I just use complex because it's available out of the box with Python
:) (and because I didn't know about Euclid; maybe I'll use it if I do
3D)

On Thu, Jan 22, 2009 at 11:58 PM, Jake b ninmonk...@gmail.com wrote:
 Still confused on the difference between complex and euclid.Vector2 [ doc:
 http://www.partiallydisassembled.net/euclid/vector-classes.html ]

 On Wed, Jan 21, 2009 at 9:24 PM, Casey Duncan ca...@pandora.com wrote:

 Here's some example code with some commonly used functions. Addition and
 subtraction are built into the complex type and work as expected (I use the
 real part

 So far, this looks like euclid.Vector2. Are you doing the same thing, only
 using 'real as the x component, and 'imag' as y? ( Meaning you are using
 complex instead of tuple, equivalent to using vector2 instead of tuple ? )

 Or, I think i'm missing something. What is the advantage to to use this over
 euclid.Vector2? [ more below ]

 for x and the imaginary part for y). complex multiply can be used to
 rotate vectors:

 Does complex multiply behind the scenes do something like this?

 def rad2v(rad,mag=1.): # convert radians to vector with magnitude
 return mag*Vector2(cos(rad), sin(rad))

 def v2rad(v): return atan2(v.y, v.x) # convert vector to radians

 def mod_angle(v,rad): # add radians to vector's orientation
 r = v2rad(v)
 r+=rad
 return rad2v( r, v.magnitude() )

  v = rad2v( radians(142.8),2.5)
 # now equals: deg=142.8, mag=2.5, v=Vector2(-1.99, 1.51)
  v = mod_angle( v, radians(3.))
 # now equals: deg=145.8, mag=2.5, v=Vector2(-2.07, 1.41)


 # 2D vectors using python complex numbers

 def radians(vector):
return atan2(vector.imag, vector.real)

 def unit(radians):
return cmath.exp(radians * 1j)

 def normal(vector):
L = length(vector)
if L == 0:
return vector2()
else:
return vector / L

 def clamp(vector, max_length):
L = length(vector)
if L  max_length:
return vector * (max_length / L)
else:
return vector

 At first, this code looks the same, except there are new functions:
 .radians(v) and unit(r). Radians looks like a 'convert vector to euler
 radians angle'.

 But whatis .unit()? I'm guessing it's to create a new unit vector in the
 angle of 'radians.' But calling it with a few values, I'm not getting what I
 was expecting.

 Is it the equivalent of rad2v(r) for Vector2, but unit(r) does the same for
 complex numbers?


 def distance(vector1, vector2):
return length(vector1 - vector2)
 This is good if the list may change during iteration. If you do this
 repeatedly in a given frame, it might be better to create a custom class
 (perhaps subclass set) that contains a stable set of the actors. When you
 add or remove, these are stored in ancillary sets rather than changing the
 stable set immediately. An update method called at the beginning of each
 frame adds and removes the items from the ancillary sets to update the
 stable set. These ancillary sets are then cleared. This mean less memory
 allocation/cleanup and work copying the lists

 class StableSet(set):

 I'll try it out.

 @emile: ( continued from above ), I'm trying to understand how/why complex
 numbers are used.

 Here is my Vector2 equivalent to your code.

 It looks like you treat complex same way I treat  euclid.Vector2 ? Am I
 missing something?

 from euclid import Vector2
 class Spaceship():
 def __init__(self, pos=Vector2(0,0), max_accel=100):
 self.pos = pos
 self.vel = Vector2(0, 0) # or'speed'. changed named to not be
 confused as Scalar
 self.accel = Vector2(0, 1.) # or 'direction'
 self.boosters_on = False
 self.max_accel = max_accel

 def update(self, dt):
 if self.boosters_on:
 self.vel += self.accel * self.max_accel * dt
 self.pos += self.vel * dt
 --
 Jake



[pygame] surface.map_rgb() returns signed int, surfarray.array2d unsigned int

2009-01-22 Thread Lenard Lindstrom

Hi,

I am writing more unit tests for surfarray after completing the 
blit_array tests. Right now I am working on array2d. It would seem 
natural to compare the elements of an array returned by array2d with 
values returned by map_rgb for the surface used to create the array. But 
it is not that easy. map_rgb returns a signed integer. The array is 
unsigned. So, though the two numbers may represent the same pixel value, 
they cannot be directly compared for assertion tests. It also brings up 
another issue, shouldn't map_rgb be compatible with array2d and 
blit_array. How else would one format surface specific pixel values from 
Color values. So the question is, do I change map_rgb to return an 
unsigned value as a Python long? Would this break anything?


Lenard

--
Lenard Lindstrom
le...@telus.net