Right now i have this. I plan on fixing the body up later but for now its what i need.
Code: Select all
void pickItem (string inv[5][5], int room, string item,int itemNum, string nothing)
{
string option;
if (room == itemNum)
{
cout << "There is a" << item << "in here. Do you want to pick it up? take or leave?";
cin >> option;
if (option == "take")
{
if (inv[0][0] == nothing)
{
inv[0][0] = item;
room = 0;
}
else if (inv[0][1] == nothing)
{
inv[0][1] = item;
room = 0;
}
else if (inv[0][2] == nothing)
{
inv[0][2] = item;
room = 0;
}
else if (inv[0][3] == nothing)
{
inv[0][3] = item;
room = 0;
}
else if (inv[0][4] == nothing)
{
inv[0][4] = item;
room = 0;
}
else if (inv[0][0] == nothing)
{
inv[0][0] = item;
room = 0;
}
else if (inv[1][1] == nothing)
{
inv[1][1] = item;
room = 0;
}
else if (inv[1][2] == nothing)
{
inv[1][2] = item;
room = 0;
}
else if (inv[1][3] == nothing)
{
inv[1][3] = item;
room = 0;
}
else if (inv[1][4] == nothing)
{
inv[1][4] = item;
room = 0;
}
if (inv[2][0] == nothing)
{
inv[2][0] = item;
room = 0;
}
else if (inv[2][1] == nothing)
{
inv[2][1] = item;
room = 0;
}
else if (inv[2][2] == nothing)
{
inv[2][2] = item;
room = 0;
}
else if (inv[2][3] == nothing)
{
inv[2][3] = item;
room = 0;
}
else if (inv[2][4] == nothing)
{
inv[2][4] = item;
room = 0;
}
else if (inv[3][0] == nothing)
{
inv[3][0] = item;
room = 0;
}
else if (inv[3][1] == nothing)
{
inv[3][1] = item;
room = 0;
}
else if (inv[3][2] == nothing)
{
inv[3][2] = item;
room = 0;
}
else if (inv[4][3] == nothing)
{
inv[3][3] = item;
room = 0;
}
else if (inv[3][4] == nothing)
{
inv[3][4] = item;
room = 0;
}
if (inv[4][0] == nothing)
{
inv[4][0] = item;
room = 0;
}
else if (inv[4][1] == nothing)
{
inv[4][1] = item;
room = 0;
}
else if (inv[4][2] == nothing)
{
inv[4][2] = item;
room = 0;
}
else if (inv[4][3] == nothing)
{
inv[4][3] = item;
room = 0;
}
else if (inv[4][4] == nothing)
{
inv[4][4] = item;
room = 0;
}
}
}
}
Code: Select all
if (player1.player_y == 2)
{
cout << room7.info<<endl;
currentRoom.room = 7;
currentRoom.left = room7.left;
currentRoom.right = room7.right;
currentRoom.up = room7.up;
currentRoom.down = room7.down;
map [0][0] = 'X';
map [1][0] = '-';
map [2][0] = '-';
map [0][1] = '-';
map [1][1] = '-';
map [2][1] = '-';
map [0][2] = '-';
map [1][2] = '-';
map [2][2] = '-';
pickItem (inventory[5][5], room7.item, health_potion.itemNum , health_potion.type, nothing.type );
pickItem (inventory[5][5], room7.item, shield.itemNum , shield.type, nothing.type );
pickItem (inventory[5][5], room7.item, sword.itemNum , sword.type, nothing.type );
pickItem (inventory[5][5], room7.item, ring.itemNum , ring.type, nothing.type );
}