[Linker error] undefined reference to `game_manager::loadcamera()'
i kept trying to recompile it but it keeps coming back
this is the code for so far
Code: Select all
//game manager.h
#include <irrlicht.h>
#include "entity.h"
using namespace irr;
using namespace gui;
using namespace video;
using namespace scene;
using namespace core;
class game_manager : public IEventReceiver
{
public:
scene::ICameraSceneNode* camera;
void Update();
Entity* getirrPlayer();
IrrlichtDevice* getirrDevice();
IVideoDriver* getirrDriver();
ISceneManager* getirrSceneManager();
IGUIEnvironment* getirrGUIEnvironment();
Entity* irrplayer;
Entity* irrenemy;
void CreateDevice();
IrrlichtDevice* irrDevice;
IVideoDriver* irrVideoDriver;
ISceneManager* irrSceneManager;
IGUIEnvironment* irrGUIEnvironment;
void Init();
void loadcamera01();
void loadweapon();
void addskymap();
bool OnEvent(SEvent event);
void addbuddycamera();
void shoot1();
void play();
void loadmap01();
};
//game manager.cpp
//this is the game manager that is responible for most/all the 3D parts of the engine
#include <irrlicht.h>
#include "game_manager.h"
void game_manager::CreateDevice()
{
irrDevice = createDevice(EDT_OPENGL, core::dimension2d<s32>(700, 600), 16, false,true,false,this);
if(irrDevice == NULL)
{
irrDevice = createDevice(EDT_DIRECT3D9, core::dimension2d<s32>(700, 600), 16,false,true,false,this);
}
irrVideoDriver = irrDevice->getVideoDriver();
irrSceneManager = irrDevice->getSceneManager();
irrGUIEnvironment = irrDevice->getGUIEnvironment();
Init();
}
IrrlichtDevice* game_manager::getirrDevice()
{
return irrDevice;
}
IVideoDriver* game_manager::getirrDriver()
{
return irrVideoDriver;
}
ISceneManager* game_manager::getirrSceneManager()
{
return irrSceneManager;
}
IGUIEnvironment* game_manager::getirrGUIEnvironment()
{
return irrGUIEnvironment;
}
Entity* game_manager::getirrPlayer()
{
return irrplayer;
}
void game_manager::Init()
{
this->getirrDevice()->getFileSystem()->addZipFileArchive("gfx/map-20kdm2.pk3");
}
void game_manager::loadmap01()
{
scene::IAnimatedMesh* q3levelmesh =this->irrSceneManager->getMesh("20kdm2.bsp");
scene::ISceneNode* q3node = 0;
if (q3levelmesh)
q3node = this->irrSceneManager->addOctTreeSceneNode(q3levelmesh->getMesh(0));
scene::ITriangleSelector* selector = 0;
if (q3node)
{
q3node->setPosition(core::vector3df(-1370,-130,-1400));
selector = this->irrSceneManager->createOctTreeTriangleSelector(q3levelmesh->getMesh(0), q3node, 128);
q3node->setTriangleSelector(selector);
selector->drop();
}
}
//this is where the error comes from (i think :? )
void game_manager::loadcamera01()
{
camera = this->irrSceneManager->addCameraSceneNodeFPS();
camera->setPosition(core::vector3df(0,0,-50));
}
void game_manager::loadweapon()
{
scene::IAnimatedMesh* weapon = this->irrSceneManager->getMesh("gfx/uzi.3ds");
scene::IAnimatedMeshSceneNode* weaponnode = this->irrSceneManager->addAnimatedMeshSceneNode(weapon,camera);
weaponnode->setMaterialFlag(video::EMF_LIGHTING, false);
weaponnode->setPosition(core::vector3df(50,-30,85));
weaponnode->setScale(core::vector3df(5,5,5));
}
void game_manager::addskymap()
{
this->irrSceneManager->addSkyBoxSceneNode(
this->irrVideoDriver->getTexture("gfx/nemesis_up.jpg"),0,
this->irrVideoDriver->getTexture("gfx/nemesis_lf.jpg"),
this->irrVideoDriver->getTexture("gfx/nemesis_rt.jpg"),
this->irrVideoDriver->getTexture("gfx/nemesis_ft.jpg"),
this->irrVideoDriver->getTexture("gfx/nemesis_bk.jpg"));
}
void game_manager::shoot1()
{
core::vector3df start = camera->getPosition();
core::vector3df end = (camera->getTarget() - start);
end.normalize();
start += end*5.0f;
end = start + (end * camera->getFarValue());
// create fire ball
scene::ISceneNode* bulletnode = 0;
bulletnode = this->irrSceneManager->addBillboardSceneNode(0,
core::dimension2d<f32>(25,25), start);
bulletnode->setMaterialFlag(video::EMF_LIGHTING, false);
bulletnode->setMaterialTexture(0, this->irrVideoDriver->getTexture("gfx/fire.bmp"));
bulletnode->setMaterialType(video::EMT_TRANSPARENT_ADD_COLOR);
f32 length = (f32)(end - start).getLength();
const f32 speed = 0.6f;
u32 time = (u32)(length / speed);
scene::ISceneNodeAnimator* anim = 0;
// set flight line
anim = this->irrSceneManager->createFlyStraightAnimator(start, end, time);
bulletnode->addAnimator(anim);
anim->drop();
anim = this->irrSceneManager->createDeleteAnimator(time);
bulletnode->addAnimator(anim);
anim->drop();
}
bool game_manager::OnEvent(SEvent event)
{
if (event.EventType == EET_KEY_INPUT_EVENT &&
event.KeyInput.Key == KEY_ESCAPE &&
event.KeyInput.PressedDown == false)
{
this->getirrDevice()->closeDevice();
}
if(event.EventType == EET_KEY_INPUT_EVENT &&
event.KeyInput.Key == KEY_SPACE &&
event.KeyInput.PressedDown == true ||
EET_MOUSE_INPUT_EVENT &&
event.MouseInput.Event == EMIE_LMOUSE_LEFT_UP)
{
shoot1();
}
}
//entity.h
#include <irrlicht.h>
class Entity
{
public:
void Initialize(Entity obj_init);
int health;
int ammo;
int speed;
long x;
long y;
long z;
int sethealth(int g_health);
int gethealth();
int setammo(int g_ammo);
int getammo();
int setspeed(int g_speed);
int getspeed();
long setposition(long g_x,long g_y,long g_z);
long getposition();
long CheckCollision(Entity obj1, Entity obj2);
Entity();
Entity(int g_health, int g_ammo, int g_speed);
};
//entity.cpp
#include "entity.h"
#include <irrlicht.h>
void Entity::Initialize(Entity obj_init)
{
obj_init.sethealth(100);
obj_init.setspeed(10);
obj_init.setammo(100);
}
int Entity::sethealth(int g_health)
{
health = g_health;
}
int Entity::gethealth()
{
return health;
}
int Entity::setspeed(int g_speed)
{
speed = g_speed;
}
int Entity::getspeed()
{
return speed;
}
int Entity::setammo(int g_ammo)
{
ammo = g_ammo;
}
int Entity::getammo()
{
return ammo;
}
long Entity::CheckCollision(Entity obj1, Entity obj2)
{
long result;
long X = obj1.x - obj2.x; //get x
long Y = obj1.y - obj2.y; //get y
long Z = obj1.z - obj2.z; //get z
result = long((x*x) + (y*y) + (z*z) + 1); //finds the distance
return result;
}
Entity::Entity()
{
health = 0;
ammo = 0;
speed = 0;
x = 0;
y = 0;
z = 0;
}
Entity::Entity(int g_health,int g_ammo,int g_speed)
{
health = g_health;
ammo = g_ammo;
speed = g_speed;
}