HELP 2D rpg game
popa6200 (2)
Jan 6, 2013 at 11:22pm UTC
i'm kind new in c++,and i`m making a rpg game.
the compiler is Dev-C++.
here is my code:
#include <cstdlib>
#include <iostream>
#include <windows.h>
#include <winable.h>
using namespace std;
int main(int argc, char *argv[])
{
double c (1);
string f;
double fieldc (0);
int t (1);
string pl;
string j;
string s;
cout << " one-a-world \n";
cout << "1.start\n";
cout << "2.exit\n";
getline(cin, s);
if(s == "1"){
cout << "what is your job: farmer/baker\n";
getline(cin, j);}
if(j == "farmer"){
start:
//hoe val{10, 1};
#define hoe (10,1); //seeds val {1, 2,};
cout << " feild=1, 2=home\n";
cin >> pl;
if(pl == "1"){goto f; }
else { goto ho; }
f:
cout << "p=plant seeds 1=outer part of vill 2=spawn\n";
getline(cin, pl);
if(pl == "p"){f =(c + fieldc);
goto f;}
if(pl == "2"){goto start;}
}
}
}
if(s == "2"){
system("cls");
cout << "press any key to exit.\n";
system("PAUSE >nul");
return EXIT_SUCCESS;}
}
the errors that I get are:
passing `double' for converting 1 of `std::basic_string<_CharT, _Traits, _Alloc>& std::basic_string<_CharT, _Traits, _Alloc>::operator=(_CharT) [with _CharT = char, _Traits = std::char_traits<char>, _Alloc = std::allocator<char>]'
expected unqualified-id before "if"
expected `,' or `;' before "if"
expected declaration before '}' token
SamuelAdams (319)
Jan 7, 2013 at 6:16pm UTC
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
#include <cstdlib>
#include <iostream>
#include <windows.h>
#include <winable.h>
using namespace std;
int main(int argc, char *argv[])
{
double c (1);
string f;
double fieldc (0);
int t (1);
string pl;
string j;
string s;
cout << " one-a-world \n" ;
cout << "1.start\n" ;
cout << "2.exit\n" ;
getline(cin, s);
if (s == "1" ){
cout << "what is your job: farmer/baker\n" ;
getline(cin, j);}
if (j == "farmer" )
{
start:
//hoe val{10, 1};
#define hoe (10,1); //seeds val {1, 2,};
cout << " feild=1, 2=home\n" ;
cin >> pl;
if (pl == "1" ){goto f; }
//else { goto ho; }
f:
cout << "p=plant seeds 1=outer part of vill 2=spawn\n" ;
getline(cin, pl);
if (pl == "p" ){f =(c + fieldc);
goto f;}
if (pl == "2" ){goto start;}
//}
//}
}
if (s == "2" )
{
system("cls" );
cout << "press any key to exit.\n" ;
system("PAUSE >nul" );
return EXIT_SUCCESS;
}
}
mathacka (1)
Jan 7, 2013 at 10:53pm UTC
this is the bast I could come up with using functions, I didn't understand where the code was completely going.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
#include <cstdlib>
#include <iostream>
#include <windows.h>
#include <winable.h>
using namespace std;
void fnPlant();
void fnStart();
void fnHome();
int main(int argc, char *argv[])
{
int t = 1;
double c = 1;
double fieldc = 0;
string strPlace, strJob, strAnswer;
cout << "one-a-world \n" ;
cout << "1.start\n" ;
cout << "2.exit\n" ;
getline(cin, strAnswer);
if (strAnswer == "1" ) {
cout << "what is your job: farmer/baker\n" ;
getline(cin, strJob);
}
if (strJob == "farmer" ) {
cout << " 1=field, 2=home\n" ;
cin >> strPlace;
if (strPlace == "1" ) {
fnPlant();
}
else {
fnHo();
}
if (strPlace == "2" ) {
system("cls" );
cout << "press any key to exit.\n" ;
system("PAUSE >nul" );
return EXIT_SUCCESS;
}
return EXIT_SUCCESS;
}
void fnStart()
{
string strPlant = "" ;
cout << " feild=1, 2=home\n" ;
cin >> strPlant;
if (strPlant == "1" )
{
fnPlant();
}
else
{
fnHome();
}
}
void fnPlant()
{
string strPlant = "" ;
cout << "Plant seeds where? 1=[outer part of vill] 2=[spawn]\n" ;
getline(cin, strPlant);
if (strPlant == "1" )
{
f =(c + fieldc);
}
if (strPlant == "2" )
{
fnStart();
}
}
void fnHome()
{
}
By the way, you're including windows headers, I probably would just stick to console programming until you're better at coding.