C++ problem

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
Requiem
Posts: 20
Joined: Fri Mar 02, 2007 10:01 am

C++ problem

Post by Requiem »

when i compile my program I get the following error...

Code: Select all

main.cpp:61: error:   because the following virtual functions are abstract:
C:/irrlicht-1.1/include/IEventReceiver.h:215: error:  virtual bool irr::IEventReceiver::OnEvent(irr::SEvent)
but I don't know where it come from it work perfectly well before I introduce some more variable to parse...
my main looks like that

Code: Select all

#include <irrlicht.h>
#ifdef _IRR_WINDOWS_
#include <windows.h>
#endif

#include <stdio.h>

#include "menu.h"
#include "game.h"

using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;


#ifdef _WIN32


#pragma comment(lib, "Irrlicht.lib")
#pragma comment(lib, "irrKlang.lib")
#pragma comment(lib, "IPhysics.lib")
#pragma comment(lib, "Newton.lib")
INT WINAPI WinMain( HINSTANCE hInst, HINSTANCE, LPSTR strCmdLine, INT )
//int  main( HINSTANCE hInst, HINSTANCE, LPSTR strCmdLine, INT )


#else
int main(int argc, char* argv[])
#endif
{
       s32 resX=640;
       s32 resY=480;
       s32 view=1;
       s32 sound=150;
       E_DRIVER_TYPE driverType; 
       EKEY_CODE acc = KEY_KEY_W;
       EKEY_CODE brake = KEY_KEY_S;
       EKEY_CODE left = KEY_KEY_A;
       EKEY_CODE right = KEY_KEY_D;
       EKEY_CODE hbrake = KEY_SPACE;
       EKEY_CODE gearup = KEY_NUMPAD1  ;
       EKEY_CODE geardown = KEY_NUMPAD2 ;



#ifndef _IRR_WINDOWS_
	 E_DRIVER_TYPE driverType= video::EDT_SOFTWARE2;
#else
	  E_DRIVER_TYPE diverType = video::EDT_DIRECT3D9;
#endif

	Menu menu;
#ifndef _DEBUG
        if (menu.run(driverType,resX,resY,view,sound,acc,brake,left,right,hbrake,gearup,geardown))
 #endif
 {
       
		Game game(driverType,resX,resY,view,sound,acc,brake,left,right,hbrake,gearup,geardown);
		game.run();

	}

	return 0;
}

in my game.cpp

Code: Select all


Game::Game(video::E_DRIVER_TYPE dT, s32 x, s32 y, s32 v, s32 s,EKEY_CODE Acc,
EKEY_CODE Brake,EKEY_CODE Left,EKEY_CODE Right,EKEY_CODE Hand,EKEY_CODE GearUp,
EKEY_CODE GearDown)
:driverType(dT), resX(x),resY(y),view(v),sound(s),KeyAcc(Acc),
KeyBrake(Brake),KeyLeft(Left),KeyRight(Right),KeyHand(Hand),KeyGearUp(GearUp),
KeyGearDown(GearDown)
{
}
and the game.h

Code: Select all

Game(video::E_DRIVER_TYPE driverType, s32 resX, s32 resY,  s32 view,  s32 sound,
     EKEY_CODE KeyAcc,EKEY_CODE KeyBrake,EKEY_CODE KeyLeft,EKEY_CODE KeyRight,
     EKEY_CODE KeyHand,EKEY_CODE KeyGearUp,EKEY_CODE KeyGearDown);

If any one have any ideas what is my problem and what is the solution your ideas are very welcome...[/quote]
Masterhawk
Posts: 299
Joined: Mon Nov 27, 2006 6:52 pm
Location: GERMANY
Contact:

Post by Masterhawk »

Can you show me your EventReceiver? It seems, that you didn't override the OnEvent() function.
Image
Requiem
Posts: 20
Joined: Fri Mar 02, 2007 10:01 am

Post by Requiem »

My event Receiver consists only of these

Code: Select all

bool Game::OnEvent(SEvent event)
{
     if (device != 0 && event.EventType == irr::EET_KEY_INPUT_EVENT)
		//{
			switch(event.KeyInput.Key)
			{
            case KEY_ESCAPE:

                if(status==false && event.KeyInput.PressedDown )
                {
                            window->setVisible(true);
                             but1->setVisible(true);
                            status=true;
                            pause=true;
                            device->getCursorControl()->setVisible(true);
                            device->getTimer()->stop();
                }
                else if(status==true && event.KeyInput.PressedDown ){
                           window->setVisible(false);
                           but1->setVisible(false);
                           status=false;
                           device->getCursorControl()->setVisible(false);
                            pause=false;
                            device->getTimer()->start();
                }
                break;
                return true;
			}//close switch
		return false;
	}
Just to pause the game. But all the key that are parse I have not used it yet in the event receiver
Masterhawk
Posts: 299
Joined: Mon Nov 27, 2006 6:52 pm
Location: GERMANY
Contact:

Post by Masterhawk »

Mh, I don't see any mistakes...damn it....I hate those errors....
Image
Perceval
Posts: 158
Joined: Tue May 30, 2006 2:42 pm

Post by Perceval »

Show the piece of code where you declare and initialise your event receiver. Post all the code if it's possible.
Requiem
Posts: 20
Joined: Fri Mar 02, 2007 10:01 am

Post by Requiem »

Here is the game.cpp fell code

Code: Select all

#include "game.h"
#include "hud.h"
#include "LoadingBar.h"

 IrrlichtDevice* device = 0;
 bool key_W_Down = false;
 bool key_S_Down = false;
 bool key_A_Down = false;
 bool key_D_Down = false;
 bool key_1_Down = false;
 bool key_2_Down=false;
 HUD *hud;
 IGUIWindow* window;
	gui::IGUIButton* but1;
		gui::IGUIStaticText* text; 
IPhysicsCar* car;
SPhysicsCar carData;
bool status=false;
bool pause ;
gui::IGUIEnvironment* guienv;
int gear=0;
float acceleration=0.001f;
float speed=0;
int flag1=0;
int flag2=0;
int flag=0;
video::IVideoDriver* driver;


 //double M_PI =3.14;
 
