[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[pygame] map format



I'm looking for a way to store maps for a game. What I have in mind, and what I will implement
unless I find something better, is to store the map in 2 files: one file is an image that contains
what the map looks like, which will actually be the background in the game. The second file is
an image that dictates how the map works. ie, white color in the second file is where the character
can walk, black color is walls, etc. So the first thing I'm wondering is: is this a decent way
to go about this?

Next... If I do it that way, there are two ways I could deal with knowing when the character is
smacking into a wall... 
1. When I load the map, I could build a list of rectangles that contain all the black (or whatever)
pixels in the second image, and then during the game check if the character's rect collides with
one of those rects.
2. Just check if any of the pixels that are within the character's rect on the second image are
black.

I'm leaning towards method 1, but I think I'll write both and do tests. But I was wondering if
anyone had any advice about that. Also, if I do implement method 1, any advice about how to go
about building that list of rects? The way I'm thinking about doing starts with
for x in range(surface.width()):
	for y in range(surface.height()):

and it won't be difficult to implement or anything but there's got to be a more efficient way...

anyway, Thanks 


-- 
Mike Benfield
____________________________________
pygame mailing list
pygame-users@seul.org
http://pygame.seul.org