Game Programming and Development Tools

Irrlicht Lua - key events – Lazarus

Lazarus

Member

Posts: 1668
From: USA
Registered: 06-06-2006
Hello.

I'm working on an Irrlicht - Lua based program, and seem to have run into a stumbling block - detecting keypresses.

I cut out
<BLOCKQUOTE><table width=80% border=0 bgcolor="#FFFFF" CELLPADDING="2" CELLSPACING="2"><TR><TD><font size="3" face="Courier" color="#000000"><pre>
MyEventReceiver = {}

function MyEventReceiver:OnEvent(Event)
if Event.EventType == irr.EET_KEY_INPUT_EVENT then
return self:OnKeyEvent(Event.KeyInput.Key, Event.KeyInput.PressedDown, Event.KeyInput.Control, Event.KeyInput.Shift)
end
return false
end

function MyEventReceiver:OnKeyEvent(Key, PressedDown, Shift, Control)

if not PressedDown then

if Key == irr.KEY_KEY_W then
imp1_y = imp1_y + 1
return true
end

if Key == irr.KEY_KEY_S then
imp1_y = imp1_y - 1
return true
end

end

return false
end
</pre></font></TD></TR></TABLE></BLOCKQUOTE>

that from one of the example programs to use - but imp_y doesn't seem to be changed when I press W or S.

Ahh - never mind. I figured it out - wasn't setting the event receiver.

(When the forum update comes, I hope we'll be able to delete a topic in situations like this - that's not possible currently)

[This message has been edited by Lazarus (edited April 02, 2007).]

Calin

Member

Posts: 358
From: Moldova
Registered: 12-04-2006
quote:
Originally posted by Lazarus:

(When the forum update comes, I hope we'll be able to delete a topic in situations like this - that's not possible currently)


I'll resurrect the forum thread see if they have any updates for us.

------------------
a good gameplay is a right combination between performance and features.

steveth45

Member

Posts: 536
From: Eugene, OR, USA
Registered: 08-10-2005
It's cool that you are using Irrlicht + Lua. Let us know how things go. I'm using Irrlicht + Python for pyweek right now, but I have to make my own lightweight Python-Irrlicht binding using Boost::Python. I'm calling it "Irrthon" right now, but I'll probably change the name later.

------------------
+---------+
|steveth45|
+---------+

Lazarus

Member

Posts: 1668
From: USA
Registered: 06-06-2006
Well, I hope you release it to the world - other language bindings for Irrlicht are plentiful - but mostly outdated, unfortunately.
steveth45

Member

Posts: 536
From: Eugene, OR, USA
Registered: 08-10-2005
Well, it will be released as part of my Pyweek entry, but I will probably clean it up a bit and make a more formal release on my webpage and/or sourceforge. There was an older Python-Irrlicht binding called Venom, but it hasn't been updated in ages. My binding takes a different philosophical approach than most bindings. Instead of just binding every single call, I'd like to make mine a little "higher" level and take care of more things for you, so you don't have to produce the same Irrlicht engine code, but in a different language. The binding will also include an audio engine, probably Audiere, so, in a sense, it will be a more general Python game engine, not just an Irrlicht binding. I'll try to keep it up do date with the latest Irrlicht version, too.

------------------
+---------+
|steveth45|
+---------+

Lazarus

Member

Posts: 1668
From: USA
Registered: 06-06-2006
I will look forward to that. IrrLua is... unsatisfactory, to say the least. 15 fps for a simple 2D layout with one sprite?!
Lazarus

Member

Posts: 1668
From: USA
Registered: 06-06-2006
I was somewhat disgusted upon commenting out three parts of the drawing loop(that printed two lines of text and a little rectangle, respectively) - and going from fifteen frames per second to forty-five!

...crazy, it's just crazy.

steveth45

Member

Posts: 536
From: Eugene, OR, USA
Registered: 08-10-2005
That doesn't sound good. When you say "printing text", are you printing it in the console or rendering it on the main windows? I could see printing to the console every frame slowing things down, though that seems a little extreme. With my Python binding, I've got an animated model ~1600 poly's, plus several hundred poly's for the level. The whole thing runs at 60 frames per second. It would probably be faster if I turned off vsync. I think Irrlua was built with Swig, which is apparently not too great of a way to make bindings regarding performance, so maybe that is the problem. Also, make sure that you are using the OpenGL device, the software device can slow everything down.

------------------
+---------+
|steveth45|
+---------+

Lazarus

Member

Posts: 1668
From: USA
Registered: 06-06-2006
Well, I checked, and I'm getting around 400FPS with Irrlicht 1.3 and the sixth example program(C++ - the 2D example) - and 19FPS with Irrlicht 1.1, IrrLua, and the same example program.(Using DX9.0C for both, btw)

I think I see where the problem is.
But - the 3D examples in IrrLua run at a much better framerate(like around 58FPS for the terrain render demo) - so I guess it's just a problem with the 2D functions or something.