C++: Writing game program...Rogue-Like?

This is a discussion on C++: Writing game program...Rogue-Like? within the C++ Programming forums, part of the General Programming Boards category; I'm writing a rogue like game for my cs class. Everything is running fine but I need to import the ...

  1. #1
    Registered User
    Join Date
    Nov 2012
    Posts
    9

    Question C++: Writing game program...Rogue-Like? Import x,y Cords

    I'm writing a rogue like game for my cs class. Everything is running fine but I need to import the walls for the game. The coordinates for the walls are in 3 text files. How do I inport it to the correct position on screen.
    This is the code i'm using but it isn't printing right on the screen.
    Can you look over? Thank you!

    Code:
    bool loadData( int coordinates[MAX_ARRAY][MAX_ARRAY], int fileIndex, int &arraySize )
    {
    char fileOne[] = "lowlevel.txt";
    char fileTwo[] = "midlevel.txt";
    char fileThree[] = "highlevel.txt";
    ifstream fin;
    
    if ( fileIndex == 1 )
        {
          fin.clear();
          fin.open( fileOne );
        }
    
    else if( fileIndex == 2 )
        {
          fin.clear();
          fin.open( fileTwo );
        }
    
    else if( fileIndex == 3)
       {
          fin.clear();
          fin.open( fileThree );
       }
    
    else
        return false;
    
    
    while ( fin.good() && arraySize < 100 )
         {
           fin >> coordinates[arraySize][arraySize];
           arraySize++;
    
           fin >> coordinates[arraySize][arraySize];
          arraySize++;
    
         }
        fin.close();
    
    
    return true;
    }

    Last edited by rvbplayer123; 12-06-2012 at 09:33 AM.

  2. #2
    Bored Programmer
    Join Date
    Jul 2009
    Location
    Tomball, TX
    Posts
    407
    Hey,

    The way you are navigating through your array looks linear. Like you are saving data in a straight line such as on a graph would be y = x.

    It looks like you are only saving into positions that would satisfy the equaion Y = X. So points (0, 0), (1, 1), (2, 2) ect. If it is a array that is 100, by 100 then you have 1000 possible positions but you are writing to only 100 of them.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 3
    Last Post: 05-16-2011, 09:33 AM
  2. Rogue Dao Studios is looking for 1-2 C# programmers
    By roguedaostudios in forum Projects and Job Recruitment
    Replies: 2
    Last Post: 08-10-2010, 09:33 PM
  3. Rogue Wave __rwstd::__rw_stdexcept_nonamedexception
    By mtronix in forum C++ Programming
    Replies: 1
    Last Post: 09-10-2007, 09:05 AM
  4. Rogue Leader
    By Scourfish in forum A Brief History of Cprogramming.com
    Replies: 5
    Last Post: 11-15-2001, 11:51 AM
  5. rogue spear fans only..
    By abhiboy007 in forum A Brief History of Cprogramming.com
    Replies: 7
    Last Post: 09-16-2001, 10:42 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21