Thanks for all the help. I took both of what you said and got this code:
Code: Select all
#include <irrlicht.h>
#include <iostream>
#include <audiere.h>
using namespace irr;
using namespace audiere;
bool play;
#pragma comment(lib, "Irrlicht.lib")
#pragma comment(lib, "audiere.lib")
class MyEventReceiver : public IEventReceiver
{
public:
virtual bool OnEvent(SEvent event)
{
if(event.EventType == EET_MOUSE_INPUT_EVENT)
{
if(event.MouseInput.Event == EMIE_LMOUSE_PRESSED_DOWN)
play = true;
if (event.MouseInput.Event == EMIE_LMOUSE_LEFT_UP)
play = false;
}
}
};
int main()
{
MyEventReceiver MyReceiver;
video::E_DRIVER_TYPE driverType;
printf("Please select the driver you want for this example:\n"\
" (a) Direct3D 9.0c\n (b) Direct3D 8.1\n (c) OpenGL 1.2\n"\
" (d) Software Renderer\n (e) NullDevice\n (otherKey) exit\n\n");
char i;
std::cin >> i;
switch(i)
{
case 'a': driverType = video::EDT_DIRECTX9;break;
case 'b': driverType = video::EDT_DIRECTX8;break;
case 'c': driverType = video::EDT_OPENGL; break;
case 'd': driverType = video::EDT_SOFTWARE; break;
case 'e': driverType = video::EDT_NULL; break;
default: return 0;
}
// create device
IrrlichtDevice *device = createDevice(driverType,
core::dimension2d<s32>(1024, 768), 32, true, false, false, MyReceiver);
if (device == 0)
return 1; // could not create selected driver.
video::IVideoDriver* driver = device->getVideoDriver();
scene::ISceneManager* smgr = device->getSceneManager();
device->getFileSystem()->addZipFileArchive
("map.pk3");
scene::IAnimatedMesh* q3levelmesh = smgr->getMesh("20kdm2.bsp");
scene::ISceneNode* q3node = 0;
if (q3levelmesh)
q3node = smgr->addOctTreeSceneNode(q3levelmesh->getMesh(0));
scene::ITriangleSelector* selector = 0;
if (q3node)
{
q3node->setPosition(core::vector3df(-1370,-130,-1400));
selector = smgr->createOctTreeTriangleSelector(
q3levelmesh->getMesh(0), q3node, 128);
q3node->setTriangleSelector(selector);
selector->drop();
}
scene::ICameraSceneNode* camera =
camera = smgr->addCameraSceneNodeFPS(0,50.0f,300.0f);
camera->setPosition(core::vector3df(-100,30,-150));
scene::ISceneNodeAnimator* anim =
smgr->createCollisionResponseAnimator(
selector, camera, core::vector3df(30,50,30),
core::vector3df(0,-3,0),
core::vector3df(0,50,0));
camera->addAnimator(anim);
anim->drop();
// disable mouse cursor
device->getCursorControl()->setVisible(false);
smgr->addLightSceneNode(0, core::vector3df(-60,100,400),
video::SColorf(1.0f,1.0f,1.0f,1.0f),
600.0f);
// add skybox
driver->setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS, false);
smgr->addSkyBoxSceneNode(
driver->getTexture("irrlicht2_up.jpg"),
driver->getTexture("irrlicht2_dn.jpg"),
driver->getTexture("irrlicht2_lf.jpg"),
driver->getTexture("irrlicht2_rt.jpg"),
driver->getTexture("irrlicht2_ft.jpg"),
driver->getTexture("irrlicht2_bk.jpg"));
// play background music
AudioDevicePtr sound_device(OpenDevice());
OutputStreamPtr stream(OpenSound(sound_device, "Theme.mp3", true));
OutputStreamPtr sound(OpenSound(sound_device, "shoot.wav", false));
stream->setRepeat(true);
stream->setVolume(0.5f);
stream->play();
video::ITexture* image = driver->getTexture("ak47.bmp");
driver->makeColorKeyTexture(image,video::SColor(0,0,61,132));
scene::ISceneNode* selectedSceneNode = 0;
scene::ISceneNode* lastSelectedSceneNode = 0;
while(device->run())
if (device->isWindowActive())
{
driver->beginScene(true, true, video::SColor(255,113,113,133));
smgr->drawAll();
if (play == true)
{
sound->setRepeat(true);
sound->setVolume(1.5f);
sound->play();
}
if (play == false)
{
sound->stop();
}
driver->draw2DImage(image, core::position2d<s32>(400,515),
core::rect<s32>(0,0,256,256), 0, video::SColor(255,255,255,255), true);
driver->endScene();
}
device->drop();
return 0;
}
Code: Select all
--------------------Configuration: FPS - Win32 Debug--------------------
Compiling...
main.cpp
C:\Documents and Settings\Tigran\My Documents\C++ TUTS\FPS\main.cpp(71) : error C2664: 'createDevice' : cannot convert parameter 7 from 'class MyEventReceiver' to 'class irr::IEventReceiver *'
No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
Error executing cl.exe.
main.obj - 1 error(s), 0 warning(s)
TYVM!