MY C++ Text based game :P
Sgt. Rho 06 Apr 2008
First, a thanks goes to codecat and warbz for helping indirectly
Well, you can choose between 3 difficulty levels ,and have to kill a monster which, depending oon the difficulty level, has 100, 200 or 300 HP.
Works perfectly fine^^
Whoops...that was the old code, updated.
Edited by Master_Chief, 06 April 2008 - 10:36.
Well, you can choose between 3 difficulty levels ,and have to kill a monster which, depending oon the difficulty level, has 100, 200 or 300 HP.
Works perfectly fine^^
#include <iostream> #include <conio.h> #include <windows.h> #include <ctime> #include <string> using namespace std; int UserChoice; int BeastDamage; string Player; int Difficulty; int main () { cout << "Hallo. \n Wie heisst du? \n"; cin >> Player; cout << "\n Waehle bitte einen schwierigkeits grad \n"; cout << "1 fuer Leicht (Gegner hat 100 Lebenspunkte) \n 2 fuer Mittel (Gegner hat 200 Lebenspunkte) \n 3 fuer Schwer (Gegner hat 300 Lebenspunkte) \n"; cin >> Difficulty; getch(); if ( !(cin >> Difficulty) || (Difficulty != 1 && Difficulty != 2 && Difficulty != 3)) { cin.clear(); cin.ignore(numeric_limits<streamsize>::max(), '\n'); cout << "Bitte 1 fuer Leicht, 2 fuer Mittel, oder 3 fuer Schwer eingeben! \n"; } int InitHealth = 100; int BeastHealth = 100 * Difficulty; while (BeastHealth > 0 && (Difficulty == 1 || Difficulty == 2 || Difficulty == 3 )) { cout << "Du wirst von einem Monster angegriffen! \n"; cout << "Was wirst du tun? Gib 1 ein um anzugreifen oder 2 um dich zu heilen \n"; cin >> UserChoice; cout << "Du hast " << InitHealth << " Lebenspunkte \n"; getch(); switch(UserChoice) { case 1: { int DamageDone = rand()%30; cout << "Du hast dem Monster " << DamageDone << " Lebenspunkte Abgezogen \n"; BeastHealth = BeastHealth - DamageDone; if (BeastHealth < 30) { int BeastHealed = rand()%30; BeastHealth = BeastHealth + BeastHealed; cout << "Das monster hat " << BeastHealed << " Regeneriert! \n"; } else if (BeastHealth > 30) { BeastDamage = rand()%25; InitHealth = InitHealth - BeastDamage; cout << "Das monster hat dir " << BeastDamage << " Lebenspunkte abgezogen! \n Du hast noch " << InitHealth << " Lebenspunkte \n"; } cout << "Das Monster hat noch " << BeastHealth << " Lebenspunkte \n"; if (BeastHealth < 1) { cout << "Gute arbeit, du hast Gewonnen!"; } else if (InitHealth < 1) { cout << "Das Monster hat dich getötet!"; } } break; case 2: { int Healed = rand()%30; if (BeastHealth < 30) { int BeastHealed = rand()%30; BeastHealth = BeastHealth + BeastHealed; cout << "Das monster hat " << BeastHealed << " Regeneriert! \n"; } else if (BeastHealth > 30) { BeastDamage = rand()%25; InitHealth = InitHealth - BeastDamage; cout << "Das monster hat dir " << BeastDamage << " Lebenspunkte abgezogen! \n Du hast noch " << InitHealth << " Lebenspunkte \n"; } InitHealth = InitHealth + Healed; cout << "Du hast " << Healed << " Lebenspunkter regeneriert. Du hast nun " << InitHealth << " Lebenspunkte \n \n"; } if (BeastHealth < 1) { cout << "Gute arbeit, du hast Gewonnen!"; } else if (InitHealth < 1) { cout << "Das Monster hat dich getötet!"; } if ( !(cin >> UserChoice) || (UserChoice != 1 && UserChoice != 2)) { cin.clear(); cin.ignore(numeric_limits<streamsize>::max(), '\n'); cout << "Bitte 1 zum Angreifen oder 2 zum Heilen eingeben! \n"; } } } getch(); return 0; }
Whoops...that was the old code, updated.
Attached File(s)
-
monsterj_ger_2.0.rar (104.67K)
Number of downloads: 4
Edited by Master_Chief, 06 April 2008 - 10:36.
Warbz 06 Apr 2008
Looks alright but I can't read what I assume is German?
Theres no point having it available for download as its easier just to copy and paste the code if anyone is going to try it.
Theres no point having it available for download as its easier just to copy and paste the code if anyone is going to try it.
Warbz 06 Apr 2008
Yeh, It don't help that all the outputs are in German.
EDIT: And I just noticed all the variables are in English. Master_Chief you trying to see how many languages you can use at once or something? lol
Edited by Warbz, 06 April 2008 - 13:05.
EDIT: And I just noticed all the variables are in English. Master_Chief you trying to see how many languages you can use at once or something? lol
Edited by Warbz, 06 April 2008 - 13:05.
Warbz 06 Apr 2008
Nah, Try and work some Spanish words in there too.
You'll then have 4 languages in it.
German
English
Spanish
and of course C++.
lmao
EDIT: Maybe even put some morse code in it!
Edited by Warbz, 06 April 2008 - 13:09.
You'll then have 4 languages in it.
German
English
Spanish
and of course C++.
lmao
EDIT: Maybe even put some morse code in it!
Edited by Warbz, 06 April 2008 - 13:09.
Sgt. Rho 06 Apr 2008
#include <iostream> #include <conio.h> #include <windows.h> #include <ctime> #include <string> using namespace std; int UserChoice; int BeastDamage; string Player; int Difficulty; int main () { cout << "Hello. \n Who are you? \n"; cin >> Player; cout << "\n Please select a difficulty level \n"; cout << "Enter 1 for easy, 2 for medium or 3 for hard difficulty level \n"; cin >> Difficulty; getch(); if ( !(cin >> Difficulty) || (Difficulty != 1 && Difficulty != 2 && Difficulty != 3)) { cin.clear(); cin.ignore(numeric_limits<streamsize>::max(), '\n'); cout << "Enter 1 for easy, 2 for medium or 3 for hard difficulty level \n"; } int InitHealth = 100; int BeastHealth = 100 * Difficulty; while (BeastHealth > 0 && (Difficulty == 1 || Difficulty == 2 || Difficulty == 3 )) { cout << "A Beast is attacking you! \n"; cout << "What are you gonna do? Press 1 to attack or 2 to heal! \n"; cin >> UserChoice; cout << "You have " << InitHealth << " Hit Points. \n"; getch(); switch(UserChoice) { case 1: { int DamageDone = rand()%30; cout << "You have damaged the enemy for " << DamageDone << " Hit Points \n"; BeastHealth = BeastHealth - DamageDone; if (BeastHealth < 30) { int BeastHealed = rand()%30; BeastHealth = BeastHealth + BeastHealed; cout << "The Beast has recovered " << BeastHealed << " Hit Points! \n"; } else if (BeastHealth > 30) { BeastDamage = rand()%25; InitHealth = InitHealth - BeastDamage; cout << "The Hostile beeing has damaged you for " << BeastDamage << " HP! \n You still have " << InitHealth << " Hit Points \n"; } cout << "The Monster has " << BeastHealth << " HP Remaining \n"; if (BeastHealth < 1) { cout << "Great job, you have defeated the beast! "; } else if (InitHealth < 1) { cout << "You are Defeated"; } } break; case 2: { int Healed = rand()%30; if (BeastHealth < 30) { int BeastHealed = rand()%30; BeastHealth = BeastHealth + BeastHealed; cout << "The Beast has recovered " << BeastHealed << " Hit Points! \n"; } else if (BeastHealth > 30) { BeastDamage = rand()%25; InitHealth = InitHealth - BeastDamage; cout << "The Hostile beeing has damaged you for " << BeastDamage << " HP! \n You still have " << InitHealth << " Hit Points \n"; } InitHealth = InitHealth + Healed; cout << "You did recover " << Healed << " Health Points. \n You have now " << InitHealth << " Health Points \n \n"; } if (BeastHealth < 1) { cout << "Great job, you have defeated the beast!"; } else if (InitHealth < 1) { cout << "You are Defeated!"; } if ( !(cin >> UserChoice) || (UserChoice != 1 && UserChoice != 2)) { cin.clear(); cin.ignore(numeric_limits<streamsize>::max(), '\n'); cout << "Enter either 1 to attack or 2 to heal! \n"; } } } getch(); return 0; }
Attached File(s)
-
monsterkiller_2.0.rar (104.67K)
Number of downloads: 3
Warbz 06 Apr 2008
Right,
1) I think the way the information is displayed to the player is pretty bad.
2)I have -11 health and am still attacking the enemy.
1) I think the way the information is displayed to the player is pretty bad.
2)I have -11 health and am still attacking the enemy.
Sgt. Rho 06 Apr 2008
what? Hmm...I guess I made an error there >.<
EDIT: Fix0rt
Edited by Master_Chief, 06 April 2008 - 14:10.
EDIT: Fix0rt
Attached File(s)
-
monsterkiller_2.0.rar (104.67K)
Number of downloads: 7
Edited by Master_Chief, 06 April 2008 - 14:10.
Reaper94 06 Apr 2008
Warbz 06 Apr 2008
IF you don't know that, then unless you actually want to properly learn the C++ language, theres no point explaining it to you, just use the .exe provided.