add functionality to move player by using arrow keys

This commit is contained in:
2024-12-14 07:59:43 +00:00
parent 9144c97fba
commit 1901043535
9 changed files with 134 additions and 34 deletions

View File

@@ -157,6 +157,7 @@ typedef Pointer Objptr;
extern "C" {
#endif
MLLIB_PUBLIC(void mltonKeyCallback (Int32 x0, Int32 x1, Int32 x2, Int32 x3);)
#undef MLLIB_PRIVATE
#undef MLLIB_PUBLIC

View File

@@ -4,6 +4,17 @@
#include <GLFW/glfw3.h>
int PRESS = GLFW_PRESS;
int REPEAT = GLFW_REPEAT;
int RELEASE = GLFW_RELEASE;
int ARROW_UP = GLFW_KEY_UP;
int ARROW_DOWN = GLFW_KEY_DOWN;
int ARROW_LEFT = GLFW_KEY_LEFT;
int ARROW_RIGHT = GLFW_KEY_RIGHT;
void keyCallback(GLFWwindow* window, int key, int scancode, int action, int mods) {
mltonKeyCallback(key, scancode, action, mods);
}
void setKeyCallback(GLFWwindow* window) {
glfwSetKeyCallback(window, keyCallback);
}

View File

@@ -7,13 +7,28 @@ struct
_symbol "PRESS" public : ( unit -> int ) * ( int -> unit );
val PRESS = PRESS ()
val (REPEAT, _) =
_symbol "REPEAT" public : ( unit -> int ) * ( int -> unit );
val REPEAT = REPEAT ()
val (RELEASE, _) =
_symbol "RELEASE" public : ( unit -> int ) * ( int -> unit );
val RELEASE = RELEASE ()
val (ARROW_UP, _) =
_symbol "ARROW_UP" public : ( unit -> int ) * ( int -> unit );
val ARROW_UP = ARROW_UP ()
val (ARROW_DOWN, _) =
_symbol "ARROW_DOWN" public : ( unit -> int ) * ( int -> unit );
val ARROW_DOWN = ARROW_DOWN ()
val (ARROW_LEFT, _) =
_symbol "ARROW_LEFT" public : ( unit -> int ) * ( int -> unit );
val ARROW_LEFT = ARROW_LEFT ()
val (ARROW_RIGHT, _) =
_symbol "ARROW_RIGHT" public : ( unit -> int ) * ( int -> unit );
val ARROW_RIGHT = ARROW_RIGHT ()
val exportKeyCallback =
_export "mltonKeyCallback" public : (int * int * int * int -> unit) -> unit;
val setKeyCallback =
_import "setKeyCallback" public : window -> unit;
end