[pygame] Is there a downloadable Manual?

2007-09-10 Thread Lamonte Harris
Would be nice to have one :).


Re: [pygame] Is there a downloadable Manual?

2007-09-10 Thread Ian Mallett
On 9/10/07, Lamonte Harris [EMAIL PROTECTED] wrote:
 Would be nice to have one :).

I second that.


Re: [pygame] Is there a downloadable Manual?

2007-09-10 Thread Lamonte Harris
Preferrable Compiled HTML Help File, runs smoother and its less RAM/CPU
usage.

On 9/10/07, Ian Mallett [EMAIL PROTECTED] wrote:

 On 9/10/07, Lamonte Harris [EMAIL PROTECTED] wrote:
  Would be nice to have one :).

 I second that.



Re: [pygame] Is there a downloadable Manual?

2007-09-10 Thread Rikard Bosnjakovic
On 10/09/2007, Lamonte Harris [EMAIL PROTECTED] wrote:

 its less RAM/CPU usage.

Than what?


-- 
- Rikard - http://bos.hack.org/cv/


Re: [pygame] Is there a downloadable Manual?

2007-09-10 Thread Jason Marshall
Lamonte,

This is available, but it's not quite up-to-date:
ftp://pygame.org/pub/pygame/pygame-docs-1.6.exe

Jason M.


   

Sick sense of humor? Visit Yahoo! TV's 
Comedy with an Edge to see what's on, when. 
http://tv.yahoo.com/collections/222


Re: [pygame] Is there a downloadable Manual?

2007-09-10 Thread Lamonte Harris
Life Saver :), can't wait til its updated.

On 9/10/07, Jason Marshall [EMAIL PROTECTED] wrote:

 Lamonte,

 This is available, but it's not quite up-to-date:
 ftp://pygame.org/pub/pygame/pygame-docs-1.6.exe

 Jason M.




 
 Sick sense of humor? Visit Yahoo! TV's
 Comedy with an Edge to see what's on, when.
 http://tv.yahoo.com/collections/222



[pygame] draw.rect question real simple

2007-09-10 Thread Lamonte Harris
So basically pygame.draw.rect basically draws on the rect onto the surface,
so its not actually assigned to anything(such as a variable).


Re: [pygame] draw.rect question real simple

2007-09-10 Thread Kris Schnee

Lamonte Harris wrote:
So basically pygame.draw.rect basically draws on the rect onto the 
surface, so its not actually assigned to anything(such as a variable).


Right; it just performs the action of drawing a rectangle on the 
specified surface. Note, though, that according to:

http://pygame.org/docs/ref/draw.html#pygame.draw.rect
the function returns a Rect object (nearly the same thing as a 4-entry 
tuple) which you can ignore. If you really wanted to know where the rect 
was drawn, you could capture that return value like so:

spam = pygame.draw.rect(...)
print spam

In terms of it being assigned to something, it's a function of the 
pygame.draw module.


Re: [pygame] draw.rect question real simple

2007-09-10 Thread Lamonte Harris
Ok kool I sort of thought so.  Thanks for the quick reply.

More questions coming soon :).

On 9/10/07, Kris Schnee [EMAIL PROTECTED] wrote:

 Lamonte Harris wrote:
  So basically pygame.draw.rect basically draws on the rect onto the
  surface, so its not actually assigned to anything(such as a variable).

 Right; it just performs the action of drawing a rectangle on the
 specified surface. Note, though, that according to:
 http://pygame.org/docs/ref/draw.html#pygame.draw.rect
 the function returns a Rect object (nearly the same thing as a 4-entry
 tuple) which you can ignore. If you really wanted to know where the rect
 was drawn, you could capture that return value like so:
 spam = pygame.draw.rect(...)
 print spam

 In terms of it being assigned to something, it's a function of the
 pygame.draw module.



Re: [pygame] Is there a downloadable Manual?

2007-09-10 Thread Lenard Lindstrom

Lamonte Harris wrote:

Life Saver :), can't wait til its updated.

On 9/10/07, *Jason Marshall* [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] 
wrote:


Lamonte,

This is available, but it's not quite up-to-date:
ftp://pygame.org/pub/pygame/pygame-docs-1.6.exe

Jason M.






Sick sense of humor? Visit Yahoo! TV's
Comedy with an Edge to see what's on, when.
http://tv.yahoo.com/collections/222


Here are the Pygame 1.8 docs I grabbed from SVN. I will make them 
available for a short while.


http:/www3.telus.net/len_l/pygame-1.8-docs.tar.gz


--
Lenard Lindstrom
[EMAIL PROTECTED]



Re: [pygame] Is there a downloadable Manual?

2007-09-10 Thread Lamonte Harris
Doesn't work for me, let me know when it works.

