Alright.
I test-ran the code myself in a new program, and… I got the black box in the corner. <_<
The map itself was moving around randomly and crashing occasionally, but I fixed that (several tyupos, a logic error, several more tuypso, etc.) and now it’s working just fine in my little program. I added the symbols in and they work, too.
So, I filled in a bunch of “EDIT SPOT” comments to point out places you can edit to change items or areas and rooms. Don’t edit anything else or it may mess up the system. You can see that I already followed a few of the edit spots and added some stuff in. Some of it is because I was working with one room the size of the entire area. Just pay attention to what it says at each EDIT SPOT and hopefully you’ll be able to figure out what to do for the rooms in your game.
The new code:
init_area_1():
[code]// EDIT NOTE: If you want to have different areas
// copy and paste the code into a new init_area_*() script
// and change the EDIT SPOTs to match the new area
// EDIT SPOT: Change the number below to the area number of the script
if (global.area != 1) // * = area #
{
// EDIT SPOT: Same here.
global.area = 1;
// EDIT SPOT: Change the following 3 values for other areas
global.mapimage = Map1; // * = sprite of the map of the area
global.area_width = 6; // * = area width in squares
global.area_height = 6; // * = area height in squares
// This clears out symbols so there are none on the map
// (there will likely be symbols leftover from other areas
// so it’s a good idea to clear the area first)
for (i = 0; i < 6; i += 1)
{
for (j = 0; j < 6; j += 1)
{
global.area_symbol[i,j] = 0;
}
}
// EDIT SPOT:
// Here’s where you fill in the symbols over the default set above
// To add item symbols, add these two lines of code:
// if (global.ITEM_ID == true) global.area_symbol[ITEM_X,ITEM_Y] = 1;
// else global.area_symbol[ITEM_X,ITEM_Y] = 2;
// ITEM_ID is the same value given to the item from
// within the room’s creation code that the item is in.
// If they’re not the same, it won’t work right.
// ITEM_X and ITEM_Y are the coordinates of the square containing the item
// Other symbols are easy to figure out how to add
// 1 = collected item, 2 = not collected item
// These are ALL the symbols in the area:
if (global.area1_missile0 == true) global.area_symbol[5,5] = 1;
else global.area_symbol[5,5] = 2;
if (global.area1_missile1 == true) global.area_symbol[5,2] = 1;
else global.area_symbol[5,2] = 2;
}[/code]
HUD draw event code:
[code]/////MAP CODE/////
SamusMapx = floor(obj_Samus1.x/320)+global.room_x;
SamusMapy = floor(obj_Samus1.y/240)+global.room_y;
if (SamusMapx >= 0 && SamusMapy >= 0) global.area1_explored[SamusMapx,SamusMapy] = true;
//Draw Black Box Code
draw_set_color(c_black);
draw_rectangle(view_xview[view_current]+275,view_yview[view_current]+2,view_xview[view_current]+300,view_yview[view_current]+27,false);
draw_set_color(c_white);
//End of Draw Black Box Code
//draw_sprite(spr_mapdata,0,view_xview[view_current]+275,view_yview[view_current]+2);
for (i = SamusMapx-1; i <= SamusMapx+1; i += 1)
{
for (j = SamusMapy-1; j <= SamusMapy+1; j += 1)
{
if (i >= 0 && j >= 0 && i < global.area_width && j < global.area_height)
{
if (global.area1_explored[i,j] == true)
{
draw_sprite_part(global.mapimage,0,1+i8,1+j8,8,8,view_xview[view_current]+276+(i+1-SamusMapx)*8,view_yview[view_current]+3+(j+1-SamusMapy)*8);
if (global.area_symbol[i,j] == 1) draw_sprite(spr_itemdot,0,view_xview[view_current]+276+(i+1-SamusMapx)*8, view_yview[view_current]+3+(j+1-SamusMapy)*8);
else if (global.area_symbol[i,j] == 2) draw_sprite(spr_itemcir,0,view_xview[view_current]+276+(i+1-SamusMapx)*8, view_yview[view_current]+3+(j+1-SamusMapy)*8);
// EDIT SPOT: Here’s where you draw symbols on the map
// So, if you add a new symbol, add a new line above these comments
// Fill in “SYMBOLNUMBER” and “SYMBOLSPRITE” appropriately from the below format
// Change nothing else. Here’s the format for adding a symbol:
// else if (global.area_symbol[i,j] == SYMBOLNUMBER) draw_sprite(SYMBOLSPRITE,0,view_xview[view_current]+276+(i+1-SamusMapx)*8, view_yview[view_current]+3+(j+1-SamusMapy)*8);
}
}
}
}
// EDIT SPOT: If you’re going to add a flashing Samus icon or
// something over the center of the mini-map, here is where you would add it.[/code]
obj_Samus1 collision with missile expansion:
[code]// This is the Samus’s collision with the missile expansion.
with (other)
{
global.maxmissiles+=5;
global.missiles+=5;
execute_string(collection);
global.area_symbol[floor(x/320)+global.room_x,
floor(y/240)+global.room_y] = 1;
instance_destroy();
}[/code]
Room creation code:
[code]// EDIT NOTE: Copy and paste all of this code in for each room in your game
// that uses the mini-map, then change the coordinates and other EDIT SPOTs
// to fit the room
// EDIT SPOT: Change the coordinates of the room for each room
// It’s the coordinates of the upper-left square of the room, remember
// Otherwise it’ll be messed up
// The coordinates:
global.room_x = 0;
global.room_y = 0;
// global.area1_explored[i,j] = true
// EDIT SPOT: This function should call the area that the room is in
// If the room isn’t in the area number it’s calling right now
// Change it to make it so or the minimap won’t work correctly.
init_area_1();
// Item Collection Code
// EDIT SPOT: For each item in this particular room…
// Add these two lines of code:
// newexpansion = instance_create(ITEM_X,ITEM_Y,ITEM_OBJECTNAME);
// newexpansion.collection = “global.ITEM_ID = true;”;
// Change ITEM_X and ITEM_Y to the coordinates of the
// item, in pixels, in the room
// ITEM_OBJECTNAME is the name of the object. m_e for missile expansions,
// for example
// ITEM_ID is what you’d call the item in the area. Like, “area1_missile1”
// It should be the same as what the end of init_area_1 uses
// to check if it has been collected or not. That’s the only reason
// it’s used.
// This code adds the instance, so don’t place the objects into the room
// with GM’s room editor or there will be two. Remember the location of
// those and add them using the two lines in here.
// Anywhere, here’s where you add those lines of code:
newexpansion = instance_create(160+3205,120+2402,m_e);
newexpansion.collection = “global.area1_missile0 = true”;
newexpansion = instance_create(160+3205,120+2405,m_e);
newexpansion.collection = “global.area1_missile1 = true”;
// If there aren’t any items in the room, don’t bother with the code.[/code]
AND
Here is my program:
http://download.yousendit.com/C40D9F9F1E240CE7
I was lazy with the graphics, and the entire area is one huge room. Zoom around the area, collect the black circles which are apparently missile expansions and watch as the symbol on the map changes.
Maybe it’ll help you figure out what’s wrong with how you’re adding the code to your own game…
Or if not, it at least shows you that it works really nicely. If you need a full map drawn on the pause menu, just ask. (It’s set up to easily support that)