i'm trying to display only part of something and i want it to fit the entire windows/screen.I also want to be able to move what i see, like a 2d strategy game camera.
Here is my code:
Code: Select all
#include <IRR/irrlicht.h>
using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;
stringw text(L"Irrlicht - cursor position = ");
int main(void)
{
IrrlichtDevice *device = createDevice (EDT_OPENGL,dimension2d<irr::u32>(1280,720),32,false,true,true,0);
IVideoDriver* driver = device->getVideoDriver ();
ISceneManager *sceneManager = device->getSceneManager ();
ITexture* images = driver->getTexture("test2.png");
ITexture* images1 = driver->getTexture("archer2.png");
ITexture* images3 = driver->getTexture("archer3.png");
ITexture* images2 = driver->getTexture("64.png");
driver->makeColorKeyTexture(images1, core::position2d<s32>(0,0));
driver->makeColorKeyTexture(images3, core::position2d<s32>(0,0));
IGUIEnvironment *gui = device->getGUIEnvironment();
while (device->run ())
{
stringw text(L"Irrlicht - cursor position = ");
text += device->getCursorControl ()-> getPosition().X;
text += L" ";
text += device->getCursorControl ()-> getPosition().Y;
driver->beginScene(true, true,SColor(255,128,225,255));
driver->draw2DImage(images,position2d<s32>(0,0),
rect<s32>(0,0,640,320), 0,
SColor(255,255,255,255), true);
driver->draw2DImage(images1,position2d<s32>(224,96),
rect<s32>(0,0,64,64), 0,
SColor(255,255,255,255), true);
driver->draw2DImage(images2,position2d<s32>(64,32),
rect<s32>(0,0,64,64), 0,
SColor(255,255,255,255), true);
driver->draw2DImage(images3,position2d<s32>(288,96),
rect<s32>(0,0,64,64), 0,
SColor(255,255,255,255), true);
device->setWindowCaption(text.c_str());
sceneManager->drawAll();
gui->drawAll();
driver->endScene();
}
device->drop ();
return 0;
}
2nd image: what i want to display
3rd image: what i would like to have as a result
If someone can point me in the right direction that would be great. Also if someone know an easier library than irrlicht to do a 2d tactics game i'm interested.