On 9/10/07, Lenard Lindstrom [EMAIL PROTECTED] wrote:

 Lamonte Harris wrote:
  Life Saver :), can't wait til its updated.
 
  On 9/10/07, *Jason Marshall* [EMAIL PROTECTED] mailto:[EMAIL PROTECTED]
  wrote:
 
  Lamonte,
 
  This is available, but it's not quite up-to-date:
  ftp://pygame.org/pub/pygame/pygame-docs-1.6.exe
 
  Jason M.
 
 
 
 
 
 
  Sick sense of humor? Visit Yahoo! TV's
  Comedy with an Edge to see what's on, when.
  http://tv.yahoo.com/collections/222
 
 
 Here are the Pygame 1.8 docs I grabbed from SVN. I will make them
 available for a short while.

 http:/www3.telus.net/len_l/pygame-1.8-docs.tar.gz


 --
 Lenard Lindstrom
 [EMAIL PROTECTED]




Re: [pygame] Is there a downloadable Manual?

2007-09-10 Thread Ethan Glasser-Camp
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Lamonte Harris wrote:
 Doesn't work for me, let me know when it works.

Hi,

It works for me. If it doesn't work for you, the problem might be on
your end.

Ethan
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFG5dc0hRlgoLPrRPwRAnpSAKCjPVDGF6eEwrRUnejDKmH0PlzjDwCfbpXS
KS0Sn/N5rYDhIgB/MMGmLc0=
=IHkA
-END PGP SIGNATURE-


Re: [pygame] Is there a downloadable Manual?

2007-09-10 Thread Lamonte Harris
Works now, a tip for others, save to ur computer before trying to unzip.
Using Winzip, it'll say corrupted.

On 9/10/07, Ethan Glasser-Camp [EMAIL PROTECTED] wrote:

 -BEGIN PGP SIGNED MESSAGE-
 Hash: SHA1

 Lamonte Harris wrote:
  Doesn't work for me, let me know when it works.

 Hi,

 It works for me. If it doesn't work for you, the problem might be on
 your end.

 Ethan
 -BEGIN PGP SIGNATURE-
 Version: GnuPG v1.4.6 (GNU/Linux)
 Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

 iD8DBQFG5dc0hRlgoLPrRPwRAnpSAKCjPVDGF6eEwrRUnejDKmH0PlzjDwCfbpXS
 KS0Sn/N5rYDhIgB/MMGmLc0=
 =IHkA
 -END PGP SIGNATURE-



Re: [pygame] Is there some type of hex codes to rgb converter or something?

2007-09-10 Thread Luke Paireepinart

Lamonte Harris wrote:
I like using HTML hex, is there a library or something on pygame or 
python it self to convert hex to rgb

HTML hex colors are defined as such:
color = #DEFFC3
I.E. a pound sign, then 2 hex digits for red, 2 for green, and 2 for blue.
This is very easy to convert between.
First let's get rid of the # sign
color = color[1:]
Next let's separate these into 3 different strings.
red = color[0:2]
green = color[2:4]
blue = color[4:6]

Next let's convert these all to integers
red = int(red, 16)
green = int(green, 16)
blue = int(blue, 16)

I'll leave it as an exercise for the reader to simplify this (I.E. I 
have food on the stove and I have to go take it off.)

HTH,
-Luke


Re: [pygame] Is there some type of hex codes to rgb converter or something?

2007-09-10 Thread Lamonte Harris
Freaking thank you Tries it out now

On 9/10/07, Luke Paireepinart [EMAIL PROTECTED] wrote:

 Lamonte Harris wrote:
  I like using HTML hex, is there a library or something on pygame or
  python it self to convert hex to rgb
 HTML hex colors are defined as such:
 color = #DEFFC3
 I.E. a pound sign, then 2 hex digits for red, 2 for green, and 2 for blue.
 This is very easy to convert between.
 First let's get rid of the # sign
 color = color[1:]
 Next let's separate these into 3 different strings.
 red = color[0:2]
 green = color[2:4]
 blue = color[4:6]

 Next let's convert these all to integers
 red = int(red, 16)
 green = int(green, 16)
 blue = int(blue, 16)

 I'll leave it as an exercise for the reader to simplify this (I.E. I
 have food on the stove and I have to go take it off.)
 HTH,
 -Luke



Re: [pygame] Is there some type of hex codes to rgb converter or something?

2007-09-10 Thread Lamonte Harris
I came up w/ this for my class:
def hex_converter(self,hexcolorcode):
hexcolorcode = hexcolorcode[1:]
red = hexcolorcode[0:2]
red = int(red,16)
blue = hexcolorcode[2:4]
blue = int(blue,16)
green = hexcolorcode[4:6]
green = int(green,16)
return (red,green,blue)

Thanks. again

On 9/10/07, Lamonte Harris [EMAIL PROTECTED] wrote:

 Freaking thank you Tries it out now

 On 9/10/07, Luke Paireepinart [EMAIL PROTECTED] wrote:
 
  Lamonte Harris wrote:
   I like using HTML hex, is there a library or something on pygame or
   python it self to convert hex to rgb
  HTML hex colors are defined as such:
  color = #DEFFC3
  I.E. a pound sign, then 2 hex digits for red, 2 for green, and 2 for
  blue.
  This is very easy to convert between.
  First let's get rid of the # sign
  color = color[1:]
  Next let's separate these into 3 different strings.
  red = color[0:2]
  green = color[2:4]
  blue = color[4:6]
 
  Next let's convert these all to integers
  red = int(red, 16)
  green = int(green, 16)
  blue = int(blue, 16)
 
  I'll leave it as an exercise for the reader to simplify this (I.E. I
  have food on the stove and I have to go take it off.)
  HTH,
  -Luke
 




