I am making a rpg type game. I have stored values inside of an array of class via a textfile. That's all I have done so far... What I need now and have not figured out yet is how to move from one array to the next using my "character".

class program
{
static void Main(string[] args)
        {
            
            TextReader reader = new StreamReader("H:/Visual Studio 2005/Projects/Pokemon Purple/Pokemon Purple/bin/Debug/enemies.txt");
            for (int i = 0; i < 5; i++)
            {
                location board = new location();
                board.name = reader.ReadLine();
                board.healthpoints = reader.ReadLine();
                board.attack = reader.ReadLine();
                board.defense = reader.ReadLine();
                board.poketype = reader.ReadLine();
                Console.WriteLine("{0}", board.name);
                Console.WriteLine("{0}", board.healthpoints);
                Console.WriteLine("{0}", board.attack);
                Console.WriteLine("{0}", board.defense);
                Console.WriteLine("{0}", board.poketype);
            }
            Console.ReadKey();
        }
}
public class location
    {
        public string name, poketype, healthpoints, attack, defense;
    }

Recommended Answers

All 4 Replies

Where is your array code?
You open a textfile.
For 5 times in a row :
You contruct a location class with 5 public string fields(using the default constructor)
You read in 5 strings into this board class
You print these 5 strings to the console
Then you wait for a keypress.

Sorry, I'm really new to this...
I am just trying to get a character to move from one square to the next. Each square has an enemy stored in it. For now I just want to move around the map. Which is just moving from one array to the next or back.

Don't feel sorry or whatever...
Do you understand the concept of an array?

Can't see any array in that code.
There are 5 public string variables. Looks to me like game environment settings.

Is your playing ground a path or 2 dimension area like chessboard ?
If its a path than you can use integer to store current position of a player. In case of 2 dimensions i will recommend Point() in order to keep track of current position.

Once you move your character its time to check what kind of enemy is in there.

But honestly first you need to learn about arrays and many more.
http://msdn.microsoft.com/en-us/library/aa288453(VS.71).aspx

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.