Re: [pygame] Networking?

2007-11-19 Thread Simon Wittber
On Nov 20, 2007 4:08 AM, Jason Ward <[EMAIL PROTECTED]> wrote:
> I want to make my game playable over the network and if possible the
> internet.
> For the network it must support more than 2 computers and be realtime
> Would the sockets library in python solve all my needs?

http://www.google.com/search?q=simple+pygame+networking

Try the first link returned. :-)

-- 
:: Simon Wittber
:: http://www.linkedin.com/in/simonwittber
:: phone: +61.4.0135.0685
:: jabber/msn: [EMAIL PROTECTED]


Re: [pygame] Apply alpha to another image

2007-11-19 Thread Lenard Lindstrom

Stuart Axon wrote:

Hello,
 I'm wondering the best way to apply alpha from one surface onto another -

I can get the alpha with
pygame.surfarray.array_alpha

But can't see a corresponding way to apply that to a surface without
affecting the rgb values.

Basically I have two images, one paletted, I manipulate the palette
then blit it onto a 32 bit surface.
The second image has the alpha, I want to apply this to the surface,
keeping the rgb values - basically a very quick way of colourising
things.
  


Array slicing comes to the rescue.

pygame.surfarray.pixels_alpha(surf32)[...] = array_of_alpha

pixels_alpha() returns an array view of a surfaces alpha plane. The 
square brackets indicate assignment to the contents of the array. The 
ellipses represents the entire array.


--
Lenard Lindstrom
<[EMAIL PROTECTED]>



[pygame] Apply alpha to another image

2007-11-19 Thread Stuart Axon
Hello,
 I'm wondering the best way to apply alpha from one surface onto another -

I can get the alpha with
pygame.surfarray.array_alpha

But can't see a corresponding way to apply that to a surface without
affecting the rgb values.

Basically I have two images, one paletted, I manipulate the palette
then blit it onto a 32 bit surface.
The second image has the alpha, I want to apply this to the surface,
keeping the rgb values - basically a very quick way of colourising
things.


Re: [pygame] Networking?

2007-11-19 Thread Richard Jones
On Tue, 20 Nov 2007, Noah Kantrowitz wrote:
> Pyraknet is worth a look, as is Twisted,
> but both have their own problems.

Twisted is very mature, but can take some effort to learn how to use. It can 
also be very tricky to incorporate into a game.


Richard


[pygame] unsubscribe pygame-users

2007-11-19 Thread JJRH -

 unsubscribe pygame-users
_
Are you ready for Windows Live Messenger Beta 8.5 ? Get the latest for free 
today!
http://entertainment.sympatico.msn.ca/WindowsLiveMessenger

Re: [pygame] Re: I'm getting BSOD while using PyGame.

2007-11-19 Thread Ian Mallett
On 11/15/07, Casey Duncan <[EMAIL PROTECTED]> wrote:
> I would think not, presumably on a true HWSURFACE that would require
> a round-trip to the graphics card, whereas on a SWSURFACE it just
> needs to grab it from RAM.
But isn't that what it has to do anyway?  I mean, doesn't it have to
send the surface to the gpu for processing?  I really have no idea.
> Also 32bpp may be faster than 24bpp, word
> alignment and all that...
What?
> At any rate YMMV, and timeit is your friend 8^)
Cool!  Why are there all these great python modules that I've never
heard about?...
> -Casey
Thanks,
Ian


Re: [pygame] Networking?

2007-11-19 Thread Noah Kantrowitz
Not really. There isn't yet a good, lightweight networking library  
that plays well with pygame. Pyraknet is worth a look, as is Twisted,  
but both have their own problems. I've got some code I can throw your  
way, but it still has rough edges.


--Noah

On Nov 19, 2007, at 2:08 PM, Jason Ward wrote:

I want to make my game playable over the network and if possible the  
internet.

For the network it must support more than 2 computers and be realtime
Would the sockets library in python solve all my needs?




[pygame] Networking?

2007-11-19 Thread Jason Ward
I want to make my game playable over the network and if possible the
internet.
For the network it must support more than 2 computers and be realtime
Would the sockets library in python solve all my needs?


Re: [pygame] Doubt about using methods in python

2007-11-19 Thread marta sanz


Hello David,

El 15/11/2007, a las 15:01, David Gowers escribió:


Hi marta,

On Nov 15, 2007 9:11 PM, marta sanz <[EMAIL PROTECTED]> wrote:

Hi,

I have a doubt about python and I would like to ask it to you.
It is about the use of functions -methos- of a class within other  
class. I
have 2 classes in 2 separate files, in file squares.py I have the  
class

Square with the methods getRect() and setRect().

Now, in other file, board.py, I have the class Board that has an  
object
outskirt= Square(), can anyone tell me how do I have to use the  
method

setRect ?

The code is the following:

File squares.py
class Square:

def setRect(self, x,y,width,height):
 self.rect= pygame.rect(x,y,width, height)


File board.py

from squares import Square
import squares

class Board :

for i in range(42):
 self.outskirt.append(squares.Square(self))


The above 2 lines are nonsensical, mainly because self only exists
inside methods (and then only if you follow the convention of naming
the first argument 'self'). using self outside of methods will not
give the desired result -- in fact it'll give an error that self
doesn't exist.

What you probably want to do, is, each time a Board is created,
initialize self.outskirt with those 42 squares. This is far closer to
achieving what you want:

class Board:
  def __init__ (self):
   self.outskirt = [] # remember to create the list before  
appending to it :)

   for i in range(42):
 self.outskirt.append(squares.Square(self)) # you are calling
Square with a Board as the first argument -- is this your intent?






Um, I forgot writing the def __init__(self).  What I want to do with  
that method is to create a square and append it to the list, so I  
think I've done it wrong while writing "self", haven't I?







def squareConfiguration (self):
...
 for j in range(len(self.outskirt)):

#and now is when I don't know which I have to use to do it OK :
 self.outskirt[j].rect= pygame.rect ( x, y, w, h)
 self.outskirt[j].setRect( x, y, w, h)
 Square.setRect( self.outskirt[j], x, y, w, h)



The following is probably more correct for what you want:

def squareConfiguration (self):
...
  for sq in self.outskirt: # iterate through the items in
self.outskirt rather than their indices.
sq.setRect (x,y,w,h) # where are x,y,w,h coming from? are they
calculated earlier in the function? ???

Well, they're calculated within that "for", what I wanted to ask was  
the right way of calling that method, that's why I didn't extend more  
in copying the body of that method :).



I'll leave it to you to figure out why.


I haven't proved them because I'm quite lost using python...
Thanks and sorry for my English..


Have you looked at http://wiki.python.org/moin/Languages ? You might
be able to find what you need to know written in your native language.


Thanks!