[pygame] Yeah looks like i'm doing quite well so far, completed my goal for today.

2007-09-10 Thread Lamonte Harris
Yeah took some time of thinking and fixing and rethinking.  Pygame is like a
strategy puzzle.  I've just mapping script, where in the text file are
numbers.  I read the numbers from 1,2 and switch then into rects that I
created.  Them I displayed them on the screen.  Its quite nice to make
something so cool without asking for help :P.  Check it out and tell me what
you think[attachements]

My only flaw is, the rects render upside down.  What could I do to fix that?


map1.map
Description: Binary data
import pygame,sys,string
from pygame.locals import *
class map_:
def __init__(self,wndow=(300,300)):
self.size = wndow
self.map = [[],[],[]]
self.surfaces = [[],[]]
self.window = pygame.display.set_mode(self.size)
pygame.init()
def create_box(self,size,color,rect):
box = pygame.Surface((size))
pygame.draw.rect(box,color,box.get_rect())
self.surfaces[0].append(box)
self.surfaces[1].append(rect)
def load_text_map(self,map):
file = open(map,r)
links = file.readlines()
file.close()
x = 0
for i in links:
i = string.replace(i,\n,)
i = i.split(,)
for e in i:
self.map[x].append(e)
x += 1
def draw_box(self):
while True:
for event in pygame.event.get():
if event.type == pygame.QUIT: sys.exit()
e = 0
while e  len(self.surfaces[0]):

self.window.blit(self.surfaces[0][e],self.surfaces[1][e])
e += 1
pygame.display.update()
def render_map(self,aray,dict):
x=0
for e in aray:  
z = 0
for y in e:
aray[x][z] = dict[int(y)]
z += 1
x += 1
return aray
def hex_converter(self,hexcolorcode):
hexcolorcode = hexcolorcode[1:]
red = hexcolorcode[0:2]
red = int(red,16)
blue = hexcolorcode[2:4]
blue = int(blue,16)
green = hexcolorcode[4:6]
green = int(green,16)
return (red,green,blue)
def main(self):
z = 0
x = 0
y = 0
m = 0
while z  len(self.map):
q = 0
while q  len(self.map[z]):

