Hi guys,
I would like to take a look at this text based RPG i created. It is not even nearly completed. It is just a prototype which helps me to brush up all the things i've learned so far in C++ (im a beginner)...So please be gentle :P (RUN the program, please)
Any comments or suggestion will be highly appreciated! This is my 1st attempt to create a game.
It might be difficult ot read in the console screen so please pay careful attention
Code:///////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////// PROTOTYPE - DEMO //////////////////////////////////////////////////// ///////////////////////////// IN PROGRESS... /////////////////////////////////////////////// ///////////////////////////////////////////////// // (!)(!)So this isnt the actual game.(!)(!) // It is just a prototype from which // I am trying to learn the logic in // creating Text-Based RPG 's. It still needs A LOT of work in order // to be considered as COMPLETED // ////////////////////////////////////// #include <iostream> using namespace std; void move(int&, int&); void menu(); bool game = true; int main() { int posx = 0; int posy = 0; while (game == true) { cout << endl << endl<< "What do you like to do? "; cout << endl << "1)Move" << endl << "2)Show current position" << endl; cout << "3) Show world map " << endl; cout << "4) quit -----> Choose: "; int choice; cin >> choice; switch(choice) { case 1: move(posx, posy); break; case 2: cout << endl << "----------------------------" << endl; cout << endl << "Current position: ("<< posx << "," << posy <<")"; cout << endl << "----------------------------" << endl; break; case 3: cout << endl << "=== WORLD-MAP===" << endl; cout << endl << "Castle (2,1) " << endl; cout << endl <<"=====================" << endl; break; case 4: game = false; break; } } // while loop BOOL cout << endl << endl << "Game Over" ; } // int main() /////////////////////////////////////// // // This function moves the character // ////////////////////////////////////// void move(int &posx, int &posy) { cout << "------------------------------------------" << endl; cout << endl << "HELP: Every time you move, you move" << endl; cout << "1point either North, South, East, West " << endl; cout << "For example, if you choose 'North' then your position " << endl; cout << "from (0,0) will be (0,1) ----> ( x-coordinate , y-coordinate) "<< endl; cout << endl << "Where to move?"; cout << endl<< "1)North 2)South 3)East"; int choice; cin >> choice; if (choice == 1) posy +=1; // move 1 point UP (y) else if (choice==2) posy -=1; else if (choice==3) posx+=1; //move 1 point RIGHT (x) //test if((posx == 2) && (posy==1)) { cout <<endl << "You reached the castle!"; //test menu(); } } //////////////////////////////////////////////////////////////////////////////////////////////////////////// // This function appears when you reach the castle. // It shows you a menu and asks you whether you want to enter search or leave // If you "search" then the do-while loop will repeat the menu // if you "leave" then it gets out of the function //////////////////////////////////////////////////////////////////////////////////////////////////////////// void menu() { int choice; do{ cout << endl << "1)Enter 2)Search 3) Quit"; cin >> choice; switch(choice) { case 1: cout << endl << "You entered the castle" << endl; // "show castle Menu"; // ..to be continued cout << "I'll end the game HERE cause i didnt finished it yet..." << endl; game=false; break; case 2: cout <<endl << endl << "Theres nothing here to search" << endl; break; case 3: game = false; } // switch }while(choice == 2); }



LinkBack URL
About LinkBacks



) 