Page 4 of 5

Re: this does'nt work

Posted: Fri Jul 25, 2008 7:35 am
by rogerborg
3DModelerMan wrote: And here's the error that I get

Code: Select all

 error: base operand of `->' has non-pointer type `MastEventReceiver'
Thanks :D .
And here's the top Google hit for that error, which took me all of 30 seconds to find.

Posted: Fri Jul 25, 2008 12:38 pm
by Dorth
And this is code snippet section, not Beginner help nor Advanced help

oh

Posted: Fri Jul 25, 2008 3:01 pm
by 3DModelerMan
Oh sorry, and thanks for the help.
I thought it was fine to post questions about the projects.

Posted: Fri Jul 25, 2008 3:33 pm
by Dorth
Questions, maybe.
Huge block of code, one line error and "Can someone help me?" no.

.h file for mast event receiver

Posted: Sat Aug 09, 2008 3:19 pm
by 3DModelerMan
Does this need many modifications to be put in a .h file instead of a .cpp?.

Posted: Mon Aug 25, 2008 5:52 am
by timetokill
Hi,

I just started using this and everything seemed to be going fine, until I let the program run for a minute or two.

I won't press any keys, I'll just let it run, and Visual Studio tells me that I've hit a break point here:

Code: Select all

	//! Direct const access operator
	const T& operator [](u32 index) const
	{
		_IRR_DEBUG_BREAK_IF(index>=used) // access violation

		return data[index];
	}

For reference, the test I'm doing with the class is this:

Code: Select all

		if(eventReceiver.keyDown(KEY_RIGHT))
		{
			a++;
		}
		else if(eventReceiver.keyDown(KEY_LEFT))
		{
			a--;
		}
		else if(eventReceiver.keyPressed(KEY_DOWN))
		{
			a=0;
		}

I'm really not sure why this is happening, or if it's a problem with the class or my code, the compiler, etc. Hopefully somebody can help.



EDIT: After some other tests, I don't think it's the class that is causing the issue. It seems to happen even in the Hello World app... I'll check around the forums for help, but if anybody can point me in the right direction I'd really appreciate it.

Posted: Mon Aug 25, 2008 7:52 am
by hybrid
It looks like you use 'a' for access to some limited array. This will crash once you pressed a often enough. Other causes are definitely not related to the standard examples' code. Just post your code in the beginner's forum and there will be someone looking at it.

Posted: Tue Aug 26, 2008 2:35 am
by Angus5
I don't know what I'm doing. I'm trying to figure out how this works, I do this but it crashes:

Code: Select all

MastEventReceiver* input;

...
...
...

if(input->keyPressed(KEY_SPACE))
    do stuff;
Obviously I'm not doing it right.

Posted: Tue Aug 26, 2008 9:07 am
by hybrid
Hmm, might be the right time to read about the C++ basics in a book or tutorial elsewhere...
You're using an uninitialized pointer, there's no receiver object created so far. Hence, any access to 'input' will lead to undesired results!

WooT!

Posted: Thu Sep 04, 2008 3:30 pm
by kingdutch
Works like a charm after I changed

Code: Select all

SEvent event
into

Code: Select all

const SEvent& event

Posted: Wed Oct 29, 2008 8:22 am
by baldong
kingdutch is right, without it, you will receive a error about can't initialize a abstract class.

Posted: Mon Dec 15, 2008 6:52 am
by Arcoroc
Just to clarify, the modification is on line 64

Code: Select all

  virtual bool OnEvent(SEvent event) 
into

Code: Select all

 virtual bool OnEvent(const SEvent& event) 
to make it work with irrlicht 1.4.2.

Thanks for sharing.

Posted: Tue Jun 16, 2009 3:42 pm
by Ulf
I've just started using Irrlicht to make a game engine. I've been creating my event handling procedures.

Is this MastEventReceiver designed for a game engine?

I am a newbie, but still I feel that there is so much wrong with this MastEventReceiver. But I'm confused why noone has questioned it.
My biggest problem is that I don't understand what it is trying to achieve.
It seems overly complex (though not complete) and redundant in some ways.

Please enlighten me if I overlook or misunderstand something.

Firstly, why have a Down() and an Up() function? Why not just have:

boolean KeyDown(EKEY_CODE keyCode) or
MouseButtonDown(int mouseButton) ??

With the MouseButtonDown, you could make one function (as above) and pass the mouse button parameter to the function.

Also, what is the Pressed() and Released() for?.. and then you update the actual values in the function startEventProcess().
Why would you want to start the event process at the end of the loop and stop it at the start?

For a game engine, I'd always take events since the user can set their own delays for their game input. The game loop (device->run()) will be calling game specific event handlers HandleKeys(), MouseMove(), MouseButton() and HandleJoystick() etc.
I understand turning off event handling just prior to the actual game specific game cycle, then turn it back on after. It may be required to keep the engine in a whole state so to speak, since the actual event handling in the app(window) is always happening and hence it is updating keystates etc. Even that may not be necessary? (anyone's opinion?)
e.g.
while (device->run())
{
HandleKeys();
evtHandler->Stop();
GameCycle();
evtHandler->Start();
}

Anyway, what is it for? Nowhere can I find explanations for the purpose of Pressed and Released.
Why would you only want to set the state to PRESSED on the first press? Instead of putting it straight to DOWN?
I can't see the benefit.
LOOK BELOW:

//Left Mouse Button Pressed
if (event.MouseInput.Event == EMIE_LMOUSE_PRESSED_DOWN)
{
if (mouseButtonState[0] == UP || mouseButtonState[0] == RELEASED)
{
mouseButtonState[0] = PRESSED;
}
else
{
mouseButtonState[0] = DOWN;
}
}

Please explain?

I'll post my event handler for a game engine when I complete it.
I'd appreciate any constructive comments about my comments or about Mastiff's event handler.

Posted: Tue Jun 16, 2009 8:59 pm
by wITTus
I agree.

The MastEventReceiver is a very ugly piece of C++ code.
If you don't like it, don't use it. :wink:

Birds are chirping

Posted: Wed Jun 17, 2009 1:57 am
by Ulf
Ok, thanks.
I never was going to use it, but I wanted to know if my idea was right, or if there really was a practical reason for all the confusing PRESSED and RELEASED, and so on..

Noone even asked what it's for. Anyway... :roll: