Dynamic Maps


Geuben

Member
Joined
Sep 5, 2006
Messages
180
does anyone know how to effictivly create a 'dynamic' map, i want to be able to add a block of colour to a map whislt in the game. basically, when u place a building, i want it to place the footprint of the building at the correct coordinates in the map, for use in a hardness map for pathfinding.
 
Well, I guess if you're using a tile map, it would be as easy as changing the element of the map array at the certain coordinate on which you place the building. That would imply that you're redrawing the tile map every game cycle, or every time when you update it in a way or another.

- Alex
 
If you still want to do it that way, use
Code:
hardness=new_map(x_size,y_size,bitmode);
once to create the hardness map and then just use
Code:
map_put(0,hardness,number,x,y);
where number is the number of the hardness tile in your fpg (a square with just the color you check for collision),
or your id for a loaded png or something (like hardtile=load_png("hardtile.png");)
If you use more than one fpg, change 0 to the name of the fpg.

Easy way to check for collision then is to use
Code:
if(map_get_pixel(0,hardness,x,y)==collision_color) do_something; end;
Don`t forget to do a
Code:
map_clear(0,hardness,-1);
to clear the map to use it for the next screen (-1 sets the whole map to white).
 
Back
Top