30/12/20 - Getting keyboard and mouse user input #8
Locked
jakelacey2012
started this conversation in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
In this post we'll get the users input and modify some internal state to render something to the screen.
2020-12-30.15-14-02.mp4
GLFW has some handy methods for us to do this with
glfwSetKeyCallback
andglfwSetCursorPosCallback
the only gotcha is that the functions passed in C++ needed to be static, which meant access to the game state would be freely available. To have access to this we would have to tell GLFW "hey this is our game state, can you keep track of it please." by usingglfwSetWindowUserPointer
and then asking for access back to it usingglfwGetWindowUserPointer
to have access to the game state.You can view the PR here https://github.com/jakelacey2012/HelloWorld/pull/7/files at the moment all it does at the moment is track the letter "E" and the cords of the mouse position. When the letter "E" is being pressed it displays a triangle.
I have some ideas of how better I'd like to pipe the events through to the game state, however what I'd like to do next is actually build a game and see how those ideas still fit whether those ideas are actually necessary. With that said I think its time to build a game, and I think that first game will be PONG.
Beta Was this translation helpful? Give feedback.
All reactions