Code: Select all
+++main.cpp+++
#include "main.h"
#include "CMainMenu.h"
int main()
{
CMainMenu m_menu;
m_menu.run();
return 0;
}
+++main.h+++
#ifndef __MAIN_H_INCLUDED__
#define __MAIN_H_INCLUDED__
//#pragma once
#include "include/irrlicht.h"
using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;
static IrrlichtDevice *device =0;
static IVideoDriver *driver = 0;
static ISceneManager* game_scene = 0;
static scene::ISceneManager* menu_scene = 0;
static bool main_menu = true;
static bool game_menu = false;
static bool game = true;
static bool mouse_left_click = false;
static bool mouse_right_click = false;
static s32 mouseX = 0;
static s32 mouseY = 0;
#endif
+++CMainMenu.cpp+++
#include <windows.h>
#include "CMainMenu.h"
#pragma comment(lib, "lib/Irrlicht.lib")
#include <stdio.h>
bool CMainMenu::OnEvent(SEvent event)
{
if(event.EventType == irr::EET_KEY_INPUT_EVENT)
{
if(!event.KeyInput.PressedDown)
{
switch(event.KeyInput.Key)
{
case KEY_ESCAPE:
{
device->closeDevice();
} }
}}
return false;
};
bool CMainMenu::run()
{
device = createDevice(EDT_OPENGL, dimension2d<s32>(1024, 768), 32, false, false, false,this);
device->setResizeAble(true);
driver = device->getVideoDriver();
menu_scene = device->getSceneManager();
while(device->run)
{
driver->beginScene(true, true, SColor(0,0,0,0));
menu_scene->drawAll();
driver->endScene();
}
device->drop();
return true;
}
+++CMainMenu.h+++
#ifndef __C_MAIN_MENU_H_INCLUDED__
#define __C_MAIN_MENU_H_INCLUDED__
#include "main.h"
class CMainMenu : public IEventReceiver
{
public:
bool run();
virtual bool OnEvent(SEvent event);
private:
};
#endif