void chaseCamera(ICameraSceneNode* cam,ISceneNode* camTarget ,float camPan ,float camTilt,float camZoom);
/*
class MyEventReceiver : public IEventReceiver
{

public:
    /*   MyEventReceiver(IPhysicsCar* car)
	{
		m_car = car;
	}
	~MyEventReceiver()
	{
	}
 bool OnEvent(SEvent event)
	{
              if (device != 0 && event.EventType == irr::EET_KEY_INPUT_EVENT)
		{
			switch(event.KeyInput.Key)
			{
             case KEY_ESCAPE:                          
                  printf("Escape has been pressed!!");
                if(status==false && event.KeyInput.PressedDown )
                {
                            window->setVisible(true);
                             but1->setVisible(true);
                            status=true;
                            device->getCursorControl()->setVisible(true);
                                                    }
                else if(status==true && event.KeyInput.PressedDown ){
                           window->setVisible(false);
                           but1->setVisible(false);
                           status=false;
                           device->getCursorControl()->setVisible(false);
                }
             break;   	
			case KEY_UP: 						  
			case KEY_KEY_W:                 
                key_W_Down = event.KeyInput.PressedDown ? true : false;
                m_car->setThrottlePercent(100.0f);
                if(!key_S_Down && !key_W_Down)
                               m_car->setThrottlePercent(0.0f);
                break;
  			
            case KEY_DOWN:    
			case KEY_KEY_S:
                key_S_Down = event.KeyInput.PressedDown ? true : false;
                m_car->setThrottlePercent(-100.0f);
                if(!key_S_Down && !key_W_Down)
                               m_car->setThrottlePercent(0.0f);
                break;  			
            
            case KEY_LEFT:
            case KEY_KEY_A:
                key_A_Down = event.KeyInput.PressedDown ? true : false;
                m_car->setSteeringPercent(-100.0f);
                if(!key_D_Down && ! key_A_Down)
                               m_car->setSteeringPercent(0.0f);
                break;     
                
            case KEY_RIGHT:    
            case KEY_KEY_D:
                key_D_Down = event.KeyInput.PressedDown ? true : false;
                m_car->setSteeringPercent(100.0f);
                if(!key_D_Down && ! key_A_Down)
                               m_car->setSteeringPercent(0.0f);
                break;  
       
                 
            case KEY_NUMPAD2:
            case KEY_KEY_2:      
                 if(flag2==0 && event.KeyInput.PressedDown== true)
                 {                             
                            key_2_Down=true;
                            gear-=1;
                            flag2=1;
  
                 }
                 else 
                      if(flag2==1 && event.KeyInput.PressedDown==false)
                      {
                            key_2_Down=false;
                            flag2=0;
                      }
               //  Key_2_Down = event.KeyInput.PressedDown ? true:false;
                 break;
                   
            case KEY_NUMPAD1:
            case KEY_KEY_1:    
                 
                 if (flag1==0 && event.KeyInput.PressedDown==true)
                 {    
                                  gear+=1;              
                                  flag1=1;
                                  key_1_Down=true;
     
                 }
                 else if(flag1==1 && event.KeyInput.PressedDown==false)
                 {
                      key_1_Down=false;
                      flag1=0;
                 }
                 
            break; 
            return true;
            }

    }
		return false;
	}
protected:
	IPhysicsCar* m_car;
	bool m_keys[KEY_KEY_CODES_COUNT];
    */   
/*	virtual bool OnEvent(SEvent event)
	{
   //  if (device != 0 && event.EventType == irr::EET_KEY_INPUT_EVENT)
		//{
			switch(event.KeyInput.Key)
			{
            case KEY_ESCAPE:

                if(status==false && event.KeyInput.PressedDown )
                {
                            window->setVisible(true);
                             but1->setVisible(true);
                            status=true;
                            pause=true;
                            device->getCursorControl()->setVisible(true);
                            device->getTimer()->stop();
                }
                else if(status==true && event.KeyInput.PressedDown ){
                           window->setVisible(false);
                           but1->setVisible(false);
                           status=false;
                           device->getCursorControl()->setVisible(false);
                            pause=false;
                            device->getTimer()->start();
                }
                break;
		/*
		If the key 'W' or 'S' was left up, we get the position of the scene node,
		and modify the Y coordinate a little bit. So if you press 'W', the node
		moves up, and if you press 'S' it moves down.
		*/
		/*
		if (event.KeyInput.Key == KEY_ESCAPE)
			{
				device->getLogger()->log("Ending program", ELL_INFORMATION);
				device->closeDevice();
				return true;
			
			}// esc key handling
        */
	/*
			case KEY_UP: 						  
			case KEY_KEY_W:                 
                key_W_Down = event.KeyInput.PressedDown ? true : false;
                break;
  			
            case KEY_DOWN:    
			case KEY_KEY_S:
                key_S_Down = event.KeyInput.PressedDown ? true : false;
                break;  			
            
            case KEY_LEFT:
            case KEY_KEY_A:
                key_A_Down = event.KeyInput.PressedDown ? true : false;
                break;     
                
            case KEY_RIGHT:    
            case KEY_KEY_D:
                key_D_Down = event.KeyInput.PressedDown ? true : false;
                break;  
                 
            case KEY_NUMPAD2:
            case KEY_KEY_2:      
                 if(flag2==0 && event.KeyInput.PressedDown== true)
                 {                             
                            key_2_Down=true;
                            gear-=1;
                            flag2=1;
  
                 }
                 else 
                      if(flag2==1 && event.KeyInput.PressedDown==false)
                      {
                            key_2_Down=false;
                            flag2=0;
                      }
               //  Key_2_Down = event.KeyInput.PressedDown ? true:false;
                 break;
                   
            case KEY_NUMPAD1:
            case KEY_KEY_1:    
                 
                 if (flag1==0 && event.KeyInput.PressedDown==true)
                 {    
                                  gear+=1;              
                                  flag1=1;
                                  key_1_Down=true;
     
                 }
                 else if(flag1==1 && event.KeyInput.PressedDown==false)
                 {
                      key_1_Down=false;
                      flag1=0;
                 }
                 
            break; 
            return true;
			}//close switch
		return false;
	}
};
*/
//MyEventReceiver receiver(car);
//device->setEventReceiver(&receiver);

//MyEventReceiver receiver;


Game::Game(video::E_DRIVER_TYPE dT, s32 x, s32 y, s32 v, s32 s,EKEY_CODE Acc,
EKEY_CODE Brake,EKEY_CODE Left,EKEY_CODE Right,EKEY_CODE Hand,EKEY_CODE GearUp,
EKEY_CODE GearDown)
:driverType(dT), resX(x),resY(y),view(v),sound(s),KeyAcc(Acc),
KeyBrake(Brake),KeyLeft(Left),KeyRight(Right),KeyHand(Hand),KeyGearUp(GearUp),
KeyGearDown(GearDown)
{
}

Game::~Game(){
              selector->drop();
              }


bool Game::OnEvent(SEvent event)
{
    if (device != 0 && event.EventType == irr::EET_KEY_INPUT_EVENT)
		{
			switch(event.KeyInput.Key)
			{
            case KEY_ESCAPE:

                if(status==false && event.KeyInput.PressedDown )
                {
                            window->setVisible(true);
                             but1->setVisible(true);
                            status=true;
                            pause=true;
                            device->getCursorControl()->setVisible(true);
                            device->getTimer()->stop();
                }
                else if(status==true && event.KeyInput.PressedDown ){
                           window->setVisible(false);
                           but1->setVisible(false);
                           status=false;
                           device->getCursorControl()->setVisible(false);
                            pause=false;
                            device->getTimer()->start();
                }
                break;
                return true;
			}//close switch
		return false;
	}
}

 

bool  Game::init()
{
       CLoadingBar* LoadBar;
       LoadBar = new CLoadingBar(device,rect<s32>(0,250,800,300),true,7);
       device->setWindowCaption(L"3D Driving Simulator");
       LoadBar->setPercent(5);
       LoadBar->draw();

       guienv = device->getGUIEnvironment();
       
       
     
	   /*txt=guienv->addStaticText(L"",
       rect<int>(10,10,640,100), true);*/
       driver = device->getVideoDriver();
	   smgr = device->getSceneManager();
	   gui::IGUIFont* font = guienv->getFont("media/font.bmp");
       if (font)
	     guienv->getSkin()->setFont(font);

       device->getGUIEnvironment()->addImage(device->getVideoDriver()->getTexture("media/speed2.tga"),
                                             core::position2d<s32>(540,390));
       LoadBar->setPercent(15);
       LoadBar->draw();
	  	// create skybox
       driver->setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS, false);
      // IGUIElement *  Parent = wht;
       window=guienv->addWindow(
       rect<s32>(100, 100 , 700, 500),
       false, // modal?
       L"Pause" ,0,2);

       window->setVisible(false);

       but1=guienv->addButton(core::rect<int>(135,150,250,300),0,1,L"Button");
       but1->setVisible(false);

	   smgr->addSkyBoxSceneNode(
		                       driver->getTexture("media/Skybox/up.jpg"),
		                       driver->getTexture("media/Skybox/dn.jpg"),
		                       driver->getTexture("media/Skybox/lf.jpg"),
		                       driver->getTexture("media/Skybox/rt.jpg"),
		                       driver->getTexture("media/Skybox/ft.jpg"),
		                       driver->getTexture("media/Skybox/bk.jpg"));

      driver->setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS, true);
      //  device->getGUIEnvironment()->addImage(device->getVideoDriver()->getTexture("media/irrlichtlogoalpha2.tga"),
	  //	core::position2d<s32>(5,5));
      //device->getGUIEnvironment()->addImage(device->getVideoDriver()->getTexture("media/labelView.tga"),
	  //	core::position2d<s32>(5,5));
      //CPhysics physics;
      //	physics.init(device->getTimer());
	// start iphysics
	CPhysics physics;
	physics.init(device->getTimer());

	// create the car data
	

	carData.carBodyOffset = vector3df(0.0f, 10.0f, 0);
	carData.carBodySize = vector3df(0.05f, 0.05f, 0.05f);
	carData.carMass = 1000.0f;
	carData.frontAxleOffset = 1.3f;
	carData.rearAxleOffset = 1.15f;
	carData.axleWidth = 1.9f;
	carData.tireMass = 10.0f;
	carData.tireRadius = 0.3f;
	carData.tireWidth = 0.15f;
	carData.maxSteerAngle = 0.6f;
	carData.maxTorque = 1000.0f;
	carData.maxBrakes = 50.0f;
	carData.tireSuspensionLength = 0.2f;
	carData.tireSuspensionSpring = (carData.tireMass * 1.0f * 9.8f) / carData.tireSuspensionLength; 
	carData.tireSuspensionShock = sqrt(carData.tireSuspensionSpring) * 1.0f;

	IAnimatedMesh* carBody1 = smgr->getMesh("media/Delorean_3DS/de.3ds");
	
	car21=smgr->addAnimatedMeshSceneNode(carBody1);
    car21->setRotation(core::vector3df(0,-90.0f,0));
    car21->setPosition(core::vector3df(100.0f,0.0f,0));
    
//	IAnimatedMeshSceneNode* carNode1 = smgr->addAnimatedMeshSceneNode(levelmesh);
	carData.carBodyNode = car21;
	carData.carBodyNode->setScale(carData.carBodySize);
	carData.carBodyNode->setRotation(core::vector3df(0,0.0f,0));
    
    carData.tireNode_FL = smgr->addSphereSceneNode(1.0f);
	carData.tireNode_FL->setScale(vector3df(carData.tireRadius, carData.tireRadius, carData.tireWidth));

	carData.tireNode_FR = smgr->addSphereSceneNode(1.0f);
	carData.tireNode_FR->setScale(vector3df(carData.tireRadius, carData.tireRadius, carData.tireWidth));

	carData.tireNode_RL = smgr->addSphereSceneNode(1.2f);
	carData.tireNode_RL->setScale(vector3df(carData.tireRadius, carData.tireRadius, carData.tireWidth));

	carData.tireNode_RR = smgr->addSphereSceneNode(1.2f);
	carData.tireNode_RR->setScale(vector3df(carData.tireRadius, carData.tireRadius, carData.tireWidth));
/*
 	IAnimatedMesh* tire_FL = smgr->getMesh("../../media/Delorean_3DS/wheel.3ds");
	carData.tireNode_FL = smgr->addAnimatedMeshSceneNode(tire_FL);
	carData.tireNode_FL->setScale(vector3df(carData.tireRadius, carData.tireRadius, carData.tireWidth));
	
    IAnimatedMesh* tire_FR = smgr->getMesh("../../media/Delorean_3DS/wheel.3ds");
	carData.tireNode_FR = smgr->addAnimatedMeshSceneNode(tire_FR);
	carData.tireNode_FR->setScale(vector3df(carData.tireRadius, carData.tireRadius, carData.tireWidth));
	
    IAnimatedMesh* tire_RL = smgr->getMesh("../../media/Delorean_3DS/wheel.3ds");
	carData.tireNode_RL = smgr->addAnimatedMeshSceneNode(tire_RL);
	carData.tireNode_RL->setScale(vector3df(carData.tireRadius, carData.tireRadius, carData.tireWidth));
	
    IAnimatedMesh* tire_RR = smgr->getMesh("../../media/Delorean_3DS/wheel.3ds");
	carData.tireNode_RR = smgr->addAnimatedMeshSceneNode(tire_RR);
	carData.tireNode_RR->setScale(vector3df(carData.tireRadius, carData.tireRadius, carData.tireWidth));
*/


	car = physics.addCar(&carData);
	

	// create our custom event receiver, pass a pointer to the car
	//MyEventReceiver receiver(car);