self.create_box(self.map[z][q][0],self.map[z][q][1],(x,y))
y += 100
q += 1
y = 0
x += 100
z += 1
self.draw_box()
Map = map_()
tiles = {1 : [(100,100),Map.hex_converter(#E0ECFF)], 2 : 
[(100,100),Map.hex_converter(#B5EDBC)] }
Map.load_text_map(map1.map)
Map.render_map(Map.map,tiles)
Map.main()

RE: [pygame] Yeah looks like i'm doing quite well so far, completed my goal for today.

2007-09-10 Thread paris
flip?http://www.pygame.org/docs/ref/display.html#pygame.display.flipbest,p



 Original Message 
Subject: [pygame] Yeah looks like i'm doing quite well so far,
completed my goal for today.
From: "Lamonte Harris" [EMAIL PROTECTED]
Date: Mon, September 10, 2007 9:05 pm
To: pygame-users@seul.org


Yeah took some time of thinking and fixing and rethinking. Pygame is like a strategy puzzle. I've just mapping script, where in the text file are numbers. I read the numbers from 1,2 and switch then into rects that I created. Them I displayed them on the screen. Its quite nice to make something so cool without asking for help :P. Check it out and tell me what you think[attachements] My only flaw is, the rects render upside down. What could I do to fix that? 





Re: [pygame] Yeah looks like i'm doing quite well so far, completed my goal for today.

2007-09-10 Thread Ethan Glasser-Camp
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Lamonte Harris wrote:
 My only flaw is, the rects render upside down.  What could I do to fix that?

Hi,

It isn't rendering upside down. If you try a map like:

1,1,1
2,1,2
1,2,2

You will see that in fact, it is rendering sideways.

HTH,

Ethan
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFG5f0YhRlgoLPrRPwRAtenAJ4p2qDp8tDRfndkRyOQ3Ex5szLSOgCfT3tp
VX3VgIjw4rUxaTqgf43ug9M=
=C96D
-END PGP SIGNATURE-


Re: [pygame] Yeah looks like i'm doing quite well so far, completed my goal for today.

2007-09-10 Thread Lamonte Harris
Okay :), I fixed it I had the x and y in the wrong spot:

self.create_box(self.map[z][q][0],self.map[z][q][1],(y,x))  is the correct
method.

On 9/10/07, Ethan Glasser-Camp [EMAIL PROTECTED] wrote:

 -BEGIN PGP SIGNED MESSAGE-
 Hash: SHA1

 Lamonte Harris wrote:
  My only flaw is, the rects render upside down.  What could I do to fix
 that?

 Hi,

 It isn't rendering upside down. If you try a map like:

 1,1,1
 2,1,2
 1,2,2

 You will see that in fact, it is rendering sideways.

 HTH,

 Ethan
 -BEGIN PGP SIGNATURE-
 Version: GnuPG v1.4.6 (GNU/Linux)
 Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

 iD8DBQFG5f0YhRlgoLPrRPwRAtenAJ4p2qDp8tDRfndkRyOQ3Ex5szLSOgCfT3tp
 VX3VgIjw4rUxaTqgf43ug9M=
 =C96D
 -END PGP SIGNATURE-



Re: [pygame] Yeah looks like i'm doing quite well so far, completed my goal for today.

2007-09-10 Thread Ethan Glasser-Camp
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Lamonte Harris wrote:
 Okay :), I fixed it I had the x and y in the wrong spot:
 
 self.create_box(self.map[z][q][0],self.map[z][q][1],(y,x))  is the
 correct method.

If you really mean for the variable y to mean vertical position
and the variable x to mean horizontal position, as is often done
:), you might want to keep (x, y) but change the ways they get updated.

In fact, I would recommend significant changes to your whole design,
if you were planning to build on this. Instead of having a surfaces
array with two elements (surfaces and their rects), I would create a
sprite class which has both a surface and a rect. Then you could
just have a list of sprites. Keeping data in parallel arrays is
generally a bad idea -- what if you change one but forget to change
the other? Like delete the surface but forget the rect?

Ethan
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFG5gXrhRlgoLPrRPwRAm0cAJ45J36sIfd8KZDDDv75lZ6B5w4ssACeLFZZ
DZl4atSYBjk7YsPoYYm4elI=
=P+Qm
-END PGP SIGNATURE-


Re: [pygame] Yeah looks like i'm doing quite well so far, completed my goal for today.

2007-09-10 Thread Lamonte Harris
I still don't understand the sprite class yet.  If you have time can you
give me a brief desc :).

On 9/10/07, Ethan Glasser-Camp [EMAIL PROTECTED] wrote:

 -BEGIN PGP SIGNED MESSAGE-
 Hash: SHA1

 Lamonte Harris wrote:
  Okay :), I fixed it I had the x and y in the wrong spot:
 
  self.create_box(self.map[z][q][0],self.map[z][q][1],(y,x))  is the
  correct method.

 If you really mean for the variable y to mean vertical position
 and the variable x to mean horizontal position, as is often done
 :), you might want to keep (x, y) but change the ways they get updated.

 In fact, I would recommend significant changes to your whole design,
 if you were planning to build on this. Instead of having a surfaces
 array with two elements (surfaces and their rects), I would create a
 sprite class which has both a surface and a rect. Then you could
 just have a list of sprites. Keeping data in parallel arrays is
 generally a bad idea -- what if you change one but forget to change
 the other? Like delete the surface but forget the rect?

 Ethan
 -BEGIN PGP SIGNATURE-
 Version: GnuPG v1.4.6 (GNU/Linux)
 Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

 iD8DBQFG5gXrhRlgoLPrRPwRAm0cAJ45J36sIfd8KZDDDv75lZ6B5w4ssACeLFZZ
 DZl4atSYBjk7YsPoYYm4elI=
 =P+Qm
 -END PGP SIGNATURE-



Re: [pygame] Yeah looks like i'm doing quite well so far, completed my goal for today.

2007-09-10 Thread Lamonte Harris
Humm.. I don't see why/how I should use it.  When it comes to my functions I
don't see how I would use it.

class map_:
def __init__(self,block=100,wndow=(300,300)):
self.BLOCK = block
self.size = wndow
self.map = []
self.surfaces = [[],[]]
self.window = pygame.display.set_mode(self.size)
pygame.init()
def create_box(self,size,color,rect):
box = pygame.Surface((size))
pygame.draw.rect(box,color,box.get_rect())
self.surfaces[0].append(box)
self.surfaces[1].append(rect)

Can you explain a little more.

On 9/10/07, Ethan Glasser-Camp [EMAIL PROTECTED] wrote:

 Lamonte Harris wrote:
  Can you give me a very basic example, I've been trying to look at code
  examples and the docs and I'm still not catching on.

 Attached is a very basic example. Note that I use the Rect move_ip
 function; if you aren't familiar with pygame.rect.Rect, this might be
 new to you.

 Ethan




Re: [pygame] Yeah looks like i'm doing quite well so far, completed my goal for today.

2007-09-10 Thread Ethan Glasser-Camp
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Lamonte Harris wrote:
 class map_:
 def __init__(self,block=100,wndow=(300,300)):
 self.BLOCK = block
 self.size = wndow
 self.map = []
 self.surfaces = [[],[]]
 self.window = pygame.display.set_mode(self.size)
 pygame.init()
 def create_box(self,size,color,rect):
 box = pygame.Surface((size))
 pygame.draw.rect(box,color,box.get_rect())
 self.surfaces[0].append(box)
 self.surfaces[1].append(rect)
 
 Can you explain a little more.

I can explain a lot more.

