-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgame.cpp
100 lines (69 loc) · 2.16 KB
/
game.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#include "iostream"
#include "game.h"
#include "irrlicht.h"
using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;
char ROOT [] = "/home/morphei/QtProjects/IrrlichtTest/resources/";
Game::Game()
{
device = createDevice(video::EDT_OPENGL, dimension2d<u32>(1024, 768), 32, false, false, false, 0);
if (!device)
{
device->drop();
}
else
{
device->setWindowCaption(L"Demo Irrlicht Game");
driver = device->getVideoDriver();
sceneManager = device->getSceneManager();
guiEnvironment = device->getGUIEnvironment();
//run();
}
}
void Game::run()
{
IAnimatedMesh* mesh = sceneManager->getMesh(strcat(ROOT, "sydney.md2"));
if (!mesh)
device->drop();
IAnimatedMeshSceneNode* node = sceneManager->addAnimatedMeshSceneNode(mesh);
node->setMaterialFlag(EMF_LIGHTING, false);
node->setMD2Animation(scene::EMAT_RUN);
node->setMaterialTexture( 0, driver->getTexture("/home/morphei/QtProjects/IrrlichtTest/resources/sydney.bmp"));
sceneManager->addCameraSceneNodeFPS();//0, vector3df(0,30,-40),vector3df(0,5,0));
device->getCursorControl()->setVisible(false);
while (device->run()) {
driver->beginScene(true, true, SColor(255,100,101,140));
sceneManager->drawAll();
guiEnvironment->drawAll();
driver->endScene();
}
device->drop();
}
void Game::init()
{
IAnimatedMesh* mesh = sceneManager->getMesh(strcat(ROOT, "sydney.md2"));
if (!mesh)
device->drop();
IAnimatedMeshSceneNode* node = sceneManager->addAnimatedMeshSceneNode(mesh);
node->setMaterialFlag(EMF_LIGHTING, false);
node->setMD2Animation(scene::EMAT_RUN);
node->setMaterialTexture( 0, driver->getTexture("/home/morphei/QtProjects/IrrlichtTest/resources/sydney.bmp"));
sceneManager->addCameraSceneNode(0, vector3df(0,30,-40),vector3df(0,5,0));
}
void Game::update()
{
}
void Game::render()
{
driver->beginScene(true, true, SColor(255,100,101,140));
sceneManager->drawAll();
guiEnvironment->drawAll();
driver->endScene();
}
void Game::processEvents()
{
}