About movement - is it just me, or does it make no sense?
Posted: Sat Mar 11, 2006 4:19 pm
Hi guys,
First off, I am a total noob to Irrlicht, so pardon me if this is a stupid question or if I don't understand how things are supposed to work.
Having examined the .NET Hello World example, the first thing I wanted to implement was some extra input routines. So I followed the C++ tutorial for movement, and implemented it as C#/VB, but right away it smacks me as not making sense.
The problem I see is that the MyEventHandler class we define is expected to actually handle the results of the input. This is a little weird. Basically, it forces us to use global variables of some kind. Either we need to define our game nodes as globals so that the MyEventHandler can do something with them (if W is pressed, then move NodeA) or define a global KeyPressed variable so that MyEventHandler can assign a value to it (if W is pressed, then KeyPressed = W) and the main loop can react to it. And either way, we just return a Boolean from the event.
This is not how .NET works, nor is it a good model for execution. The OnEvent() function should not be returning a boolean, it should be raising an event, and passing eventinfo through the delegate which contains stuff like what event took place, and the particulars (keypressed, mousex, whatever) . We then just react to the event appropriately.
So is it just me? Am I misunderstanding how this works? Is this just a hack because of the way it is handled in C++?
First off, I am a total noob to Irrlicht, so pardon me if this is a stupid question or if I don't understand how things are supposed to work.
Having examined the .NET Hello World example, the first thing I wanted to implement was some extra input routines. So I followed the C++ tutorial for movement, and implemented it as C#/VB, but right away it smacks me as not making sense.
The problem I see is that the MyEventHandler class we define is expected to actually handle the results of the input. This is a little weird. Basically, it forces us to use global variables of some kind. Either we need to define our game nodes as globals so that the MyEventHandler can do something with them (if W is pressed, then move NodeA) or define a global KeyPressed variable so that MyEventHandler can assign a value to it (if W is pressed, then KeyPressed = W) and the main loop can react to it. And either way, we just return a Boolean from the event.
This is not how .NET works, nor is it a good model for execution. The OnEvent() function should not be returning a boolean, it should be raising an event, and passing eventinfo through the delegate which contains stuff like what event took place, and the particulars (keypressed, mousex, whatever) . We then just react to the event appropriately.
So is it just me? Am I misunderstanding how this works? Is this just a hack because of the way it is handled in C++?