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

Re: [pygame] map format



wow, after 8 months of reading, i'm actually going to reply to something!

anyway, solution 1 would likely be better in your case, another similar 
solution would be to use "walk boxes", if your map isn't comprised mostly of 
square tiles, this may be a better approach. this approach is used in things 
like those hilarious lucasarts adventure games, and some more recent stuff 
like final fantasy 7.

	polygons and lines defined in a separate file which the player can walk in 
the interior of boxes, and along lines, you can also have how big your 
character will be at any one point into the file too, so you your player's 
image can shrink and grow as they go further into the image. anyway, the 
lines dont have to run right up against the wall, and small, narrow paths can 
be served just fine with a line. From a map editor perspective, this is 
prolly a less stressfull approach, since you wont have to, pixel by pixel 
define what can pass where, you can place an average 6 or seven points, and 
connect the dots. Of course you would read this file and generate rects all 
around to collide against, however, it may be simpler to deal with collision 
on your own, since you might be keeping track of where they are on the boxes 
anyway to scale the player's image, or any other useful tags you want to put 
in there.

	obviously if this wont work for you, it wont work for you.

	i hope it's of use.

On Tuesday 22 October 2002 05:54 pm, Michael Benfield wrote:
> 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


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