Attempt to make it so that keys track their own key down and key up event so you can hold down one key and do something with another at the same time.
This commit is contained in:
parent
3a1f834777
commit
21466a5e2d
@ -113,15 +113,15 @@ while running do
|
||||
for e in SDL.pollEvent() do
|
||||
if e.type == SDL.event.KeyUp then --chrys just recognice the keyup and free the loop
|
||||
keyName = SDL.getKeyName(e.keysym.sym)
|
||||
holdKey.keyName = false
|
||||
holdKey[keyName] = false
|
||||
direction = ""
|
||||
-- speak(playerPosition)
|
||||
end
|
||||
if e.type == SDL.event.Quit then
|
||||
running = false
|
||||
elseif e.type == SDL.event.KeyDown and not holdKey.keyName then -- chrysif not already down ( see below)
|
||||
elseif e.type == SDL.event.KeyDown and not holdKey[keyName] then -- chrysif not already down ( see below)
|
||||
keyName = SDL.getKeyName(e.keysym.sym)
|
||||
holdKey.keyName = true --chrys mark the remember the keydown
|
||||
holdKey[keyName] = true --chrys mark the remember the keydown
|
||||
if keyName == "Q" then
|
||||
running = exit_game(SDL, mixer)
|
||||
elseif keyName == "Left Shift" or keyName == "Right Shift" then
|
||||
|
Loading…
Reference in New Issue
Block a user