In your code, you have a structure called surfaces, which is kept in
the map class. This structure is a list with two elements. These two
elements are themselves lists -- the first one is a list of Surface
objects, representing images, and the second one is a list of some
type representing location of these images on-screen. In the code
snippet above, your map create_box method adds an image and a
location to this surfaces structure. These two things, image and
location, are paired, in a sense; the image has a location, and
putting a different image at the same location, or putting the same
image at a different location, would be a bug.

Pairing information in this way is very common in all kinds of
programs, not just games, and there are many mechanisms for showing
this kind of pairing. You have implemented a mechanism which I will
call parallel arrays; in order to access an image and its
corresponding location, you look up the same index in two lists
(surfaces[0][i] and surfaces[1][i]). This is a simple mechanism, and
it works fine, but there are some complications. For instance, let's
say you have five images, and five locations. Now you want to delete
an image, but forget to delete its location. Now you have four images
and five locations, and it may not be possible to figure out which
image goes with which location.

I am proposing the use of another structure, which is called sprite
here but can really be called anything, which combines both the image
and the location. If you were to structure your map_ class this way,
instead of having structures be a list of two lists, it would be one
list of sprites. To access the image and the location, you would do
surfaces[i].image and surfaces[i].rect. In addition, you no longer
have to worry about deleting all the parts of the sprite object; once
the sprite is removed from the surfaces list, it's gone, not
half-there like in the hypothetical forgot to delete something case.

There is more to pygame sprites, but the reason I suggested you use
them is that they keep the image and its location together.

This is the why. The how is outlined in the code I sent -- it
creates one sprite, and uses its image and rect attributes to
simplify moving it around onscreen (in an admittedly trivial way). As
it applies to your own code you can probably figure out on your own.

HTH,

Ethan
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFG5hRXhRlgoLPrRPwRAkA+AKC2ys7nnDAbdX6Gd3NzVTf0eIZH2QCdFZK2
G9xndlCnp/vvSqr+Hb8K9vY=
=lAFx
-END PGP SIGNATURE-


Re: [pygame] Yeah looks like i'm doing quite well so far, completed my goal for today.

2007-09-10 Thread Lamonte Harris
Okay I'm a bit confused with the whole surfaces[i].image I understand how to
assign rects and all but what I mean is how would I go about making that
class into a list?

On 9/10/07, Ethan Glasser-Camp [EMAIL PROTECTED] wrote:

 -BEGIN PGP SIGNED MESSAGE-
 Hash: SHA1

 Lamonte Harris wrote:
  class map_:
  def __init__(self,block=100,wndow=(300,300)):
  self.BLOCK = block
  self.size = wndow
  self.map = []
  self.surfaces = [[],[]]
  self.window = pygame.display.set_mode(self.size)
  pygame.init()
  def create_box(self,size,color,rect):
  box = pygame.Surface((size))
  pygame.draw.rect(box,color,box.get_rect())
  self.surfaces[0].append(box)
  self.surfaces[1].append(rect)
 
  Can you explain a little more.

 I can explain a lot more.

 In your code, you have a structure called surfaces, which is kept in
 the map class. This structure is a list with two elements. These two
 elements are themselves lists -- the first one is a list of Surface
 objects, representing images, and the second one is a list of some
 type representing location of these images on-screen. In the code
 snippet above, your map create_box method adds an image and a
 location to this surfaces structure. These two things, image and
 location, are paired, in a sense; the image has a location, and
 putting a different image at the same location, or putting the same
 image at a different location, would be a bug.

 Pairing information in this way is very common in all kinds of
 programs, not just games, and there are many mechanisms for showing
 this kind of pairing. You have implemented a mechanism which I will
 call parallel arrays; in order to access an image and its
 corresponding location, you look up the same index in two lists
 (surfaces[0][i] and surfaces[1][i]). This is a simple mechanism, and
 it works fine, but there are some complications. For instance, let's
 say you have five images, and five locations. Now you want to delete
 an image, but forget to delete its location. Now you have four images
 and five locations, and it may not be possible to figure out which
 image goes with which location.

 I am proposing the use of another structure, which is called sprite
 here but can really be called anything, which combines both the image
 and the location. If you were to structure your map_ class this way,
 instead of having structures be a list of two lists, it would be one
 list of sprites. To access the image and the location, you would do
 surfaces[i].image and surfaces[i].rect. In addition, you no longer
 have to worry about deleting all the parts of the sprite object; once
 the sprite is removed from the surfaces list, it's gone, not
 half-there like in the hypothetical forgot to delete something case.

 There is more to pygame sprites, but the reason I suggested you use
 them is that they keep the image and its location together.

 This is the why. The how is outlined in the code I sent -- it
 creates one sprite, and uses its image and rect attributes to
 simplify moving it around onscreen (in an admittedly trivial way). As
 it applies to your own code you can probably figure out on your own.

 HTH,

 Ethan
 -BEGIN PGP SIGNATURE-
 Version: GnuPG v1.4.6 (GNU/Linux)
 Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

 iD8DBQFG5hRXhRlgoLPrRPwRAkA+AKC2ys7nnDAbdX6Gd3NzVTf0eIZH2QCdFZK2
 G9xndlCnp/vvSqr+Hb8K9vY=
 =lAFx
 -END PGP SIGNATURE-



