Code:
#include "haunt.h"
/***************** PLAYER *****************************************************/
Player::Player()
{
health = 100;
gold = 5;
magic = 0;
pname;
palive = true; // new game
pdead = false; // turns TRUE when player defeated
}
Player::~Player()
{
}
/****************** ENEMY *****************************************************/
Enemy::Enemy()
{
ehealth;
edamage;
ename;
ealive = true; // on enemy encounter
edead = false; // turns TRUE when enemy defeated
}
Enemy::~Enemy()
{
}
void gotoxy( int x, int y )
{
COORD c;
c.X = x - 1 ;
c.Y = y - 1 ;
// TO REMEMBER: 1ST NUMBER SPACES IN :: 2ND NUMBER SPACES DOWN
SetConsoleCursorPosition( GetStdHandle( STD_OUTPUT_HANDLE ), c ) ;
}
// string colour graphic function
void DrawColorString(string szText, int X, int Y, WORD color)
{
HANDLE OutputH;
COORD position = {X, Y};
OutputH = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleTextAttribute(OutputH, color);
SetConsoleCursorPosition(OutputH, position);
cout << szText;
}
// full screen mode ( optional )
void FullScreen ( void )
{
keybd_event(VK_MENU, 0x38, 0, 0);
keybd_event(VK_RETURN, 0x1c, 0, 0);
keybd_event(VK_RETURN, 0x1c, KEYEVENTF_KEYUP, 0);
keybd_event(VK_MENU, 0x38, KEYEVENTF_KEYUP, 0);
}
void tb ( void )
{
Player play;
system("cls");
DrawColorString("", 0, 5, FOREGROUND_GREEN);
gotoxy(2,1);cout << "PLAYER:";
DrawColorString("", 0, 5, FOREGROUND_RED | FOREGROUND_GREEN);
gotoxy(11,1);cout << play.pname;
DrawColorString("", 0, 5, FOREGROUND_GREEN);
gotoxy(2,3);cout << "HEALTH:";
DrawColorString("", 0, 5, FOREGROUND_RED | FOREGROUND_GREEN);
gotoxy(11,3);cout << play.health;
DrawColorString("", 0, 5, FOREGROUND_GREEN);
gotoxy(45,1);cout << "HP:";
DrawColorString("", 0, 5, FOREGROUND_RED | FOREGROUND_GREEN);
gotoxy(50,1);cout << play.magic;
DrawColorString("", 0, 5, FOREGROUND_GREEN);
gotoxy(45,3);cout << "GOLD:";
DrawColorString("", 0, 5, FOREGROUND_RED | FOREGROUND_GREEN);
gotoxy(58,3);cout << play.gold;
DrawColorString("", 0, 5, FOREGROUND_BLUE);
}
// create message box at bottom of screen
void bb ( void )
{
gotoxy(2,42);cout << "**************************************************************************";
gotoxy(2,43);cout << "*";
gotoxy(75,43);cout << "*";
gotoxy(2,44);cout << "*";
gotoxy(75,44);cout << "*";
gotoxy(2,45);cout << "*";
gotoxy(75,45);cout << "*";
gotoxy(2,46);cout << "*";
gotoxy(75,46);cout << "*";
gotoxy(2,47);cout << "*";
gotoxy(75,47);cout << "*";
gotoxy(2,48);cout << "**************************************************************************";
}
code for main