When I previewed the message, all the code tags after the first one didn't work, so it might not appear correctly.
main.cpp
Code: Select all
#include <iostream>
#include <fstream>
#include <vector>
#include "MyEventReceiver.h"
#include "GameCore.h"
#include "Irrlicht.h"
#pragma comment(lib, "Irrlicht.lib")
using namespace irr;
int main() {
/*
GameCore MyCore;
MyCore.InitDevice();
IrrlichtDevice *device = MyCore.device;
device->getSceneManager();
video::IVideoDriver* driver = device->getVideoDriver();
scene::ISceneManager* smgr = device->getSceneManager();
device->getFileSystem()->addZipFileArchive("map-20kdm2.pk3");
scene::IAnimatedMesh* mesh = smgr->getMesh("20kdm2.bsp");
scene::IAnimatedMeshSceneNode* node;
scene::IAnimatedMesh* mesh2 = smgr->getMesh("Soldier9.3ds");
scene::IAnimatedMeshSceneNode* node2;
scene::ISceneNode* camera = smgr->addCameraSceneNodeFPS();
scene::ISceneNode* camera2 = smgr->addCameraSceneNodeFPS();
int hello = MyCore.receiver.xplane;
if (mesh)
node = smgr->addAnimatedMeshSceneNode(mesh, camera, -1, core::vector3df(10, 0, 0));
node2 = smgr->addAnimatedMeshSceneNode(mesh2, camera, -1, core::vector3df(500, 0, 0));}
int lastFPS = -1;
while(device->run())
{
driver->beginScene ( true, true, video::SColor ( 0, 0, 0, 0 ) );
smgr->drawAll ( );
driver->endScene ( );
int fps = driver->getFPS();
if (lastFPS != fps)
{
core::stringw str = L"Irrlicht Engine - Vertex and pixel shader example [";
str += driver->getName();
str += "] FPS:";
str += fps;
device->setWindowCaption(str.c_str());
lastFPS = fps;
}
}
device->drop();
*/
GameCore* myCore;
myCore->videoCore->Init();
int hello;
cin >> hello;
if (hello = 1) {
return 0;}
}
MyEventReceiver.h
Code: Select all
#ifndef __MYEVENTRECEIVER_H__
#define __MYEVENTRECEIVER_H__
#include "Irrlicht.h"
//#include "GameCore.h"
#include <iostream>
using namespace std;
using namespace irr;
const int MOUSE_BUTTON_CODE_COUNT = 3;
class MyEventReceiver : public IEventReceiver {
private:
core::vector2di m_mouseLocation;
bool m_mouseMoved;
f32 m_mouseWheelValue;
bool m_key_buffer[KEY_KEY_CODES_COUNT];
bool m_key_buffer_toggle[KEY_KEY_CODES_COUNT];
bool m_mouse_buffer[MOUSE_BUTTON_CODE_COUNT];
bool m_mouse_buffer_toggle[MOUSE_BUTTON_CODE_COUNT];
//scene::IAnimatedMeshSceneNode* currentNode;
public:
/*
void setCurrentNode(scene::IAnimatedMeshSceneNode* setCurrentNodeNode) {
currentNode = setCurrentNodeNode;
}
*/
virtual bool OnEvent(SEvent event) {
switch ( event.EventType ) {
case EET_KEY_INPUT_EVENT: {
m_key_buffer[event.KeyInput.Key] = event.KeyInput.PressedDown;
switch (event.KeyInput.Key) {
//case KEY_KEY_W: cout << "whoamg its W, lol" << endl; break;
case 65: cout << "y helo thar A" << endl; break;
case 83: cout << "O_O S" << endl; break;
case 68: cout << "I'm D. D for YOU!" << endl; break;
case KEY_KEY_W:
cout << "W" << endl;
}
return true; }
case EET_MOUSE_INPUT_EVENT:{
if ( event.MouseInput.Event == EMIE_MOUSE_WHEEL )
m_mouseWheelValue = event.MouseInput.Wheel;
if ( event.MouseInput.Event == EMIE_MOUSE_MOVED ) {
m_mouseLocation.X = event.MouseInput.X;
m_mouseLocation.Y = event.MouseInput.Y;
m_mouseMoved = true; }
if ( event.MouseInput.Event == EMIE_LMOUSE_PRESSED_DOWN )
m_mouse_buffer[EMIE_LMOUSE_PRESSED_DOWN] = true;
else if ( event.MouseInput.Event == EMIE_LMOUSE_LEFT_UP )
m_mouse_buffer[EMIE_LMOUSE_PRESSED_DOWN] = false;
if ( event.MouseInput.Event == EMIE_RMOUSE_PRESSED_DOWN )
m_mouse_buffer[EMIE_RMOUSE_PRESSED_DOWN ] = true;
else if ( event.MouseInput.Event == EMIE_RMOUSE_LEFT_UP )
m_mouse_buffer[EMIE_RMOUSE_PRESSED_DOWN] = false;
if ( event.MouseInput.Event == EMIE_MMOUSE_PRESSED_DOWN )
m_mouse_buffer[EMIE_MMOUSE_PRESSED_DOWN ] = true;
else if ( event.MouseInput.Event == EMIE_MMOUSE_LEFT_UP )
m_mouse_buffer[EMIE_MMOUSE_PRESSED_DOWN] = false;
return true;
}
}
return false;
}
};
#endif // __MYEVENTRECEIVER_H__
VideoCore.h
Code: Select all
#ifndef __VIDEOCORE_H__
#define __VIDEOCORE_H__
#include "Irrlicht.h"
#include "MyEventReceiver.h"
using namespace irr;
class VideoCore
{
private:
IrrlichtDevice* device;
scene::ISceneManager* smgr;
video::IVideoDriver* driver;
gui::IGUIEnvironment* guiEnvironment;
MyEventReceiver* receiver;
video::E_DRIVER_TYPE deviceType;
bool fullscreen;
core::dimension2d<s32> windowSize;
public:
VideoCore();
~VideoCore();
bool Init();
IrrlichtDevice* GetDevice ( ) { return device; }
video::IVideoDriver* GetVideoDriver ( ) { return driver; }
scene::ISceneManager* GetSceneManager ( ) { return smgr; }
gui::IGUIEnvironment* GetGUIEnvironment ( ) { return guiEnvironment; }
MyEventReceiver* GetReceiver ( ) { return receiver; }
core::rect<s32> GetViewPort ( ) { return driver->getViewPort ( ); }
int GetViewPortWidth ( ) { return driver->getViewPort ( ).getWidth ( ); }
int GetViewPortHeight ( ) { return driver->getViewPort ( ).getHeight ( ); }
void SetDeviceType ( video::E_DRIVER_TYPE deviceType ) { deviceType = deviceType; }
void SetWindowSize ( core::dimension2d<s32> windowSize ) { windowSize = windowSize; }
void SetFullscreen ( bool fullscreen ) { fullscreen = fullscreen; }
};
#endif
VideoCore.cpp
Code: Select all
#include "VideoCore.h"
#include "MyEventReceiver.h"
#include "Irrlicht.h"
using namespace irr;
// VideoCore Constructor
VideoCore::VideoCore ( )
{
device = NULL;
smgr = NULL;
driver = NULL;
guiEnvironment = NULL;
receiver = NULL;
deviceType = video::EDT_OPENGL;
fullscreen = false;
windowSize = core::dimension2d<s32> ( 1024, 768 );
}
// VideoCore Destructor
VideoCore::~VideoCore ( )
{
if ( receiver )
delete receiver;
}
// VideoCore Initialization
bool VideoCore::Init()
{
receiver = new MyEventReceiver;
device = createDevice(deviceType, windowSize, 32, fullscreen, false, false, receiver);
if ( device )
{
smgr = device->getSceneManager ( );
driver = device->getVideoDriver ( );
guiEnvironment = device->getGUIEnvironment ( );
return true;
}
return false;
}
GameCore.h
Code: Select all
#ifndef __GAMECORE_H__
#define __GAMECORE_H__
#include "Irrlicht.h"
#include <iostream>
#include "VideoCore.h"
using namespace std;
using namespace irr;
class GameCore {
public:
VideoCore* videoCore;
};
#endif