Re: [pygame] Yeah looks like i'm doing quite well so far, completed my goal for today.

2007-09-10 Thread Ethan Glasser-Camp
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Lamonte Harris wrote:
 Okay I'm a bit confused with the whole surfaces[i].image I understand
 how to assign rects and all but what I mean is how would I go about
 making that class into a list?

In Python, lists contain other objects of any type. To access one of
the objects in the list, you use a subscript, like: l[0]. Adding a
sprite to a list is no different from adding any other object to a
list. In your code, the way you did it was to create a variable box,
and then call something like l.append(box). So if I were you, I
would create the sprite, set the image and rect to some values, and
then call something like l.append(sprite).

Ethan
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFG5hgehRlgoLPrRPwRAmCVAJ9r41dEG7vJoQ9BYYtiAUvutEUU/gCdFBAx
x7YQZYCfuNIF3/ckxFHC6ow=
=ykWz
-END PGP SIGNATURE-


Re: [pygame] Yeah looks like i'm doing quite well so far, completed my goal for today.

2007-09-10 Thread Lamonte Harris
Oh dude you might be a life saver I found this script on google and I
understand it.

http://www.daniweb.com/code/snippet390.html thats what you ment right

On 9/10/07, Ethan Glasser-Camp [EMAIL PROTECTED] wrote:

 -BEGIN PGP SIGNED MESSAGE-
 Hash: SHA1

 Lamonte Harris wrote:
  Okay I'm a bit confused with the whole surfaces[i].image I understand
  how to assign rects and all but what I mean is how would I go about
  making that class into a list?

 In Python, lists contain other objects of any type. To access one of
 the objects in the list, you use a subscript, like: l[0]. Adding a
 sprite to a list is no different from adding any other object to a
 list. In your code, the way you did it was to create a variable box,
 and then call something like l.append(box). So if I were you, I
 would create the sprite, set the image and rect to some values, and
 then call something like l.append(sprite).

 Ethan
 -BEGIN PGP SIGNATURE-
 Version: GnuPG v1.4.6 (GNU/Linux)
 Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

 iD8DBQFG5hgehRlgoLPrRPwRAmCVAJ9r41dEG7vJoQ9BYYtiAUvutEUU/gCdFBAx
 x7YQZYCfuNIF3/ckxFHC6ow=
 =ykWz
 -END PGP SIGNATURE-



Re: [pygame] Yeah looks like i'm doing quite well so far, completed my goal for today.

2007-09-10 Thread Ethan Glasser-Camp
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Lamonte Harris wrote:
 Oh dude you might be a life saver I found this script on google and I
 understand it.
 
 http://www.daniweb.com/code/snippet390.html thats what you ment right

This is a good example of how objects are created and added to a list,
yes.

Ethan
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFG5hl+hRlgoLPrRPwRArqTAJ9tT/sK5Tjqqht+RUYr51Ao0Q1mWwCdGOhi
dK4FAKDZu5N+k26dK5rk4sY=
=arD5
-END PGP SIGNATURE-


Re: [pygame] Yeah looks like i'm doing quite well so far, completed my goal for today.

2007-09-10 Thread Lamonte Harris
Okay kool, I'll start rewriting and see what I come up with 2morrow :).

import pygame,sys,string
from pygame.locals import *
class Block(pygame.sprite.Sprite):
def __init(self):
pygame.sprite.Sprite.__init__(self)


Is that a good start btw?

On 9/10/07, Ethan Glasser-Camp [EMAIL PROTECTED] wrote:

 -BEGIN PGP SIGNED MESSAGE-
 Hash: SHA1

 Lamonte Harris wrote:
  Oh dude you might be a life saver I found this script on google and I
  understand it.
 
  http://www.daniweb.com/code/snippet390.html thats what you ment right

 This is a good example of how objects are created and added to a list,
 yes.

 Ethan
 -BEGIN PGP SIGNATURE-
 Version: GnuPG v1.4.6 (GNU/Linux)
 Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

 iD8DBQFG5hl+hRlgoLPrRPwRArqTAJ9tT/sK5Tjqqht+RUYr51Ao0Q1mWwCdGOhi
 dK4FAKDZu5N+k26dK5rk4sY=
 =arD5
 -END PGP SIGNATURE-



Re: [pygame] Yeah looks like i'm doing quite well so far, completed my goal for today.

2007-09-10 Thread Ethan Glasser-Camp
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Lamonte Harris wrote:
 def __init(self):
 
 Is that a good start btw?

Most people write __init__ instead of __init.

The best way to figure out of something is a good start is to keep
going with it and see what happens.

Ethan
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFG5hrxhRlgoLPrRPwRAqWYAKCpUQUCh9m3mTiAz0n/T//x94uwWACfZcZ7
CoD5SMBuWzNG2dQ/PAWTqts=
=ms66
-END PGP SIGNATURE-


