Okay. What was the code to get a key while it is pressed, instead of
just shooting the event when it’s first pressed?
I tried this, but it doesn’t seem to work: (I key)----------
iPressed = false
while true do
while (SDL.SDL_PollEvent(event) == 0) do
-- Render the screen
render()
-- Move the ball
moveBall()
SDL.SDL_Delay(100)
end
if event.type == SDL.SDL_KEYDOWN then
key = event.key.keysym.sym
if key == SDL.SDLK_I then
iPressed = true
else
iPressed = false
end
if iPressed then
-- Do my stuff here
end
end
OK, I know this isn’t C++, but it should be pretty straight-forward if
you know that… And I know C++, so you can use that in your answers.
I’m sorry for having wasted your time, it does work… Well, not really,
but it seems to be a problem with the Lua port… :-/
Which Lua port are you using? There are a number of OSS projects
that has Lua SDL bindings. It might be a good idea contacting a
list dealing with that particular project, or contact the
author(s) directly.> None of the letter keys work, so I’m stuck with the arrows… Gotta look
into that, but thanks though!
matt wrote:
L-28C wrote:
Hello everyone!
Okay. What was the code to get a key while it is pressed, instead of
just shooting the event when it’s first pressed?
I tried this, but it doesn’t seem to work: (I key)
[snip snip]
–
Cheers,
Kein-Hong Man (esq.)
Kuala Lumpur, Malaysia
I figured it out; it seems it doesn’t support the PollEvent method for
getting keys, so I must use GetKeyState(). It works pretty well IMO.
Kein-Hong Man wrote:> Leo M. Cabrera wrote:
I’m sorry for having wasted your time, it does work… Well, not really,
but it seems to be a problem with the Lua port… :-/
Which Lua port are you using? There are a number of OSS projects
that has Lua SDL bindings. It might be a good idea contacting a
list dealing with that particular project, or contact the
author(s) directly.
None of the letter keys work, so I’m stuck with the arrows… Gotta look
into that, but thanks though!
matt wrote:
L-28C wrote:
Hello everyone!
Okay. What was the code to get a key while it is pressed, instead of
just shooting the event when it’s first pressed?
I tried this, but it doesn’t seem to work: (I key)