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

[pygame] Re : [pygame] raycasting engine performances (numpy array)



In fact it s not for professional stuff or whatever but i am à huuuuge fan of python and of old school techniques such as raycasting. I have already wrote a wolfenstein clone in c using le libx. Textures and some.effects were implemented without any lag ( i can give the code if anyone is interested). So now i'd like to write à more advanced wolf/doom like using an OO approach. So i though Python of course cause it's soon sexy blablabla but maybe not adapted.
So now my question is, can i write the game logic entirely in python and write the rendering part in C with OpenGL calls?
Thank you in advance!

----- Reply message -----
De : "Weeble" <clockworksaint@xxxxxxxxx>
PourÂ: <pygame-users@xxxxxxxx>
Objet : [pygame] raycasting engine performances (numpy array)
Date : ven., avr. 27, 2012 08:36


On Thu, Apr 26, 2012 at 1:49 PM, Nathan Biagini <nathan.open@xxxxxxxxx> wrote:
> i dunno if i can do more "optimized" as a drawing line function...

I see a moderate speed-up when replacing:

   asf[x][y] = 255

with:

   asf[x,y] = 255

Which avoids doing two layers of Python indexing for each pixel.
Still, it doesn't make it fast enough to be smooth. I see a much
bigger speed-up if I replace that loop with:

   asf[x,start:end] = 255

This shifts the whole loop into C code with no Python interpreter to
slow it down. The only problem is figuring out how to express the
texturing as something numpy can do do efficiently. I think it may
well be possible, but I'm not enough of a numpy expert to know off the
top of my head.

I totally agree with Greg: only do this if it's for your own education
and amusement. Raycasting on the CPU is always going to be way slower
than a GPU can do, even if you can get the Python interpreter out of
all the slow bits (whether that's by way of numpy, PyPy or just plain
writing some C).