I have been learning c++ through the Game Institute. The code here is from the book. I can get the code to work with VC 2008 no problem. I would like to use DarkGDK so I set up a project using the wizard option DarkGdk-game get all the class code done and it compiles with no errors but when the screen comes up nothing is seen. My code generation for C++ under the properties is set to MT. I have tried all the other options and get lots of errors. Not sure what this option is supposed to be for mixing Dgdk and straight C++. I have tried the code in main in and out of the While(Loop).
Here is the code
The header file
#ifndef WIZARD _H
#define WIZARD_H
#include <iostream>
#include <string>
#include "DarkGDK.h"
class Wizard
{
public:
//Methods
void fight();
void talk();
void castSpell();
//Data members
std::string mName;
int mHitPoints;
int mMagicPoints;
int mArmor;
};
#endif //Wizard_h
Here is the class implementation file
#include "wiz.h"
using namespace std;
void Wizard::fight()
{
cout << "fighting" << endl;
}
void Wizard::talk()
{
cout << "Talking" << endl;
}
void Wizard::castSpell()
{
cout << "Casting Spell" << endl;
}
And here is the main file
// Dark GDK - The Game Creators - www.thegamecreators.com
// the wizard has created a very simple project that uses Dark GDK
// it contains the basic code for a GDK application
// whenever using Dark GDK you must ensure you include the header file
#include "DarkGDK.h"
#include "wiz.h"
#include <iostream>
#include <string>
using namespace std;
// the main entry point for the application is this function
void DarkGDK ( void )
{
// turn on sync rate and set maximum rate to 60 fps
dbSyncOn ( );
dbSyncRate ( 60 );
// our main loop
while ( LoopGDK ( ) )
{
Wizard wiz0; // Declare a variable called wiz0 of type Wizard
wiz0.fight();
wiz0.talk();
wiz0.mArmor = 10;
cout << "Player's name = " << wiz0.mName << endl;
//Test to see if player has enough magic points to cast a spell
if(wiz0.mMagicPoints > 4)
wiz0.castSpell();
else
cout << "Not enough magic points!" << endl;
// update the screen
dbSync ( );
}
// return back to windows
return;
}