- Online Community Forums » Programming Questions » mappy and collision removal

This thread is locked; no one can reply to it. rss feed Print
mappy and collision removal
Member #8,352
February 2007

hey, ive searched the forums and found a lot of questions and answers relating to mappy, but i couldnt find anything that solves my problem.

i have a map made with mappy, with 3 different block types.
1- land, walkable.
2- grass, collision, non walkable. BUT can be removed so that it is walkable.
3- rock, collision, non walkable.

here is a sample map

the player starts off on the left side and needs to make it across to the right side.
and in order to do that, the player needs to remove the grass by hitting a key (SPACE for example) so that he can make his way across.

now my problem arise, how do i code it so that SPACE removes the grass and changes it to a normal block 1(land)?


Jeff Bernard
Member #6,698
December 2005

You've got an array on intetegers, right? (I've never used Mappy). Just change the value:

if (tile_that_is_faced_is(2) // if you are facing the grass tile
    && key[KEY_SPACE]) // if you press the space key
       map[that_tile] = 1; // change it to land
       update_map_graphics(that_tile, 1); // if you need run a special function to change that tile

I thought I was wrong once, but I was mistaken.

Member #8,352
February 2007

nope, its not on an array, the map is actually loaded as a .fmp file..

William Labbett
Member #4,486
March 2004

I can't really help but perhaps the .fmp file format wasn't really meant to be writable. You either need to find out how to change the info in the .fmp which might require some help from whoever wrote mappy or write your own level editor which for the type of thing you're doing is dead easy :-

For example you could have a little bitmap. Choose a colour for each tile type you have. Load the bitmap. Declare a 2D array tiles[MAP_WIDTH][MAP_HEIGHT] then read the bitmap and write the array :

1enum tile_types{ LAND, GRASS, ROCKS };
5for(x = 0; x < MAP_WIDTH; ++x)
6 for(y = 0; y < MAP_HEIGHT; ++y)
7 {
8 colour = getpixel(level_bitmap, x, y);
10 tiles[x][y] = get_tile_type(colour);
11 }
14int get_tile_type(colour)
16 if(colour == makecol(............)) /* colour for land */
17 return LAND;
18 else if(colour == makecol(........)) /* colour for grass */
19 return GRASS;
20 else if(colour == makecol(....)) /* colour for ROCKS */
21 return ROCKS;

then you've got an array with the type of tile in and you can change it's
elements by doing what Jeff said.

Sorry if that's patronising - maybe you're keen to make use of Mappy in which case you need to learn about the .fmp format so that you can copy the map info into an array like above.

Member #8,352
February 2007

i figured it out, i had to use the method MapSetBlock, but now i have another question, which method am i suppose to use to retrieve a block id??
because i need to know if the block is grass or rock to determine if its removeable.

Go to: