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

Re: [pygame] Texture for raycasting engine



On Thu, 6 Mar 2008 16:51:22 +0100, Julia <midnightjulia@xxxxxxxxx> wrote:
> 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 :)


Quick reply: Do you mean the basics of loading images in general? If so,
that's just pygame.image.load(), sometimes adding .convert() or
.convert_alpha() for certain other effects. See the Documentation section
of pygame.org for that.

For scaling that's:
scaled_version = pygame.transform.scale(original,(new_width,new_height))

Also, try pygame.transform.scale2x(), which doubles an image's size using
an interpolation technique that looks a lot better than the most obvious
way of scaling up.

If you mean you need to scale a loaded image to a polygon in 3D, take a
look at my "Mode 7" code for a slow but usable example that maps a flat
image to a trapezoidal "ground":
http://kschnee.xepher.net/code/mode7test.py

Kris