Code:
/* Main File for Wizadora
Written by Peter Watts
DO NOT EDIT OR DELETE THIS CODE!!!*/
#include <iostream>
#include <string>
#include <stdlib.h>
#include <cctype> // files used
#include <windows.h>
#include <algorithm>
#include <conio.h>
using namespace std; // for cout and endl;
void AltEnter(); // TO QUIT GAME HOLD CONTROL THEN PRESS C //
void intro();
void level1();
void plea();
void wizavillage();
void signpost(); // functions are delcared
void magicshop();
void oldchurch();
void creepywoods();
void woodenhut();
void endingANDcredits();
extern void gameover();
extern void stats();
extern void magics(); // external functions to call when needed
extern void spells();
/* Player Varibles*/
string pname; // player name
int health = 100; // player health;
int MAXhealth = 500; // player maximum health
int MINhealth = 1; // player minimum health
int gold = 0; // gold player has gathered
int Exp = 0; // experience gained
int powers = 0; // number of magic spells learned
string spellname; // string fof spell name
int level = 1; // player level
int items = 0; // items found
/* Enemy Varibles*/
string enemyname; // string for enemy name
int ehealth; // enemy health
int edamage; // enemy damage
int elevel; // enemy level;
bool edead; // booleen varible to decide is enemy defeated or active
bool ealive; // ""
/* Misc Vsribles*/
int size;
int x; // special varibles used in text scroll
char attack; // used in battle
char choice; // used in selection
char magic; // used in magic
int main(int argc, char *argv[])
{
SetConsoleTitle("W I Z A D O R A - BY PETER WATTS -"); // console Title
AltEnter();
intro();
level1();
plea();
wizavillage();
signpost(); // Set functions to MAIN()
magicshop();
oldchurch();
creepywoods();
woodenhut();
endingANDcredits();
if(health<=0) gameover(); // call gameover FROM main
if(powers=+1) spells(); // call spells FROM main
return 0;
} // end main
void AltEnter() // call keyboard events
{
keybd_event(VK_MENU, 0x38, 0, 0);
keybd_event(VK_RETURN, 0x1c, 0, 0);
keybd_event(VK_RETURN, 0x1c, KEYEVENTF_KEYUP, 0); // this brill function makes the
keybd_event(VK_MENU, 0x38, KEYEVENTF_KEYUP, 0); // console window fill the screen
intro(); // just like in a real time game!!
return;
}
void intro()
{
HANDLE h = GetStdHandle ( STD_OUTPUT_HANDLE );
WORD wOldColorAttrs;
CONSOLE_SCREEN_BUFFER_INFO csbiInfo;
/*
* First save the current color information
*/
GetConsoleScreenBufferInfo(h, &csbiInfo);
wOldColorAttrs = csbiInfo.wAttributes;
/*
* Set the new color information
*/
SetConsoleTextAttribute ( h, FOREGROUND_GREEN | FOREGROUND_INTENSITY );
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_RED| FOREGROUND_GREEN | FOREGROUND_INTENSITY );
cout << "\n\n";
cout <<"\t\t=============================================\n";
printf("\t\t# # # ##### #### #### #### #### ####\n"
"\t\t# # # # # # # # # # # # # #\n"
"\t\t# # # # # # # # # # #### # #\n"
"\t\t# # # # # #### # # # # # # ####\n"
"\t\t# # # # # # # # # # # # # # #\n"
"\t\t##### # ##### # # #### #### # # # #\n"
"\t\t=============================================\n"
"\t\t| | \n"
"\t\t| Press P to Play A New Game | \n"
"\t\t| | \n"
"\t\t| Press L to Load A Saved Game | \n"
"\t\t| | \n"
"\t\t| Press Q to Quit the Game | \n"
"\t\t--------------------------------------------- \n");
cout << "\n\n";
cout << "\tSelection >";
cin >> choice;
if (choice == 'l')
{
HANDLE h = GetStdHandle ( STD_OUTPUT_HANDLE );
WORD wOldColorAttrs;
CONSOLE_SCREEN_BUFFER_INFO csbiInfo;
/*
* First save the current color information
*/
GetConsoleScreenBufferInfo(h, &csbiInfo);
wOldColorAttrs = csbiInfo.wAttributes;
/*
* Set the new color information
*/
SetConsoleTextAttribute ( h, FOREGROUND_RED|FOREGROUND_INTENSITY );
system("cls");
printf("The load feature is not yet avalible...");
Sleep(2000);
system("cls");
intro();
}
else if (choice == 'q')
{
system("cls");
HANDLE h = GetStdHandle ( STD_OUTPUT_HANDLE );
WORD wOldColorAttrs;
CONSOLE_SCREEN_BUFFER_INFO csbiInfo;
/*
* First save the current color information
*/
GetConsoleScreenBufferInfo(h, &csbiInfo);
wOldColorAttrs = csbiInfo.wAttributes;
/*
* Set the new color information
*/
SetConsoleTextAttribute ( h, FOREGROUND_BLUE|FOREGROUND_INTENSITY );
printf("Goodbye then, please come back to save the kingdom soon...\n");
Sleep(3000);
exit(0);
}
else if (choice == 'p')
{
system("cls");
SetConsoleTextAttribute ( h, wOldColorAttrs);
cin.ignore();
level1();
}
else {
system("cls");
printf("You must enter one of the three commands!\n");
Sleep(2000);
system("cls");
intro();
}
} // end intro
void level1()
{
system("cls");
char senta[]="Hail adventurer!\nDo you seek glory, fame, fortune\nand even gold?\n"
"Then I welcome you to my land of magic and fantasy...\nI am Wizadora\n"
"and I need your help....\n";
size=strlen(senta);
for(x=0;x<size;x++)
{
Sleep(40);
printf("%c",senta[x]);
}
Sleep(2000);
system("cls");
char sentb[]="But before you can start, I need to know your name.\nAs I cannot keep\n"
"calling you adventurer now can I?\n"
"\n\n"
"My name is: ";
size=strlen(sentb);
for(x=0;x<size;x++)
{
Sleep(40);
printf("%c",sentb[x]);
}
getline ( cin, pname );
char sentc[]="\n\n"
"So, your name is ";
size=strlen(sentc);
for(x=0;x<size;x++)
{
Sleep(40);
printf("%c",sentc[x]);
}
cout<<""<< pname <<""<<endl;
char sentd[]="Thats is a nice name!\nI hope we can get on well together...\n"
"Would you like to hear my story of why I have come to ask for your\n"
"aid ";
size=strlen(sentd);
for(x=0;x<size;x++)
{
Sleep(40);
printf("%c",sentd[x]);
}
cout<<""<< pname <<"?"<<endl;
printf("\n\n"
"Press Y to hear her plea or N to continue anyway\n"
"\n\n");
cout << "Will you? ";
cin >> choice;
if (choice == 'n')
{
system("cls");
wizavillage();
}
else if (choice == 'y')
{
system("cls");
plea();
}
else {
printf("\n\n"
"You must enter yes or no...");
Sleep(2000);
level1(); // loop back to start of game to make sure question is aswered
}
} // end of level1
void plea()
{
HANDLE h = GetStdHandle ( STD_OUTPUT_HANDLE );
WORD wOldColorAttrs;
CONSOLE_SCREEN_BUFFER_INFO csbiInfo;
/*
* First save the current color information
*/
GetConsoleScreenBufferInfo(h, &csbiInfo);
wOldColorAttrs = csbiInfo.wAttributes;
/*
* Set the new color information
*/
SetConsoleTextAttribute ( h, FOREGROUND_GREEN|FOREGROUND_INTENSITY );
system("cls");
char sentmp[]="The land of Wiza, which is basicly a land of child fantasy\n"
"has always been a peaceful land, where young trainee wizards\n"
"and witches roam, and practice their magic in the hope that\n"
"one day, they can use it to help bring peace to the world...\n"
"\n\n";
size=strlen(sentmp);
for(x=0;x<size;x++)
{
Sleep(40);
printf("%c",sentmp[x]);
}
Sleep(2000);
system("cls");
char sentmpa[]="But one day, the evil witch DRUCILA cast an evil spell\n"
"on all the people who live in Wiza.\n"
"Her plan is to make all the people her slaves, so she can\n"
"have enough power to conquer the WHITE WILLOW, which is the\n"
"source of all our powers, and turn it evil...\n"
"\n\n";
size=strlen(sentmpa);
for(x=0;x<size;x++)
{
Sleep(40);
printf("%c",sentmpa[x]);
}
Sleep(2000);
system("cls");
char sentmpb[]="But hope is not lost....\n"
"\n\n"
"I have been instructed by the WHITE WILLOW to challenge\n"
"DRUCIA and break her spell that she has over us.\n"
"I am all but an amatuer witch at the moment, that is why\n"
"I need your help to battle the monsters that DRUCILA has\n"
"crafted into Wiza...\n"
"I know if we work as a team, we can defeat DRUCILA and restore\n"
"peice to Wiza!\n"
"\n\n";
size=strlen(sentmpb);
for(x=0;x<size;x++)
{
Sleep(40);
printf("%c",sentmpb[x]);
}
Sleep(2000);
system("cls");
SetConsoleTextAttribute ( h, wOldColorAttrs);
wizavillage();
} // end of plea
void wizavillage()
{
char sente[]="\tWIZA VILLAGE\n"
"\n\n"
"Welcome to my village.... Hmm, I guess it would be a good\n"
"Idea to stock up on magic or supplies before we venture into\n"
"The woods ahead, Ok then, were to first ";
size=strlen(sente);
for(x=0;x<size;x++)
{
Sleep(40);
printf("%c",sente[x]);
}
cout<<""<< pname <<"?"<<endl;
Sleep(2000);
system("cls");
signpost();
} // end function WizaVillage()
void signpost()
{
system("cls");
char sentf[]="Please Select a destination then hit ENTER\n"
"\n\n"
"Magic Shop == Press M\n"
"\n\n"
"Go to Wiza Woods == Press W\n"
"\n\n"
"Old Church == Press C\n"
"\n\n"
"View Stats == Press S\n"
"\n\n";
size=strlen(sentf);
for(x=0;x<size;x++)
{
Sleep(40);
printf("%c",sentf[x]);
}
cout << "\tSelection: ";
cin >> choice;
if (choice == 's')
{
stats(); // call STATS()
return signpost(); // return to this point after system("pause")
}
else if (choice == 'w')
{
system("cls");
creepywoods();
}
else if (choice == 'm')
{
system("cls");
magicshop();
}
else if (choice == 'c')
{
system("cls");
oldchurch();
}
else {
system("cls");
signpost();
}
} // end signpost
int purchase; // varible used to shop
void magicshop()
{
system("cls");
if (items <=0)
{
system("cls");
char sentmsl[]="It appears that the magic shop is locked, Maybe we need a key\n"
"I am sure there is one somwhere....\n";
size=strlen(sentmsl);
for(x=0;x<size;x++)
{
Sleep(40);
printf("%c",sentmsl[x]);
}
Sleep(2000);
system("cls");
signpost();
}
else if (items == 1)
{
items=items-1; // lose key from stats
system("cls");
char sentmso[]="\t\tM A G I C S H O P\n"
"\n\n"
"A cheery looking woman looks at you from behind the counter.\n"
"She seems a little young to be running a magic shop,\n"
"but you do not let this bother you as you aproach her.\n"
"\n\n";
size=strlen(sentmso);
for(x=0;x<size;x++)
{
Sleep(40);
printf("%c",sentmso[x]);
}
Sleep(2000);
system("cls");
cout<<""<< pname <<""<<endl;
char sentta[]="\n\n"
"Erm, hello there....\n"
"I am traveling on an adventure to save the kingdom from Drucila's\n"
"evil spell, and Wizadora and myself would like to purchase some\n"
"magical supplies if that is ok....\n"
"\n\n";
size=strlen(sentta);
for(x=0;x<size;x++)
{
Sleep(40);
printf("%c",sentta[x]);
}
Sleep(1000);
printf("ASSISTANT:");
char senttb[]="\n\n"
"Of course you can!\n"
"Providing you have the correct gold on you.\n"
"Here is a list of what I sell, and how much gold it will cost...\n"
"\n\n"
"NAME OF ITEM ------ COST ------ TO PURCHASE\n"
"\n\n"
"Complete Heal 20 gold Press 1\n"
"\n\n"
"Magical Mushrooms 10 gold Press 2\n"
"\n\n"
"Stone of Wonder 50 gold Press 3\n"
"\n\n"
"Invisibilty Cloak 100 gold Press 4\n"
"\n\n"
"TO QUIT SHOPPING PRESS 5\n"
"\n\n";
size=strlen(senttb);
for(x=0;x<size;x++)
{
Sleep(40);
printf("%c",senttb[x]);
}
cout << "\tWhat will it be? ";
cin >> purchase;
}
switch (purchase) { // I use a switch loop here as it is easier to control
case 1:
if (gold <=19)
{
system("cls");
printf("You cannot afford that Item yet!");
Sleep(2000);
system("cls");
magicshop();
}
else if (gold >=20)
{
gold=gold-20;
powers=+1;
system("cls");
printf("You have got a new spell!");
Sleep(2000);
system("cls");
magicshop();
}
else {
system("cls"); // ELSE is used as a catch fall to avoid errors
magicshop();
}
break;
case 2:
if (gold <=9)
{
system("cls");
printf("You cannot afford this yet!");
Sleep(2000);
system("cls");
magicshop();
}
else if (gold >=10)
{
items=+1;
gold=gold-10;
system("cls");
printf("You have gained a new item: MAGIC MUSHROOMS!! (maybe sombody could\n"
"cook them...)");
Sleep(2000);
system("cls");
magicshop();
}
else {
system("cls"); // ELSE is used as a catch fall to avoid errors
magicshop();
}
break;
case 3:
if (gold <=49)
{
system("cls");
printf("Sorry, not enough gold...");
Sleep(2000);
system("cls");
magicshop();
}
else if (gold >=50)
{
items=+1;
gold=gold-50;
system("cls");
printf("You have found the Stone of Wonder!!! What a glowing delight!");
Sleep(2000);
system("cls");
magicshop();
}
else {
system("cls"); // ELSE is used as a catch fall to avoid errors
magicshop();
}
break;
case 4:
if (gold <=99)
{
system("cls");
printf("This does not come cheap, I can't sell it you for less than it states...");
Sleep(2000);
system("cls");
magicshop();
}
else if (gold >=100)
{
items=+1;
gold=gold-100;
system("cls");
printf("Hey, BIG spender! You have aquired the invisabilty cloak!");
Sleep(2000);
system("cls");
magicshop();
}
else {
system("cls"); // ELSE is used as a catch fall to avoid errors
magicshop();
}
break;
case 5: // if player wants no items then exit to previous function
system("cls");
printf("Please come back and shop again soon...");
Sleep(2000);
system("cls");
signpost();
break;
default: // makes sure questions are answered correctly
system("cls");
printf("Please choose from 1 to 5 ...");
Sleep(2000);
system("cls");
magicshop();
break;
} // end switch loop
} // end magicshop
void oldchurch()
{
} // end oldchurch
void creepywoods()
{
system("cls");
char sentg[]="\t\tTHE CREEPY WOODS.....\n"
"\n\n"
"You enter the creepy woods....\n"
"As you venture forward, you hear a rustling sound behind you...\n"
"You turn around and ..... \n"
"\n\n";
size=strlen(sentg);
for(x=0;x<size;x++)
{
Sleep(40);
printf("%c",sentg[x]);
}
Sleep(2000);
system("cls");
char senth[]="An old woman is suddenly walking towards you....\n"
"She seems friendly enough, so you try to engage in some light\n"
"convasation with her...\n";
size=strlen(senth);
for(x=0;x<size;x++)
{
Sleep(40);
printf("%c",senth[x]);
}
Sleep(2000);
system("cls");
cout<<""<< pname <<""<<endl;
char senttc[]="\n\n"
"Hi there, can you help me and Wizdora through the forest,\n"
"Or at least the location of a safe passage out?\n"
"\n\n";
size=strlen(senttc);
for(x=0;x<size;x++)
{
Sleep(40);
printf("%c",senttc[x]);
}
printf("OLD WOMAN:");
char senttd[]="\n\n"
"Yes, I do know a safe passage out, and I would advise against\n"
"not taking my advise. But, my advise does not come cheap...\n"
"\n\n"
"Do you have any EXPERIENCE in anything yet?\n"
"\n\n"
"If you do, I will help you progress further....\n"
"\n\n";
size=strlen(senttd);
for(x=0;x<size;x++)
{
Sleep(40);
printf("%c",senttd[x]);
}
printf("WIZADORA:");
char sentte[]="\n\n"
"Do we have any Experience yet ";
size=strlen(sentte);
for(x=0;x<size;x++)
{
Sleep(40);
printf("%c",sentte[x]);
}
cout<<""<< pname <<""<<endl;
printf("\n\n"
"If you have experience Press Y, if you do not then Press N...");
cout << "\n\n";
cout << "Do you? ";
cin >> choice;
if ((choice == 'y') && (Exp == 1))
{
system("cls");
cout<<""<< pname <<""<<endl;
char senttf[]="\n\n"
"Yes, I do have Experience, Here is the proof....\n"
"Now Please help us on our travels...\n"
"\n\n";
size=strlen(senttf);
for(x=0;x<size;x++)
{
Sleep(40);
printf("%c",senttf[x]);
}
printf("OLD WOMAN:");
char senttg[]="\n\n"
"Oh yes, so you do.. Follow me....\n"
"\n\n";
size=strlen(senttg);
for(x=0;x<size;x++)
{
Sleep(40);
printf("%c",senttg[x]);
}
Sleep(1000);
char senti[]="The old woman shows you a way through to woods, and you soon\n"
"come across an old wooden hut...\n"
"\n\n";
size=strlen(senti);
for(x=0;x<size;x++)
{
Sleep(40);
printf("%c",senti[x]);
}
Sleep(2000);
system("cls");
woodenhut();
}
else if ((choice == 'y') && (Exp <=0))
{
health=health-20;
system("cls");
printf("OLD WOMAN\n"
"\n\n");
char sentth[]="I can see it in your eyes, you are lying to me!\n"
"For this punishment.... Back you go, and I will take\n"
"Some of your life force too, and use it to create my own!\n"
"NEVER LIE TO A WISE ONE!\n"
"\n\n";
size=strlen(sentth);
for(x=0;x<size;x++)
{
Sleep(40);
printf("%c",sentth[x]);
}
Sleep(1000);
char sentj[]="You feel dizzy and close your eyes, when you open them, you\n"
"find yourself back at the signpost...\n";
size=strlen(sentj);
for(x=0;x<size;x++)
{
Sleep(40);
printf("%c",sentj[x]);
}
Sleep(2000);
system("cls");
signpost();
}
else if (choice == 'n')
{
system("cls");
cout<<""<< pname <<""<<endl;
char sentti[]="\n\n"
"No, I have not got any yet, but I will venture on and return\n"
"when I am more experienced.\n"
"\n\n";
size=strlen(sentti);
for(x=0;x<size;x++)
{
Sleep(40);
printf("%c",sentti[x]);
}
printf("OLD WOMAN:");
char senttj[]="\n\n"
"I like people who tell the truth, for a reward, I will give you a\n"
"clue...\n"
"\n\n"
"Go to the OLD CHURCH. The minester should be able to help you\n"
"gain some experience in battle...\n"
"\n\n"
"Now, I shall return you to the signpost you past, it is the nearest I can\n"
"get you to the church....\n"
"\n\n";
size=strlen(senttj);
for(x=0;x<size;x++)
{
Sleep(40);
printf("%c",senttj[x]);
}
Sleep(2000);
system("cls");
printf("WIZADORA");
char sentk[]="\n\n"
"Hey, who was that woman, some sort of witch?\n"
"And look, we are back at the signpost....\n"
"\n\n";
size=strlen(sentk);
for(x=0;x<size;x++)
{
Sleep(40);
printf("%c",sentk[x]);
}
cout<<""<< pname <<""<<endl;
char sentl[]="\n\n"
"I do not know who she was Wizadora, but we need that Experience.\n"
"We'd better head to the old church. Maybe we can find some answera there.\n"
"\n\n";
size=strlen(sentl);
for(x=0;x<size;x++)
{
Sleep(40);
printf("%c",sentl[x]);
}
Sleep(2000);
system("cls");
signpost();
}
else {
system("cls");
printf("You must press yes or no");
Sleep(2000);
system("cls");
creepywoods();
}
} // end function Creepy Woods
void woodenhut()
{
} // end function woodenhut
void endingANDcredits()
{
HANDLE h = GetStdHandle ( STD_OUTPUT_HANDLE );
WORD wOldColorAttrs;
CONSOLE_SCREEN_BUFFER_INFO csbiInfo;
/*
* First save the current color information
*/
GetConsoleScreenBufferInfo(h, &csbiInfo);
wOldColorAttrs = csbiInfo.wAttributes;
/*
* Set the new color information
*/
SetConsoleTextAttribute ( h, FOREGROUND_GREEN|FOREGROUND_INTENSITY );
system("cls");
char senteog[]="Drucila Falls to the floor and trys to grab you\n"
"as you take a step back from her...\n"
"\n\n"
"The chapel begins to tumble to the floor, you manage to\n"
"escape through the large window on your left hand side.\n"
"\n\n"
"You run and run as the cathedral tumbles down behind you.\n"
"\n\n"
"The sun breaks through the clouds as they turn from dark\n"
"to white\n"
"In the faint rays of the sun, the monsters that littered the\n"
"ground turn back to the once happy people of Wiza...\n"
"\n\n"
"You then arrive back in the town square, and recive three\n"
"huge cheers as the entire town turns out to give their thanks!\n"
"\n\n"
"The WHITE WILLOW begins to glow and sprout with joy once more...\n"
"\n\n"
"You can see the light flowing from it's glistening bark...\n"
"\n\n"
"\n\n"
"With Drucila now defeated, and the land of Wiza finaly free, you can\n"
"now take a well earned break....\n"
"\n\n"
"\n\n"
"\n\n"
"\n\n"
"CONGATULATIONS!!!!!\n"
"\n\n"
"\n\n"
"\n\n"
"\n\n"
"\n\n"
"\n\n";
size=strlen(senteog);
for(x=0;x<size;x++)
{
Sleep(40);
printf("%c",senteog[x]);
}
Sleep(2000);
system("cls");
char senteogc[]="\tW I Z A D O R A\n"
"\t\n\n"
"\tProgramed by - Peter Watts\n"
"\t\n\n"
"\tWritten and Developed by - Peter Watts\n"
"\t\n\n"
"\tSound and Music - Steve THE MAN Childs\n"
"\t\n\n"
"\tSprite Design - Alan Pink\n"
"\t\n\n"
"\tText Color Program - Peter Watts\n"
"\t\n\n"
"\tMain dcpp Concept - Archwright Limited\n"
"\t\n\n"
"\tSpecial Thanks - Alan Pink\n"
"\t\n\n"
"\t Steve Childs\n"
"\t\n\n"
"\tLook out for the sequal soon!!!\n"
"\t\n\n"
"\n\n"
"\n\n"
"\n\n"
"\n\n"
"\t\tT H E E N D\n"
"\n\n"
"\n\n"
"\n\n"
"\n\n"
"\n\n"
"\n\n";
size=strlen(senteogc);
for(x=0;x<size;x++)
{
Sleep(40);
printf("%c",senteogc[x]);
}
Sleep(3000);
exit(0);
} // end of game
here is the gsameover function source: