keymap bug

You discovered a bug in the engine, and you are sure that it is not a problem of your code? Just post it in here. Please read the bug posting guidelines first.
Post Reply
Evil Game Manic
Posts: 12
Joined: Sun Apr 23, 2006 11:05 pm

keymap bug

Post by Evil Game Manic »

it might be my coding but i doubt it, i'm using irrlicht0.14.0(i've had a slow dial-up so i have been unable to download the new version so that might be the problem :oops: )but anyway i JUST placed in a SKeyMap keyMap[8] and now the camera with only rotate as usual but the camera will not move left,right,down,up(also i haven't add a collision respone animator,if that helps :) )

Code: Select all

	
#include <irrlicht.h>
#include <iostream>
#include "game_manager.h"


using namespace std;

int main()
{

game_manager g_manager;
g_manager.CreateDevice();
g_manager.getirrDevice();
g_manager.getirrGUIEnvironment();
g_manager.getirrSceneManager();

g_manager.Init();

	scene::IAnimatedMesh* q3levelmesh =g_manager.irrSceneManager->getMesh("20kdm2.bsp");
	scene::ISceneNode* q3node = 0;

	
	if (q3levelmesh)
		q3node = g_manager.irrSceneManager->addOctTreeSceneNode(q3levelmesh->getMesh(0));


	scene::ITriangleSelector* selector = 0;
	
	if (q3node)
	{		
		q3node->setPosition(core::vector3df(-1370,-130,-1400));

		selector = g_manager.irrSceneManager->createOctTreeTriangleSelector(q3levelmesh->getMesh(0), q3node, 128);
		q3node->setTriangleSelector(selector);
		selector->drop();
	}

	SKeyMap keyMap[8];
    keyMap[0].Action = EKA_MOVE_FORWARD;
    keyMap[0].KeyCode = KEY_UP;
    keyMap[1].Action = EKA_MOVE_FORWARD;
    keyMap[1].KeyCode = KEY_KEY_W;
                   
    keyMap[2].Action = EKA_MOVE_BACKWARD;
    keyMap[2].KeyCode = KEY_DOWN;
    keyMap[3].Action = EKA_MOVE_BACKWARD;
    keyMap[3].KeyCode = KEY_KEY_S;
                   
    keyMap[4].Action = EKA_STRAFE_LEFT;
    keyMap[4].KeyCode = KEY_LEFT;
    keyMap[5].Action = EKA_STRAFE_LEFT;
    keyMap[5].KeyCode = KEY_KEY_A;
                   
    keyMap[6].Action = EKA_STRAFE_RIGHT;
    keyMap[6].KeyCode = KEY_RIGHT;
    keyMap[7].Action = EKA_STRAFE_RIGHT;
    keyMap[7].KeyCode = KEY_KEY_D;
	scene::ISceneNode* lightnode = 0;
	lightnode = g_manager.irrSceneManager->addLightSceneNode(0,core::vector3df(10,15,0),video::SColorf(1,1,1,255),100.0f);

	
	scene::ICameraSceneNode* camera = g_manager.irrSceneManager->addCameraSceneNodeFPS(0,100.0,500.0,-1,keyMap,8,false);

	camera->setPosition(core::vector3df(-0,-0,-0));
	
	g_manager.irrDevice->setResizeAble(true);

   scene::IAnimatedMesh* weapon = g_manager.irrSceneManager->getMesh("gfx/uzi.3ds");
   scene::IAnimatedMeshSceneNode* weaponnode = g_manager.irrSceneManager->addAnimatedMeshSceneNode(weapon,camera);
   weaponnode->setMaterialFlag(video::EMF_LIGHTING, false);
   weaponnode->setPosition(core::vector3df(50,-30,85));
   weaponnode->setScale(core::vector3df(5,5,5));
				 
 
				  g_manager.irrSceneManager->addSkyBoxSceneNode(
				  g_manager.irrVideoDriver->getTexture("gfx/nemesis_up.jpg"),0,
				  g_manager.irrVideoDriver->getTexture("gfx/nemesis_lf.jpg"),
				  g_manager.irrVideoDriver->getTexture("gfx/nemesis_rt.jpg"),
				  g_manager.irrVideoDriver->getTexture("gfx/nemesis_ft.jpg"),
				  g_manager.irrVideoDriver->getTexture("gfx/nemesis_bk.jpg"));
				  
  g_manager.irrVideoDriver->draw2DImage(g_manager.irrVideoDriver->getTexture("gfx/healthmeter.bmp"), core::position2d<s32>(468,350));

   	int lastFPS = -1;
   	int lastpoly = -1;

	while(g_manager.irrDevice->run())
	if (g_manager.irrDevice->isWindowActive())
	{
		g_manager.irrVideoDriver->beginScene(true, true,video::SColor(100,100,100,100));

		g_manager.irrSceneManager->drawAll();


		g_manager.irrVideoDriver->endScene();

		int fps = g_manager.irrVideoDriver->getFPS();
		int polydrawn = g_manager.irrVideoDriver->getPrimitiveCountDrawn();

					 
		if (lastFPS != fps)
		{
		  core::stringw str = L"GAME DEMO - Irrlicht Engine [";
		  str += g_manager.irrVideoDriver->getName();
		  str += "] FPS:";
		  str += fps;
          str += L"Polygon count";
	      str += polydrawn;


		  g_manager.irrDevice->setWindowCaption(str.c_str());
		  lastFPS = fps;

		}
		
	}

	g_manager.irrDevice->drop();

return 0;
}
I'm not Game Manic
Acki
Posts: 3496
Joined: Tue Jun 29, 2004 12:04 am
Location: Nobody's Place (Venlo NL)
Contact:

Post by Acki »

Hmm, your code seems to be correct...
Do you have an event receiver created ???
Maybe there is the problem...
My first thought was that your event receiver does not return false...
If your event recever returns true, Irrlicht doesn't care about the event itself...

But this code seems right to me...
while(!asleep) sheep++;
IrrExtensions:Image
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
Evil Game Manic
Posts: 12
Joined: Sun Apr 23, 2006 11:05 pm

Post by Evil Game Manic »

I do have an event receiver created in game_manager.h
I'm not Game Manic
Clone256
Posts: 11
Joined: Thu Oct 13, 2005 9:20 pm

Post by Clone256 »

I had the same problem with the keys not moving the camera. I was using the example from http://www.irrforge.org/index.php/Keyboard_Input to get the input.

In this part:

Code: Select all

if(event.EventType == irr::EET_KEY_INPUT_EVENT){ 
keys[event.KeyInput.Key] = event.KeyInput.PressedDown; 
return true; 
}
The "return true;" needed to be deleted. Then it worked fine for me.
Shakira22

Post by Shakira22 »

really ? :) :)
Post Reply