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

Re: [pygame] Texture for raycasting engine



Thank you for your answers and I'm sorry for the lack of clarity. I've been working on the project so long I didn't think about the fact that the whole thing wasn't as clear to you as it was to me.

What I am working on is basically a Wolfenstein 3d type of game. So my raycasting engine is more of a 2.5d engine. Despite my somewhat limited trigonometric skills the game acutely works and now I'm trying to get textures for the game. (And yes, will use using the original Wolf textures ; )

From Wikipedia: In order to draw the world, a single ray is traced for every column of screen pixels and a vertical slice of wall texture is selected and scaled according to where in the world the ray hits a wall and how far it travels before doing so.

My problem is I'm not really sure where to start if I'm going to do this with images in pygame. So far I've only needed to used pygame.draw.line() so right now I'm rather lost.

Julia


On Thu, Mar 6, 2008 at 6:32 PM, Christian Reichlin <chrigi@xxxxxxxxxxx> wrote:
hi,

if you are working on a classic raycasting engine like wolfenstein3d or
similar games used where you only have vertical walls there is a short
tutorial on http://www.permadi.com/tutorial/raycast/ or one at
they are both not in python or pygame but they explain how the textures
are calculated.
in the end you simply have to draw a scaled one pixel column of a
texture on every column of the screen. for this you can maybe use
pygame.transform.chop and pygame.transform.scale but it might be to slow.
if you want to do it yourself you can use a modified bresenham
algorithmus. http://en.wikipedia.org/wiki/Bresenham's_line_algorithm
because you need only the y coordinates for vertical lines you can use
the x coordinate for the position in the texture you draw.

chrigi

Julia schrieb:
> Hi everyone!
>
> I am currently working on a raycasting engine using pygame for
> graphics.  The
> engine works great and now I'm thinking about adding support for textures.
> The problem is that I'm not really sure to with modules and methods to
> use.
> I need to be able to load textures, scale then to fit and then draw the
> scaled image. Any tips on a smart way to do this? Good tutorial url's are
> also appreciated :)
>
> / J