//	device->setEventReceiver(&receiver);	

//	IAnimatedMesh* levelmesh = smgr->getMesh("media/townDS.obj");
//	IAnimatedMeshSceneNode* levelnode = smgr->addAnimatedMeshSceneNode(levelmesh);
	vector3df positionCar;
	positionCar.X=((carData.tireNode_RR->getPosition().X)+(carData.tireNode_RL->getPosition().X))/2;
    positionCar.Z=((carData.tireNode_RR->getPosition().Z)+(carData.tireNode_RL->getPosition().Z))/2;
	IAnimatedMesh* h = smgr->getMesh("media/rec.3ds");	
	IAnimatedMeshSceneNode* node= smgr->addAnimatedMeshSceneNode(h);
    node->setPosition(positionCar);

	
                               
      LoadBar->setPercent(25);
      LoadBar->draw();
      /*
      car = smgr->addAnimatedMeshSceneNode(smgr->getMesh("media/yugo/yugo45.obj"));
      car->setMaterialTexture(0, driver->getTexture("media/yugo/texture.jpg"));
      car->setMaterialFlag(video::EMF_LIGHTING, true);
      car->setPosition(core::vector3df(0.0f,0.7f,10.0f));
      car->setScale(core::vector3df(0.8,0.8,0.8));
      car->setRotation(core::vector3df(0,270.0f,0));
*/
      smgr->loadScene("media/testtown.irr");
printf("teststs1\n");
      scene_node = smgr->getSceneNodeFromName("city");
printf("teststs2\n");
      LoadBar->setPercent(40);
      LoadBar->draw();
printf("teststs3\n");
      if(scene_node->getType()==ESNT_MESH)
      {
          IAttributes* attribs = device->getFileSystem()->createEmptyAttributes();
printf("teststs4\n");
          if (attribs)
          {
                  LoadBar->setPercent(50);
                  LoadBar->draw();
                  scene_node->serializeAttributes(attribs);
                  // get the mesh name out
                  core::stringc mesh_name = attribs->getAttributeAsString("Mesh");
                  const c8 *meshName = mesh_name.c_str();
printf("teststs5\n");
                  attribs->drop();
printf("teststs6\n");
                  LoadBar->setPercent(60);
                  LoadBar->draw();
printf("teststs7\n");
                  // get a mesh from the name
                  IAnimatedMesh* mesh = smgr->getMesh(meshName);
                  IAnimatedMeshSceneNode* levelnode = smgr->addAnimatedMeshSceneNode(mesh);
printf("teststs8\n");
                  ITriangleSelector* selector =0;
                  /* smgr->createOctTreeTriangleSelector(mesh->getMesh(0), scene_node, 128);
                  scene_node->setTriangleSelector(selector);
*/printf("teststs9\n");
                  LoadBar->setPercent(70);
                  LoadBar->draw();
printf("teststs10\n");
                  camera = smgr->addCameraSceneNode();
                  //camera->setPosition(core::vector3df(0,40,0));
                  //camera->setrotation(core::vector3df(-30,0.0f,0));
printf("teststs11\n");
                  LoadBar->setPercent(80);
                  LoadBar->draw();
                  SPhysicsStaticMesh level;
            	  level.mesh = mesh;
            	  level.meshnode = levelnode;
            	  level.meshScale = vector3df(0.1f, 0.1f, 0.1f);
            	  level.meshnode->setScale(level.meshScale);
            printf("teststs12\n");
            	IPhysicsEntity* levelEntity = physics.addEntity(&level);
            	printf("teststs13\n");
            	selector = smgr->createOctTreeTriangleSelector(mesh->getMesh(0), levelnode, 128);
            	levelnode->setTriangleSelector(selector);
                scene::ISceneNodeAnimator* anim = smgr->createCollisionResponseAnimator(
                                           selector, carData.carBodyNode, core::vector3df(15,15,15),
                                           core::vector3df(0,0,0));
                     printf("teststs14\n");          /*

                  scene::ISceneNodeAnimator* anim = smgr->createCollisionResponseAnimator(
                                                          selector, car, core::vector3df(15,15,15),
                                                          core::vector3df(0,0,0));
                  car->addAnimator(anim);
                  anim->drop();

                  selector->drop();*/
          }
      }


      LoadBar->setPercent(80);
      LoadBar->draw();
      // add a user controlled camera

      //camera = smgr->addCameraSceneNode();
      //scene::ICameraSceneNode* camera = smgr->addCameraSceneNodeFPS(0, 100.0f, 100.0f);
     // camera->setPosition(core::vector3df(150.0f,2.0f,210.0f));
	 // device->getCursorControl()->setVisible(false);
	 // camera->setFOV(1.75f);
   	 // camera->setInputReceiverEnabled(false);
	 // camera->setFarValue(400.0f);
	 // camera->setIsOrthogonal(false);
///
      //attachCamera(car,camera,core::vector3df(100,25,0));
	  // and draw everything.
	  //gui::IGUIStaticText* txt;
      str = L"Speed: ";
	  str+= speed;
	  hud = new HUD(device, speed, gear, driver);

    //  v = car->getPosition();
    //  w = car->getRotation();
      image= device->getGUIEnvironment()->addImage(device->getVideoDriver()->getTexture("media/changeNotGear2.tga"),
    core::position2d<s32>(250,250));
    image->setVisible(false);
    //Image that user should change the gear
    image_gearChange= device->getGUIEnvironment()->addImage(device->getVideoDriver()->getTexture("media/ChangeGear1.tga"),
    core::position2d<s32>(150,250));
    image_gearChange->setVisible(false);
    //Image Speed is not enough to change gear
    image_lackSpeed= device->getGUIEnvironment()->addImage(device->getVideoDriver()->getTexture("media/ChangeGear2.tga"),
    core::position2d<s32>(250,150));
    image_lackSpeed->setVisible(false);
    //Image going too fast
    image_fast= device->getGUIEnvironment()->addImage(device->getVideoDriver()->getTexture("media/DrivingToFast.tga" ),
    core::position2d<s32>(250,250));
    image_fast->setVisible(false);
    //Already in reverse gear
    image_reverse= device->getGUIEnvironment()->addImage(device->getVideoDriver()->getTexture("media/ChangeGear1.tga"),
    core::position2d<s32>(250,250));
    image_reverse->setVisible(false);
    //Speed is too much to change to gear 1
    image_gear2_1= device->getGUIEnvironment()->addImage(device->getVideoDriver()->getTexture("media/ChangeGear1.tga"),
    core::position2d<s32>(100,250));
    image_gear2_1->setVisible(false);
    //Should not change lane
    image_change_lane= device->getGUIEnvironment()->addImage(device->getVideoDriver()->getTexture("media/ChangeLane.tga"),
    core::position2d<s32>(250,250));
    image_change_lane->setVisible(false);
    //Image Must change gear to increase speed
    image_change_gear= device->getGUIEnvironment()->addImage(device->getVideoDriver()->getTexture("media/canChangeGear1.tga"),
    core::position2d<s32>(250,250));
    image_change_gear->setVisible(false);
      LoadBar->setPercent(100);
      LoadBar->draw();
      LoadBar->setVisible(false);
      pause=false;
      return true;

}


bool Game::run()
{
     
	device =createDevice(video::EDT_SOFTWARE2,
                         core::dimension2d<s32>(800,600),
		                 16,false, false, false);

//	init();
//fdpsfojdsoifgkll jfopdu nw0ujvouewm9ruipe klckmdnslv fl
 device->setWindowCaption(L"3D Driving Simulator");
       
       guienv = device->getGUIEnvironment();
       
       
     
	   /*txt=guienv->addStaticText(L"",
       rect<int>(10,10,640,100), true);*/
       driver = device->getVideoDriver();
	   smgr = device->getSceneManager();
	   gui::IGUIFont* font = guienv->getFont("media/font.bmp");
       if (font)
	     guienv->getSkin()->setFont(font);

       device->getGUIEnvironment()->addImage(device->getVideoDriver()->getTexture("media/speed2.tga"),
                                             core::position2d<s32>(540,390));
     
	  	// create skybox
       driver->setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS, false);
      // IGUIElement *  Parent = wht;
       window=guienv->addWindow(
       rect<s32>(100, 100 , 700, 500),
       false, // modal?
       L"Pause" ,0,2);

       window->setVisible(false);

       but1=guienv->addButton(core::rect<int>(135,150,250,300),0,1,L"Button");
       but1->setVisible(false);

	   smgr->addSkyBoxSceneNode(
		                       driver->getTexture("media/Skybox/up.jpg"),
		                       driver->getTexture("media/Skybox/dn.jpg"),
		                       driver->getTexture("media/Skybox/lf.jpg"),
		                       driver->getTexture("media/Skybox/rt.jpg"),
		                       driver->getTexture("media/Skybox/ft.jpg"),
		                       driver->getTexture("media/Skybox/bk.jpg"));

      driver->setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS, true);
      
      //hdksahdkhsakdskaldksandksankjfkdsnfkdhsifisdlfksdfsoijklgvs

u32 time;
int disp;
device->getTimer()->setTime(0);
printf("Key Acc" +KeyAcc );
printf("\n Resolution" +resX);
printf("\n");
printf("\n");

    while(device->run())
    {
       driver->beginScene(true, true, 0);
       // camera->setTarget(car->getPosition());
       time=device->getTimer()->getTime();


  /*      if(v.X<265)
        {
                   if(speed>10.0f)
                   {
                                  txt=guienv->addStaticText(L"You are driving too fast!!!!!!!!!!!!!!!!!!!11!!",
		                          rect<int>(10,10,640,100), true);
                   }
        }



        if(v.X<=546 &&  v.Z<=70 && v.Z>=30)
        {
                   if(speed>=0)
                   {
                                  txt=guienv->addStaticText(L"You failed!!",
		                          rect<int>(10,10,640,100), true);
                   }
        }


*/



  //      driver->beginScene(true, true, video::SColor(0,200,200,200));
  if(!pause){
            // chaseCamera(camera,carData.carBodyNode,90,-25,50);
        //returnCollision();

        


        device->setWindowCaption(str.c_str());
        updatePosition();
        str = L"Speed: ";
        str += int(speed);
        str += L"  Gear:";
        str += gear;
       
 smgr->drawAll();
 
 str2 = " Time : ";
			disp=int(time)/1000;
			
            if (disp<10)
			{str2 +="0";
            str2 +=disp;}
			else
			str2+=disp;
  if(text)
    text->remove();         
        	//text = guienv->addStaticText(str2,core::rect<s32>(250,250,650,350));
  text = guienv->addStaticText(
		str2.c_str(),
		core::rect<s32>(10,453,200,475), false, false, 0, -1, true);
                
			device->setWindowCaption(str.c_str());
			
			
         //       driver->beginScene(true, true, video::SColor(0,200,200,200));
          

}

        //device->getGUIEnvironment()->addImage(device->getVideoDriver()->getTexture("media/labelView.tga"),
		//core::position2d<s32>(5,5));
         
            // hud->drawHUD();
            guienv->drawAll();
		    driver->endScene();
		//physics.update();
        }

	device->drop();

	return 0;
}

void chaseCamera(ICameraSceneNode* cam,ISceneNode* camTarget ,float camPan ,float camTilt,float camZoom)
{
		vector3df CPosVector;
		vector3df NewCamLocation;
		vector3df Target1;

		//camPan==0 places camera behind Model "farie" camPan range 0-360
		//camTilt inputs should be between -89 and +89

		CPosVector.X=cos((camPan+180)*PI/180)*sin((camTilt+90)*PI/180);
		CPosVector.Y=cos((camTilt+90)*PI/180);
		CPosVector.Z=sin((camPan+180)*PI/180)*sin((camTilt+90)*PI/180);

		matrix4 m2;
		m2.setRotationDegrees(camTarget->getRotation());
		m2.transformVect(CPosVector);

		//all i know is that the vector transformation somehow gives a vector which you can multiply by a zoom value

		Target1=camTarget->getPosition();
		NewCamLocation.X=Target1.X+CPosVector.X*camZoom;
		NewCamLocation.Y=Target1.Y+CPosVector.Y*camZoom;
		NewCamLocation.Z=Target1.Z+CPosVector.Z*camZoom;

		cam->setPosition(NewCamLocation);
		cam->setUpVector(vector3df(0,1,0));
		cam->setTarget(vector3df(Target1));
		cam->updateAbsolutePosition();

		//TODO: IF Camera Distance == CLOSE then make model semi transparent
		//if(camZoom<10){
		//   {
}
void Game::returnCollision(){

		line.start = car->getPosition();

		line.end = line.start + (camera->getTarget() - line.start).normalize() * 10.0f;

		core::vector3df intersection;
		core::triangle3df tri;

		if (smgr->getSceneCollisionManager()->getCollisionPoint(
			line, selector, intersection, tri))
		{
            gui::IGUIStaticText* text3=guienv->addStaticText(
                     L"                                                        You failed. you have collided with something",
                     core::rect<int>(10,10,640,100),true);

		}

 }
 /*
void Game::createCarPhysics()
{
     CPhysics physics;
	physics.init(device->getTimer());

	// create the car data
	SPhysicsCar carData;

carData.carBodyOffset = vector3df(0, 0.0f, 0);
	carData.carBodySize = vector3df(1.2f, 0.5f, 0.2f);
	carData.carMass = 500.0f;
	carData.frontAxleOffset = 0.6f;
	carData.rearAxleOffset = 0.6f;
	carData.axleWidth = 0.8f;
	carData.tireMass = 20.0f;
	carData.tireRadius = 0.3f;
	carData.tireWidth = 0.2f;
	carData.maxSteerAngle = 0.6f;
	carData.maxTorque = 1000.0f;
	carData.maxBrakes = 50.0f;

	carData.tireSuspensionLength = 0.2f;
	carData.tireSuspensionSpring = (carData.tireMass * 1.0f * 9.8f) / carData.tireSuspensionLength;
	carData.tireSuspensionShock = sqrt(carData.tireSuspensionSpring) * 1.0f;

	carData.carBodyNode = smgr->addCubeSceneNode(1.0f);
	carData.carBodyNode->setScale(carData.carBodySize);

	carData.tireNode_FL = smgr->addSphereSceneNode(1.0f);
	carData.tireNode_FL->setScale(vector3df(carData.tireRadius, carData.tireRadius, carData.tireWidth));

	carData.tireNode_FR = smgr->addSphereSceneNode(1.0f);
	carData.tireNode_FR->setScale(vector3df(carData.tireRadius, carData.tireRadius, carData.tireWidth));

	carData.tireNode_RL = smgr->addSphereSceneNode(1.0f);
	carData.tireNode_RL->setScale(vector3df(carData.tireRadius, carData.tireRadius, carData.tireWidth));

	carData.tireNode_RR = smgr->addSphereSceneNode(1.0f);
	carData.tireNode_RR->setScale(vector3df(carData.tireRadius, carData.tireRadius, carData.tireWidth));
	 car = physics.addCar(&carData);

// chaseCamera(camera,carData.carBodyNode,90,-25,50);
	// create our custom event receiver, pass a pointer to the car
	MyEventReceiver receiver(car);
	device->setEventReceiver(&receiver);

	//IAnimatedMesh* levelmesh = smgr->getMesh("../../media/blockland2.obj");
	//IAnimatedMeshSceneNode* levelnode = smgr->addAnimatedMeshSceneNode(levelmesh);

//SPhysicsStaticMesh level;
//	level.mesh = levelmesh;
//	level.meshnode = levelnode;
////	level.meshScale = vector3df(0.1f, 0.1f, 0.1f);
//	level.meshnode->setScale(level.meshScale);

//	IPhysicsEntity* levelEntity = physics.addEntity(&level);
 } */