Re: [pygame] Yeah looks like i'm doing quite well so far, completed my goal for today.

2007-09-10 Thread Lamonte Harris
Yeah I just seen it lol sorry my mistake.  I'll email back when I'm done.

Thanks for all the help, so far so good.

On 9/10/07, Ethan Glasser-Camp [EMAIL PROTECTED] wrote:

 -BEGIN PGP SIGNED MESSAGE-
 Hash: SHA1

 Lamonte Harris wrote:
  def __init(self):
 
  Is that a good start btw?

 Most people write __init__ instead of __init.

 The best way to figure out of something is a good start is to keep
 going with it and see what happens.

 Ethan
 -BEGIN PGP SIGNATURE-
 Version: GnuPG v1.4.6 (GNU/Linux)
 Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

 iD8DBQFG5hrxhRlgoLPrRPwRAqWYAKCpUQUCh9m3mTiAz0n/T//x94uwWACfZcZ7
 CoD5SMBuWzNG2dQ/PAWTqts=
 =ms66
 -END PGP SIGNATURE-



Re: [pygame] Is there some type of hex codes to rgb converter or something?

2007-09-10 Thread Luke Paireepinart

Lamonte Harris wrote:

I came up w/ this for my class:
def hex_converter(self,hexcolorcode):
hexcolorcode = hexcolorcode[1:]
red = hexcolorcode[0:2]
red = int(red,16)
blue = hexcolorcode[2:4]
blue = int(blue,16)
green = hexcolorcode[4:6]
green = int(green,16)
return (red,green,blue)

Thanks. again
Sure.  Are you sure you're using your classes right, though?  A method 
of a class should change instance attributes, and only secondly return 
values.  That shouldn't be its primary focus.
If you have more questions that are python-specific but not 
pygame-specific, try asking on the python-tutor mailing list.  It's a 
nice list geared specifically toward people learning Python.

-Luke


Re: [pygame] Is there some type of hex codes to rgb converter or something?

2007-09-10 Thread Lamonte Harris
It works well for me.  Its just a snippet i grabed from my class O_o.

On 9/10/07, Luke Paireepinart [EMAIL PROTECTED] wrote:

 Lamonte Harris wrote:
  I came up w/ this for my class:
  def hex_converter(self,hexcolorcode):
  hexcolorcode = hexcolorcode[1:]
  red = hexcolorcode[0:2]
  red = int(red,16)
  blue = hexcolorcode[2:4]
  blue = int(blue,16)
  green = hexcolorcode[4:6]
  green = int(green,16)
  return (red,green,blue)
 
  Thanks. again
 Sure.  Are you sure you're using your classes right, though?  A method
 of a class should change instance attributes, and only secondly return
 values.  That shouldn't be its primary focus.
 If you have more questions that are python-specific but not
 pygame-specific, try asking on the python-tutor mailing list.  It's a
 nice list geared specifically toward people learning Python.
 -Luke



Re: [pygame] Yeah looks like i'm doing quite well so far, completed my goal for today.

2007-09-10 Thread Lamonte Harris
Ok heres my outcome.  main2.py is the newer one.  main.py is the older one.

On 9/10/07, Lamonte Harris [EMAIL PROTECTED] wrote:

 Yeah I just seen it lol sorry my mistake.  I'll email back when I'm done.

 Thanks for all the help, so far so good.

 On 9/10/07, Ethan Glasser-Camp [EMAIL PROTECTED] wrote:
 
  -BEGIN PGP SIGNED MESSAGE-
  Hash: SHA1
 
  Lamonte Harris wrote:
   def __init(self):
  
   Is that a good start btw?
 
  Most people write __init__ instead of __init.
 
  The best way to figure out of something is a good start is to keep
  going with it and see what happens.
 
  Ethan
  -BEGIN PGP SIGNATURE-
  Version: GnuPG v1.4.6 (GNU/Linux)
  Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
 
  iD8DBQFG5hrxhRlgoLPrRPwRAqWYAKCpUQUCh9m3mTiAz0n/T//x94uwWACfZcZ7
  CoD5SMBuWzNG2dQ/PAWTqts=
  =ms66
  -END PGP SIGNATURE-
 


import pygame,sys,string
from pygame.locals import *
class Block(pygame.sprite.Sprite):
def __init__(self):
pygame.sprite.Sprite.__init__(self)
class map_(object):
def __init__(self,block=100,wndow=(300,300)):
self.BLOCK = block
self.size = wndow
self.window = pygame.display.set_mode(self.size)
self.blocks = []
self.map = []
pygame.init()
def hex_converter(self,hexcolorcode):
hexcolorcode = hexcolorcode[1:]
red = hexcolorcode[0:2]
red = int(red,16)
blue = hexcolorcode[2:4]
blue = int(blue,16)
green = hexcolorcode[4:6]
green = int(green,16)
return (red,green,blue)
def create_box(self,size,color,rect):
box = Block()
box.image = pygame.Surface((size))
pygame.draw.rect(box.image,color,box.image.get_rect())
box.color = color
box.point = rect
self.blocks.append(box)
def load_text_map(self,map):
file = open(map,r)
links = file.readlines()
file.close()
x = 0
total = len(links)
k = 0
while ktotal:
self.map.append([])
k += 1
for i in links:
i = string.replace(i,\n,)
i = i.split(,)
for e in i:
self.map[x].append(e)
x += 1
def render_map(self,aray,dict):
x=0
for e in aray:  
z = 0
for y in e:
aray[x][z] = dict[int(y)]
z += 1
x += 1
return aray
def main(self):
z = 0
x = 0
y = 0
m = 0
while z  len(self.map):
q = 0
while q  len(self.map[z]):

