In main.cpp:
Code: Select all
#include <irrlicht.h>
#include <iostream>
#include "audiere.h"
#include "CDemo.h"
using namespace irr;
using namespace audiere;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;
//bool fire;
//bool fullscreen = false;
bool progDeath = false;
void shoot();
#pragma comment(lib, "Irrlicht.lib")
#pragma comment(lib, "audiere.lib")
static IrrlichtDevice* device = 0;
class MyEventReceiver : public IEventReceiver
{
public:
virtual bool OnEvent(SEvent event)
{
if (event.EventType == EET_KEY_INPUT_EVENT){
switch(event.KeyInput.Key){
case KEY_ESCAPE:
{
return progDeath = true;
}
}
}
if (event.EventType == EET_MOUSE_INPUT_EVENT)
{
switch(event.MouseInput.Event) {
case EMIE_LMOUSE_LEFT_UP:
shoot();
}
}
return false;
}
};
int main()
{
MyEventReceiver receiver;
......
device->drop();
return 0;
}
void CDemo::shoot()
{
scene::ISceneManager* sm = device->getSceneManager();
scene::ICameraSceneNode* camera = sm->getActiveCamera();
if (!camera)
return;
SParticleImpact imp;
imp.when = 0;
// get line of camera
core::vector3df start = camera->getPosition();
core::vector3df end = (camera->getTarget() - start);
end.normalize();
start += end*5.0f;
end = start + (end * camera->getFarValue());
core::triangle3df triangle;
core::line3d<f32> line(start, end);
// get intersection point with map
if (sm->getSceneCollisionManager()->getCollisionPoint(
line, mapSelector, end, triangle))
{
// collides with wall
core::vector3df out = triangle.getNormal();
out.setLength(0.03f);
imp.when = 1;
imp.outVector = out;
imp.pos = end;
}
else
{
// doesnt collide with wall
end = (camera->getTarget() - start);
end.normalize();
end = start + (end * 1000);
}
// create fire ball
scene::ISceneNode* node = 0;
node = sm->addBillboardSceneNode(0,
core::dimension2d<f32>(25,25), start);
node->setMaterialFlag(video::EMF_LIGHTING, false);
node->setMaterialTexture(0, device->getVideoDriver()->getTexture("fireball.bmp"));
node->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 = sm->createFlyStraightAnimator(start, end, time);
node->addAnimator(anim);
anim->drop();
anim = sm->createDeleteAnimator(time);
node->addAnimator(anim);
anim->drop();
if (imp.when)
{
// create impact note
imp.when = device->getTimer()->getTime() + (time - 100);
Impacts.push_back(imp);
}
}
It give me 2 errors when linking:
Code: Select all
Linking...
main.obj : error LNK2001: unresolved external symbol "void __cdecl shoot(void)" (?shoot@@YAXXZ)
Debug/FPS.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
FPS.exe - 2 error(s), 0 warning(s)
Thank you so so so much!