Code: Select all
#include "preamble.h"
using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;
#pragma comment(lib, "Irrlicht.lib")
int main() {
//MyEventReceiver receiver;
IrrlichtDevice *device = createDevice(EDT_DIRECT3D8,
dimension2d<s32>(800,600),
16, //bit
false, //fullscrenn
false, //stencilbufer (bayangan)
false);
video::IVideoDriver* driver = device->getVideoDriver();
scene::ISceneManager* scenemgr = device->getSceneManager();
IGUIEnvironment* env = device->getGUIEnvironment();
//layar pertama
ITexture * background = 0;
IGUIFont * fontjudul = env->getFont("Fonts/franklin_gothic.xml");
IGUIFont * fonttombol = env->getFont("Fonts/arialblack_14.xml");
env->getSkin()->setFont(fonttombol);
array<IGUIButton*> butons;
menu_state state;
state = MS_PEMBUKAAN;
bool loaded = false;
while (device->run()){
driver->beginScene(true, true, video::SColor(255,128,128,128));
switch (state){
case MS_PEMBUKAAN:
if(!loaded){
driver->removeAllTextures();
pembuka(driver,env,butons);
loaded = true;
}
if(butons.size()>0)
if(butons[0]->isPressed()){
loaded = false;
state = MS_MENU;
butons.clear();
}
break;
case MS_MENU:
if(!loaded){
driver->removeAllTextures();
//menu(driver,env,butons);
liat3D(scenemgr,driver,env,butons);
loaded = true;
}
break;
}
driver->setViewPort(rect<s32>(20,20,500,500));
scenemgr->drawAll();
driver->setViewPort(rect<s32>(0,0,800,600));
env->drawAll();
driver->endScene();
}
return 0;
}
below are the code for class liat3D which are called when the case are MS_MENU:
void liat3D(ISceneManager* smgr, IVideoDriver* driver, IGUIEnvironment* &env, array<IGUIButton*> &butons){
env->clear();
butons.push_back(env->addButton(rect<s32>(640,480,780,510),0,-1,L"kucing",L"kucing"));
butons.push_back(env->addButton(rect<s32>(640,540,780,570),0,-1,L"anjing",L"anjing"));
smgr->loadScene("scenes/tipe45.irr"); // i think this is my prob. how2fix????
}