void Game::updatePosition()
{/*
v = car->getPosition();
w = car->getRotation();

       if(v.X>60 && v.Z>0 && v.Z<1000)
        {
               image_change_lane->setVisible(true);   
        }
        else if(v.X<60 && v.Z>0 && v.Z<1000)
        {    
               image_change_lane->setVisible(false);
        }
        
        if(key_1_Down){
              
            if(gear>=3){
               //gear=2;
                        
    	      // gui::IGUIStaticText* text2 = env->addStaticText(
       	      // L"You are already in gear 5",
      		  // core::rect<s32>(250,150,360,200));
      		  image->setVisible(true);

            }
            else if(gear<3)
                      image->setVisible(false);
            if(gear>=-1)
                      image_reverse->setVisible(false);            
        } //close key_1_Down
        
        if(key_2_Down){
            if(gear<3)
                      image->setVisible(false);           
            if(gear<-1){
                 gear=-1;
                 image_reverse->setVisible(true);
            }
            else
                 image_reverse->setVisible(false);
                 
            
        }//close key_2_down
        
        //if the gear has increased from reverse to 0 
        if(gear==0 && flag==1){
              flag=0;     
              if(speed>1){           
                    speed=speed-(speed/3.82);
                    v.Z-=speed*cos (w.Y/180*M_PI);
                    v.X-=speed*sin(w.Y/180*M_PI);
                    car->setPosition(v);
              }
              else{//speed<=1
                    speed=0;
                    car->setPosition(v);
              } 
        }//close if statement for gear==0 && flag==1
        
        //if gear has changed form 1 to 0
        if(gear==0 && flag==2){
              flag=0;     
              if(speed>1){           
                   speed=speed-(speed/3.82);
                   v.Z+=speed*cos (w.Y/180*M_PI);
                   v.X+=speed*sin(w.Y/180*M_PI);
                   car->setPosition(v);
              }
              else{//speed<=1
                   speed=0;
                   car->setPosition(v);
              } 
        }//close if statement for gear==0 && flag==2  
    
                     
        //When the gear is in reverse 
        if(gear==-1){
                //when the user has stopped pressing key "S" the
                //car will continue moving constantly at the 
                //previous speed      
                if(!(speed<=0)){
                        v.Z-=speed*cos (w.Y/180*M_PI);
                        v.X-=speed*sin(w.Y/180*M_PI);
                        car->setPosition(v);
                }          
                if(key_S_Down){
                        if(speed<=25.0){       
                               speed+=acceleration;
                               v.Z-=speed*cos(w.Y/180*M_PI);
                               v.X-=speed*sin(w.Y/180*M_PI);
                               car->setPosition(v);
                        }
                        //the car cannot move at a speed greater that
                        //25 when it is in reverse gear
                        else{
                               v.Z-=speed*cos(w.Y/180*M_PI);
                               v.X-=speed*sin(w.Y/180*M_PI);
                               car->setPosition(v);
                        }
                }//close if statement for key_S_Down
                // When the key "A" is pressed the car will turn to the 
                //move backward to the left
                if(key_A_Down){
                        if(speed<=25.0f){
                               speed+=acceleration;
                               w.Y+= 0.1f;
                               v.Z-=((speed*sin(w.Y/180*M_PI))/3)*cos(w.Y/180*M_PI);
                               v.X-=((speed*sin(w.Y/180*M_PI))/3)*sin(w.Y/180*M_PI);
                               car->setRotation(w);
                               car->setPosition(v);  
                        }
                        else{
                               w.Y+= 5.0f;
                               v.Z-=((speed*sin(w.Y/180*M_PI))/3)*cos(w.Y/180*M_PI);
                               v.X-=((speed*sin(w.Y/180*M_PI))/3)*sin(w.Y/180*M_PI);
                               car->setRotation(w);
                               car->setPosition(v);
                        }
                }//close if statement for key_A_Down
                // When the key "D" is pressed the car will turn to the 
                //move backward to the right
                if(key_D_Down){
                        if(speed<=25.0f){
                               speed+=acceleration;
                               w.Y-= 0.1f;
                               v.Z-=((speed*sin(w.Y/180*M_PI))/3)*cos(w.Y/180*M_PI);
                               v.X-=((speed*sin(w.Y/180*M_PI))/3)*sin(w.Y/180*M_PI);
                               car->setRotation(w);
                               car->setPosition(v);  
                        }
                        else{
                               w.Y-= 5.0f;
                               v.Z-=((speed*sin(w.Y/180*M_PI))/3)*cos(w.Y/180*M_PI);
                               v.X-=((speed*sin(w.Y/180*M_PI))/3)*sin(w.Y/180*M_PI);
                               car->setRotation(w);
                               car->setPosition(v);
                        }
                }//close if statement for key_D_Down
                
                //when the key "W" is pressed this will act as a 
                //break to stop the car from moving backwards
                if(key_W_Down){
                        if(speed>1){           
                               speed=speed-(speed/3.82);
                               v.Z-=speed*cos (w.Y/180*M_PI);
                               v.X-=speed*sin(w.Y/180*M_PI);
                               car->setPosition(v);
                        }
                        else{//speed<=1
                               speed=0;
                               car->setPosition(v);
                        }         
                }//close if statement for key_w_Down
        }//close if statement for gear=-1
                

        //When the car is in gear 1                              
        if(gear==1){
			if(!(speed<=0)){
                         v.Z+=speed*cos (w.Y/180*M_PI);
                         v.X+=speed*sin(w.Y/180*M_PI);       
                         car->setPosition(v); 
            } 		
            if(speed<25){
                         image_gearChange->setVisible(false);
            }
            if(speed>25 && speed<30){
                         image_gearChange->setVisible(true); 
		    }
            if(speed>30){
				 		 //display image speed too fast to change to gear 1	                     
		    }
             
            //When the car is accelerating                         
            if ( key_W_Down ){ 
                if(speed < 30){ 
                 	         
                   speed+=(acceleration);
                   v.Z+=speed*cos (w.Y/180*M_PI);
                   v.X+=speed*sin(w.Y/180*M_PI);       
                   car->setPosition(v);
                   
                   if(speed >= 25 && speed < 30)
                               image_gearChange->setVisible(true);
                }
                /*30 is the maximum speed that the car is allowed to travel
                  in gear 1. The user will have to change the gear to gear 
                  2 to be able to increase the speed*/
              /*  else{
					 /*Should also display a warning message as this is an error*/
                   /*  image_gearChange->setVisible(false);
                     image_change_gear->setVisible(true);
                     v.Z+=speed*cos(w.Y/180*M_PI);
                     v.X+=speed*sin(w.Y/180*M_PI);
                     car->setPosition(v);
                 }
            }//close if statement for Key_W_Down
            */
           /* */
            //When the user press the brake
        /*    if(key_S_Down){
                if(speed>1){           
                     speed=speed-(acceleration);
                     v.Z+=speed*cos (w.Y/180*M_PI);
                     v.X+=speed*sin(w.Y/180*M_PI);                      
                     car->setPosition(v);
                     
                     if(speed<=25){
                               image_gearChange->setVisible(false);
			         }          
                     if(speed>25 && speed<30){
					  		   //image that user should change gear	 
					 		   image_gearChange->setVisible(true);
					 		   //image that user must change gear to increase speed
					 		   image_change_gear->setVisible(false); 
				     }					 		   	 			            
                }
                else{//speed<=1
               
                     speed=0;
                     car->setPosition(v);
                }         
            }//close if statement for key_S_Down
                  */    
            /*To calculate displacement the length of the car needs to be known.
              We will assume the length of the car to be 3.0f i.e 3 meters. The
              displacement of a car when it is making a turn is:
              (speed*angleTurn)/length of car */
         /*   if ( key_A_Down && speed!=0){
                 w.Y-= 5.0f;
                 v.Z+=((speed*sin(w.Y/180*M_PI))/3)*cos(w.Y/180*M_PI);
                 v.X+=((speed*sin(w.Y/180*M_PI))/3)*sin(w.Y/180*M_PI);
                 car->setRotation(w);
                 car->setPosition(v);
            }
            
            if ( key_D_Down && speed!=0){
                 w.Y+=5.0f;
                 v.Z+=((speed*sin(w.Y/180*M_PI))/3)*cos(w.Y/180*M_PI);
                 v.X+=((speed*sin(w.Y/180*M_PI))/3)*sin(w.Y/180*M_PI);
                 car->setRotation(w);
                 car->setPosition(v);
            }

        }//close if statement for gear==1
        */
        
         /*When the car is in gear 2*/                              
     /*   if(gear==2){
			if(speed>=25 && speed <=30){
						 image_gearChange->setVisible(false);
						 image_change_gear->setVisible(false);
						 v.Z+=speed*cos(w.Y/180*M_PI);
                     	 v.X+=speed*sin(w.Y/180*M_PI);
                     	 car->setPosition(v);
		    }
			else if(speed<25){
				 		 //Display image speed not enough to change to gear 2
						 // 
		    }	 */		
            /*When the car is accelerating*/                         
           /* if ( key_W_Down ){ 
			   	//The user has already change to gear 2 
			   	if(speed>=25){ 
			    			  image_gearChange->setVisible(false);
	            }*/
			    //The car can continue accelerating till a maximum speed
				//of 60 for gear 2			  
               /* if(speed<=60){
				   // The user can change to gear 3
				   // The maximum speed allowed for a driving test is 50			  
				   if(speed>50)
                               image_gearChange->setVisible(true);								  			   		         
                   speed+=(acceleration);
                   v.Y=0;
                   v.Z+=speed*cos (w.Y/180*M_PI);
                   v.X+=speed*sin(w.Y/180*M_PI);       
                   car->setPosition(v);
                }*/
                /*60 is the maximum speed that the car is allowed to travel
                  in gear 2. The user will have to change the gear to gear 
                  3 to be able to increase the speed*/
               /* else{
                    /* gui::IGUIStaticText* text3=env->addStaticText(
                     L"You should change the gear to 2",
                     core::rect<s32>(250,150,360,200),true, true,0,1,true);
                   */
                 /*    v.Z+=speed*cos(w.Y/180*M_PI);
                     v.X+=speed*sin(w.Y/180*M_PI);
                     car->setPosition(v);
                 }
            }
            *///close if statement for Key_W_Down
            /*When the user press the brake*/
         /*   if(key_S_Down){
                if(speed>=25){           
                     speed=speed-(acceleration);
                     v.Z+=speed*cos (w.Y/180*M_PI);
                     v.X+=speed*sin(w.Y/180*M_PI);                      
                     car->setPosition(v);
                     
                     //The user is decelerating and he should change to gear 1
                     //to continue decelerating
                     if(speed<=30){
                               image_gearChange->setVisible(true);
				     }
                     //The user does not have to change gear          
                     if(speed<50){
					 		   image_gearChange->setVisible(false); 
				     }           
                }
                else{//speed<=1
                     v.Z+=speed*cos(w.Y/180*M_PI);
                     v.X+=speed*sin(w.Y/180*M_PI);
                     car->setPosition(v);
                }         
            }//close if statement for key_S_Down
                     */ 
            /*To calculate displacement the length of the car needs to be known.
              We will assume the length of the car to be 3.0f i.e 3 meters. The
              displacement of a car when it is making a turn is:
              (speed*angleTurn)/length of car */
       /*     if ( key_A_Down && speed!=0){
                 w.Y-= 5.0f;
                 v.Z+=((speed*sin(w.Y/180*M_PI))/3)*cos(w.Y/180*M_PI);
                 v.X+=((speed*sin(w.Y/180*M_PI))/3)*sin(w.Y/180*M_PI);
                 car->setRotation(w);
                 car->setPosition(v);
            }
            if ( key_D_Down && speed!=0){
                 w.Y+=5.0f;
                 v.Z+=((speed*sin(w.Y/180*M_PI))/3)*cos(w.Y/180*M_PI);
                 v.X+=((speed*sin(w.Y/180*M_PI))/3)*sin(w.Y/180*M_PI);
                 car->setRotation(w);
                 car->setPosition(v);
            }

        }//close if statement for gear==2
*/
}