self.create_box(self.map[z][q][0],self.map[z][q][1],(x,y))
x += self.BLOCK
q += 1
x = 0
y += self.BLOCK
z += 1
self.draw_box()
def draw_box(self):
while True:
for event in pygame.event.get():
if event.type == pygame.QUIT: sys.exit()
e = 0
while e  len(self.blocks):

self.window.blit(self.blocks[e].image,self.blocks[e].point)
e += 1
pygame.display.update()
Map = map_(25)
tiles = {1 : [(25,25),Map.hex_converter(#E0ECFF)], 2 : 
[(25,25),Map.hex_converter(#B5EDBC)], 3 : 
[(25,25),Map.hex_converter(#F3E807)] }
Map.load_text_map(map1.map)
Map.render_map(Map.map,tiles)
Map.main()import pygame,sys,string
from pygame.locals import *
class map_:
def __init__(self,block=100,wndow=(300,300)):
self.BLOCK = block
self.size = wndow
self.map = []
self.surfaces = [[],[]]
self.window = pygame.display.set_mode(self.size)
pygame.init()
def create_box(self,size,color,rect):
box = pygame.Surface((size))
pygame.draw.rect(box,color,box.get_rect())
self.surfaces[0].append(box)
self.surfaces[1].append(rect)
def load_text_map(self,map):
file = open(map,r)
links = file.readlines()
file.close()
x = 0
total = len(links)
k = 0
while ktotal:

Re: [pygame] Yeah looks like i'm doing quite well so far, completed my goal for today.

2007-09-10 Thread Lamonte Harris
Sorry I forgot the map1.map file.

On 9/10/07, Lamonte Harris [EMAIL PROTECTED] wrote:

 Ok heres my outcome.  main2.py is the newer one.  main.py is the older
 one.

 On 9/10/07, Lamonte Harris [EMAIL PROTECTED]  wrote:
 
  Yeah I just seen it lol sorry my mistake.  I'll email back when I'm
  done.
 
  Thanks for all the help, so far so good.
 
  On 9/10/07, Ethan Glasser-Camp [EMAIL PROTECTED] wrote:
  
   -BEGIN PGP SIGNED MESSAGE-
   Hash: SHA1
  
   Lamonte Harris wrote:
def __init(self):
   
Is that a good start btw?
  
   Most people write __init__ instead of __init.
  
   The best way to figure out of something is a good start is to keep
   going with it and see what happens.
  
   Ethan
   -BEGIN PGP SIGNATURE-
   Version: GnuPG v1.4.6 (GNU/Linux)
   Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
  
   iD8DBQFG5hrxhRlgoLPrRPwRAqWYAKCpUQUCh9m3mTiAz0n/T//x94uwWACfZcZ7
   CoD5SMBuWzNG2dQ/PAWTqts=
   =ms66
   -END PGP SIGNATURE-
  
 
 




map1.map
Description: Binary data


Re: [pygame] Is there some type of hex codes to rgb converter or something?

2007-09-10 Thread Luke Paireepinart

Lamonte Harris wrote:

It works well for me.  Its just a snippet i grabed from my class O_o.

The fact that it works doesn't mean it's good practice.
This also works:
a = 1
b = a + 1
c = b + 1
d = c + 1
e = d + 1
but it's much more common (and better practice) to just straight-away say
e = 5
unless you really need all those intermediate values.  And still that 
wouldn't be the best way to assign them.
Your class isn't designed correctly if your methods don't do anything 
but return values.
This is for many reasons: efficiency, maintainability, readability, etc. 
etc.
But in general, the Object Oriented paradigm is centered around objects 
that are collections of data and methods (related functions) that act on 
data.  If your classes just take in external data and output data 
externally to the class, they're not objects.  Then you're just using 
classes to group functions which may or may not be related, and no data 
involving them.
I was trying to word it in a way that was less critical, but that's the 
general meaning I was trying to get across: your class should be 
modifying data internally.
It's possible that the rest of your class does, and for some reason or 
another you just had to code this method this way, but since I can't see 
your code I can only assume.

-Luke


Re: [pygame] Is there some type of hex codes to rgb converter or something?

2007-09-10 Thread Noah Kantrowitz

#abc - #aabbcc - (0xaa, 0xbb, 0xcc)

--Noah

On Sep 10, 2007, at 7:08 PM, Lamonte Harris wrote:

I like using HTML hex, is there a library or something on pygame or  
python it self to convert hex to rgb