I'm making a little text game. The starting dialogue is in my main (static) method. From there, it sends you to other methods depending on your choices.
Now I think I need to have an instance of my class for this to work.
For example:
Program p = new Program();
if(stuff){
p.room1();
}
else{
p.room2();
}
Within those other methods there are global variables that will change.
So above the main method there is:
public bool hasItem = false;
So room1() would look like,
public void room1(){
if(stuff){
p.hasItem = true;
}
}
I know I'm screwing something up with the main method. Do I declare the instance "p" inside or outside of the main method? I've tried both but get errors both ways.
Edit: I ended up declaring a static "Program" outside of the main method to use elsewhere. Thanks for the help!
hasItem? I would suggest you declare it as a member variable of the object that represents the thing (room, world, player, whatever) that actually has the item.