Hey all,
im quite new to Java but i'm trying to create a text based adventure game. Where as you control a main character and pick up items along the way in order to finish the game.
The main plot would be the character moves from room to room, picking up items which unlock "abilities" allowing you to enter the next room.
eg. picking up a key to open a locked door.
mind you this is a text based game...
I'm almost finished a version 1 of the game and Currently the player starts with an inventory allowing them to carry 6 items, but i am wanting them to be able to pick up a BAG
which enables the inventory to increase to 8, allowing them to pick up more items before game can be finished.
My coding is as follows:
int MAX_ITEMS = 6
public void pickUp(Item item, Location location)
{
if(youHave(item))
{
System.out.println("You already have the " + item + "!");
}
else if(!location.isHere(item))
{
System.out.println("There is no " + item + " here!");
}
else if(numItems < MAX_ITEMS)
{
location.removeItem(item);
hasItem[item.ordinal()] = true;
numItems++;
System.out.println("ok");
}
else
{
System.out.println("You can't carry any more!");
}
How am i able to code to increase MAX ITEMS when i pick up the BAG
Thank you. if you want to see more of the code i can post, was just hard putting it all in this initial post