[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[pygame] Old pygame tutorial not working



Hello,

For a 3D game I'm making, I need to load a grey heightmap*.  Obviously, only 256 heights are possible.  In game, this translates to a landscape having "steps". 

-My current method, loading the data pixel by pixel with Surface.get_at() seems inefficient.  There is a faster way through Numeric.  What?  (Note that I only want one component of the color, as it is grey.  Not alpha though).

-The array must be blurred, i.e. made so that the "steps" no longer exist.  The only unique example I could find originates here:
http://www.pygame.org/docs/tut/surfarray/SurfarrayIntro.html
...andt gives me an error:
soften[1:,  0:  ] += Data[0:-1,0:  ]*8
TypeError: list indices must be integers
Plus, as the height at the edges of the landscape is not necessarily the same, the edges must be specially handled so that they don't average heights with stuff on the other side of the map.

Thanks,
Ian

*Heightmaps are greyscale images containing height data--with the intensity of the grey corresponding to the height.