The game.h

Code: Select all

#ifndef __GAME_H_INCLUDED__
#define __GAME_H_INCLUDED__

#include <irrlicht.h>
#include <IPhysics.h>
#include <Newton.h>

#include <iostream>
#include <math.h>
#include <stdio.h>
#include <wchar.h>
#include <aabbox3d.h>





//#include <irrKlang.h>
#pragma comment(lib, "Irrlicht.lib")
#pragma comment(lib, "IPhysics.lib")
#pragma comment(lib, "Newton.lib")
/******************************************************************************
**
**              The game.h file where all the declaration of the                                                                 
**                  function and variable and pointers that will be use..
**
**
*******************************************************************************/
using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;
//using namespace audio;
// use scale factor between Newton and IRR
//const float NewtonToIrr = 32.0f;
//const float IrrToNewton = (1.0f / NewtonToIrr);


class Game : public IEventReceiver
{
      
      
public:
      
	Game(video::E_DRIVER_TYPE driverType, s32 resX, s32 resY,  s32 view,  s32 sound,
     EKEY_CODE KeyAcc,EKEY_CODE KeyBrake,EKEY_CODE KeyLeft,EKEY_CODE KeyRight,
     EKEY_CODE KeyHand,EKEY_CODE KeyGearUp,EKEY_CODE KeyGearDown);
     ~Game();
	//Game();
    bool run();
    bool init();
    void returnCollision();
    void createCarPhysics();
    void updatePosition();
    virtual bool OnEvent(const SEvent event);

private:
       
      video::E_DRIVER_TYPE driverType;
       s32 resX;
       s32 resY;
        s32 view;
       s32 sound;
       EKEY_CODE KeyAcc;
       EKEY_CODE KeyBrake;
       EKEY_CODE KeyLeft;
       EKEY_CODE KeyRight;
       EKEY_CODE KeyHand;
       EKEY_CODE KeyGearUp;
       EKEY_CODE KeyGearDown;
       bool status;
      
       
        scene::IAnimatedMeshSceneNode* car21;
        ITriangleSelector* selector;
        scene::ICameraSceneNode* camera;
        ISceneNode* scene_node;
        ISceneNode* levelnode;
       	core::line3d<f32> line;
    	core::vector3df intersection;
        core::triangle3df tri;
        core::vector3df v;
        core::vector3df w;
    	core::stringw str; 
    	core::stringw str2;
    	gui::IGUIStaticText* txt;
        gui::IGUIImage* image;
        gui::IGUIImage* image_gearChange;
        gui::IGUIImage* image_lackSpeed;
        gui::IGUIImage* image_fast;
        gui::IGUIImage* image_reverse;
        gui::IGUIImage* image_gear2_1;
        gui::IGUIImage* image_change_lane;
        gui::IGUIImage* image_change_gear;
        scene::ISceneManager* smgr; 
        

        //	IPhysicsCar* car;
       
        	
};

#endif
And in my menu.cpp run() parse the value when game is started...

Code: Select all

bool Menu::run(video::E_DRIVER_TYPE& outdriverType, s32& outresX,  s32& outresY, s32& outview, s32& outsound, EKEY_CODE& outKeyAcc,EKEY_CODE& outKeyBrake,EKEY_CODE& outKeyLeft,EKEY_CODE& outKeyRight,EKEY_CODE& outKeyHand,EKEY_CODE& outKeyGearUp,EKEY_CODE& outKeyGearDown)
{
..some codes
}
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

You declare your method OnEvent in Game with "const SEvent" but it should not have the const.
Furthermore you have an additional event receiver which seems to have no reason, won't work (due to lack of inits) and you should be careful with nested C-style comments.
Masterhawk
Posts: 299
Joined: Mon Nov 27, 2006 6:52 pm
Location: GERMANY
Contact:

Post by Masterhawk »

I think you also set no event receiver

Code: Select all

device =createDevice(video::EDT_SOFTWARE2,
                         core::dimension2d<s32>(800,600),
                       16,false, false, false);
Think you should change it to

Code: Select all

device =createDevice(video::EDT_SOFTWARE2,
                         core::dimension2d<s32>(800,600),
                       16,false, false, this);
Image
Requiem
Posts: 20
Joined: Fri Mar 02, 2007 10:01 am

Post by Requiem »

THx for your help :D
joshua1091
Posts: 23
Joined: Thu Aug 09, 2007 5:16 pm

simple

Post by joshua1091 »

simple.....change

Code: Select all

OnEvent(const SEvent event)
to

Code: Select all

OnEvent(const SEvent &event)
Post Reply