problem

This is a discussion on problem within the Game Programming forums, part of the General Programming Boards category; ok im making a very simple rpg and i need some help because it hasnt turned out the way i ...

  1. #1
    Registered User
    Join Date
    Oct 2001
    Posts
    224

    problem

    ok im making a very simple rpg and i need some help because it hasnt turned out the way i wanted it to. now to the details first off you need to have more than no brain to help me and know how to program in c++ (hopefully all of you have a brain) ok the problem is that when i start the prgram it ask for the name right but when it goes to display the map its just blank till yoiu hit a button 4 times then the map scrolls down the page rather fast and then goes blank again then yoiu need to press a button 4 times again if anyone coiuld help i thank yoiu in advanced

    the code is attached
    Attached Files Attached Files

  2. #2
    Registered User
    Join Date
    Aug 2001
    Posts
    129
    I downloaded your source and whoa!

    Last of all, it wouldn't compile (missing this, missing that, undefined symbol, etc).
    Second last of the rest you have multiple declarations of the same functions. Not that it really matters, but it kinds spoils the feeling... (?)

    Then again, there's a function called `strcpy()' which is pretty handy when you need to set an array after wards. So, instead of

    boards[9][9]='+';
    boards[0][9]='+';
    boards[9][0]='+';
    boards[5][1]='=';
    boards[5][2]='=';

    do

    strcpy(boards[0], "=++==++)

    which will set the first row of `boards' (boards[0]) to =++==++.

    Anyway, if can get a version of that file that compiles, feel free to repost.
    kooma - t.h@iki.fi

  3. #3
    monotonously living Dissata's Avatar
    Join Date
    Aug 2001
    Posts
    341
    compies fine with devC++ and visual C++

    what compiler you useing?
    if a contradiction was contradicted would that contradition contradict the origional crontradiction?

  4. #4
    Registered User
    Join Date
    Aug 2001
    Posts
    129
    bcc55. Anyway, split your source to multiple files to make it readable :-)

  5. #5
    Registered User
    Join Date
    Oct 2001
    Posts
    224
    thanks for the knowledge on the strcpy function

  6. #6
    Registered User
    Join Date
    Oct 2001
    Posts
    224
    ok i got another problem now im trying to save a file and read a file (not at the same time) but it keeps coming up with these errors

    Code:
    C:\Windows\Profiles\programming\Desktop\New Folder\text rpg my version0.0001.cpp(87) : error C2676: binary '>>' : 'class std::basic_ofstream<char,struct std::char_traits<char> >' does not define this operator or a conversion to a type acceptable to 
    the predefined operator
    C:\Windows\Profiles\programming\Desktop\New Folder\text rpg my version0.0001.cpp(125) : error C2679: binary '>>' : no operator defined which takes a right-hand operand of type 'class std::basic_string<char,struct std::char_traits<char>,class std::al
    locator<char> >' (or there is no acceptable conversion)
    C:\Windows\Profiles\programming\Desktop\New Folder\text rpg my version0.0001.cpp(125) : fatal error C1903: unable to recover from previous error(s); stopping compilation
    Error executing cl.exe.
    here is the code
    Code:
    void Save()
    										
    {										
    	ofstream fout;										
    														
    	string szLine ="";									
    	string szWord = "";									
    	string Name = Name;								
    														
    	fout.open("Stats.dat");								
    														
    	fout << "Name: "	<<Name		<<endl;				
    	fout << "Life: "	<<Life		<<endl;				
    	fout << "Maxlife: "	<<Maxlife	<<endl;
    	fout << "Money: "	<<Money		<<endl;				
        fout << "Potions: "	<<Potions	<<endl;
    	fout << "Spells: "	<<Spells	<<endl;
    	fout << "Level: "	<<Level		<<endl;
    	fout << "NLevel: "	<<NLevel	<<endl;
    	fout << "EPoints: "	<<EPoints	<<endl;
    	fout << "EOld: "	<<EOld		<<endl;
    	fout << "EGained: "	<<EGained	<<endl;
    	fout << "Power: "	<<Power		<<endl;
    	fout << "PotionP: "	<<PotionP	<<endl;
    	fout << "MagicP: "	<<MagicP	<<endl;
    														
    	fout.close();										
    }														
    
    void Open()
    {														
    	ifstream fin;										
    	string szLine = "";									
    	string szWord = "";									
    	string szName = "";									
    														
    	fin.open("Stats.txt");								
    														
    	if(fin.fail())										
    	{													
    		cout << "ERROR: Could not find Stats.txt!\n";	
    														
    		return;											
    	}													
    														
    	cout << endl;										
    
    														
    	while(fin >> szWord)								
    		cout << szWord;									
    
    	cout << endl;										
    														
    	fin.clear();										
    	fin.seekg(NULL, ios::beg);							
    														
    	while(getline(fin, szLine))							
    		cout << szLine << endl;							
    	
    	cout << endl;										
    
    	fin.clear();										
    	fin.seekg(NULL, ios::beg);							
    														
    	fin >> szWord >> Name;							
    	fin >> szWord >> Life;							
    	fin >> szWord >> Maxlife;									
    	fin >> szWord >> Money;
    	fin >> szWord >> Potions;
    	fin >> szWord >> Spells;
    	fin >> szWord >> Level; 
    	fin >> szWord >> NLevel
    	fin >> szWord >> EPoints;
    	fin >> szWord >> EOld;
    	fin >> szWord >> EGained;
    	fin >> szWord >> Power;
    	fin >> szWord >> PotionP;
    	fin >> szWord >> MagicP;
    												
    	fin.close();								.
    
    }
    thanx if you can help

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Need help understanding a problem
    By dnguyen1022 in forum C++ Programming
    Replies: 2
    Last Post: 04-29-2009, 04:21 PM
  2. Memory problem with Borland C 3.1
    By AZ1699 in forum C Programming
    Replies: 16
    Last Post: 11-16-2007, 10:22 AM
  3. Someone having same problem with Code Block?
    By ofayto in forum C++ Programming
    Replies: 1
    Last Post: 07-12-2007, 08:38 AM
  4. A question related to strcmp
    By meili100 in forum C++ Programming
    Replies: 6
    Last Post: 07-07-2007, 02:51 PM
  5. WS_POPUP, continuation of old problem
    By blurrymadness in forum Windows Programming
    Replies: 1
    Last Post: 04-20-2007, 06:54 PM

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