gamecreator Posted August 18, 2016 Share Posted August 18, 2016 At the title screen, I would like to have the user "Press any key to continue..." I couldn't find a Leadwerks function that does this. I also searched the forums and no luck there either. Possibilities: - Use a Windows-only function like GetKeyboardState though I'd rather not have this be the only thing preventing a Linux deployment - See if I can incorporate another library like SDL but I doubt the Publisher will play well with it and I'd also rather avoid this - Somehow check all of the keys one by one with KeyHit. I'm not sure how this would work as far as C code goes besides something going in a loop. For example, is it safe to check for later letters by incrementing on A (A+1, A+2, etc.)? Thoughts? Also, is there any way to not have the Alt button trigger the window menu? Most games let you map this button. Quote Link to comment Share on other sites More sharing options...
AggrorJorn Posted August 18, 2016 Share Posted August 18, 2016 I made a helper class with a method AnyKeyDown(). I would loop over all the keys or a specific set like enter, space, escape, etc. The downside to this is that Leadwerks has now marked those checked key as used. So if you would check the state of a button again in another script, it would return a different value. That why I store the values of every key and use my own functions to check for key down/up. Maybe this has changed though (haven't used in Le in a while). 1 Quote Link to comment Share on other sites More sharing options...
PerEspen00 Posted August 18, 2016 Share Posted August 18, 2016 I made a helper class with a method AnyKeyDown(). I would loop over all the keys or a specific set like enter, space, escape, etc. The downside to this is that Leadwerks now has marked those checked key as used. So if you would check the state of a button again in another script, it would return a different value. That why I store the values of every key and use my own functions to check for key down/up. Maybe this has changed though (haven't used in Le in a while). Hi, I Think you just pin pointed one of my major bugs. When i pick up a weapon in my game, it shoots once. So i made like a timer thing were u can shoot only after 1 second of picking it up. Anyway, is there a way around this? Quote Link to comment Share on other sites More sharing options...
AggrorJorn Posted August 18, 2016 Share Posted August 18, 2016 A custom input check class is the way I solved it. So basicly, if I have two lua scripts that want to know if the space bar in the same update frame, you get true in one script and false in the other. Storing the value of the spacebar being pressed every frame prevents this from happening. Quote Link to comment Share on other sites More sharing options...
gamecreator Posted August 18, 2016 Author Share Posted August 18, 2016 I'm using C/C++ so Lua limitations are not an issue. I think going the method you suggested is the best, unless someone has a better idea. It's not that bad to do this one by one key[i++]=Key::A; key[i++]=Key::B; etc. or if they're incremental (for int i=0; i<26; i++) key[i]=Key::A+i; but not sure how reliable this is. Quote Link to comment Share on other sites More sharing options...
AggrorJorn Posted August 19, 2016 Share Posted August 19, 2016 I recall doing this in C++ as well and although it is incremental, the keyboard layout takes some figuring out. The letter A starts somewhere on position 22, Enter on 76 etc. This was 2 years ago so maybe things changed. 1 Quote Link to comment Share on other sites More sharing options...
CangoJoe Posted August 19, 2016 Share Posted August 19, 2016 Forgive the pseudo-code but would something like this work? If not KeyHit("Escape") then ContinueGame() Else ExitGame() End Quote Link to comment Share on other sites More sharing options...
gamecreator Posted August 20, 2016 Author Share Posted August 20, 2016 Good thought but that would always trigger ContinueGame because if you don't hit any button at all, it counts as Escape not being hit. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.