This is my first game. Its not really mine because its very strongly based on kirdra's ghost game. I wanted to post it tho to demonstrate how i did some things a little differently, and because i have some questions.
I want to implement monsters and random amounts taken away from "health" based on the action the user chooses, how might i go about this?
Code:
/* Steven Billington
Caverns.cpp
September 27, 2002
This is my first game ever. Its a relativley simple program
as it should be cause its newbie made. Its a console based text RPG.
Welcome to Caverns, enjoy!
*/
#include <iostream.h>
#include <stdlib.h>
#include <conio.h>
int User_Location_X = 0;
int User_Location_Y = 0;
int underwear = 0;
int DBZ = 0;
int points = 0;
int end_game = 100;
char input;
int main ()
{
//Take user input and display opening messages
char name[20];
cout <<"Please enter your first name and press enter twice: ";
cin >>name;
cout <<"Welcome to the caverns "<<name<<" . You are here because you are a non-conformist\n";
cout <<"to society. To get home you must complete a task..\n";
cout <<"This task is too find two items. These items will guide you home.\n";
cout <<"Many trials and horrors await thee..take the step into the darkness, \n";
cout <<"and find the Dragonball Z t-shirt, and my Dirty Underwear!\n";
cout <<"\n";
cout <<"You may quit at any time by entering (Q)\n";
getch(); //wait for key push and continue
do//Start loop
{
// Check user position
if (User_Location_Y == 15)
{
cout <<"You cannot continue in this direction\n";
User_Location_Y = User_Location_Y--;
getch();
}
else if (User_Location_Y == -15)
{
cout <<"You cannot continue in this direction\n";
User_Location_Y = User_Location_Y++;
getch();
}
else if (User_Location_X == 15)
{
cout <<"You cannot continue in this direction\n";
User_Location_X = User_Location_X--;
getch();
}
else if (User_Location_X == -15)
{
cout <<"You cannot continue in this direction\n";
User_Location_X = User_Location_X++;
}
//This decrements by 1 every loop, when it hits 0 game ends.
end_game = end_game--;
if (end_game == 0)
{
system("cls");
cout <<"You have used all your energy, GAME OVER!\n";
return 0;
}
//This displays every loop so user knows options
system("cls");
cout <<"North (1)\nSouth (2)\nEast (3)\nWest (4)\n\n";
cin >>input; //Store user choice
cout <<"\n";
//Does user want to quit?
if (input == 'Q' || input == 'q')
{
system("cls");
cout <<"You have chosen to exit, goodbye!\n";
return 0;
}
//Update user position
if (input == '1')
{
User_Location_Y = User_Location_Y++;
}
else if (input == '2')
{
User_Location_Y = User_Location_Y--;
}
else if (input == '3')
{
User_Location_X = User_Location_X++;
}
else if (input == '4')
{
User_Location_X = User_Location_X--;
}
if (User_Location_X == 0 && User_Location_Y == 5)
{
if (underwear == 1)
{
cout <<"You have found some more dirty underwear.\n\n";
User_Location_X = 0;
User_Location_Y = 0;
}
else if (underwear == 0)
{
cout <<"You found a pair of dirty underwear!\n\n";
underwear = 1;
points = points + 50;
User_Location_X = 0;
User_Location_Y = 0;
}
}
if (User_Location_X == 10 && User_Location_Y == 0)
{
if (DBZ == 1)
{
cout <<"You find another Dragonball Z t-shirt!\n\n";
User_Location_X = 0;
User_Location_Y = 0;
}
else if (DBZ == 0)
{
cout <<"You have aquired a Dragonball Z t-shirt, now your lost in style!\n\n";
DBZ = 1;
points = points + 50;
User_Location_X = 0;
User_Location_Y = 0;
}
}
if (points == 100)
{
cout <<"You have found both items and will now be freed!\n\n";
getch();
return 0;
}
}
while(end_game!=1);
return 0;
}