Refactor struct part 2.
This commit is contained in:
@ -36,32 +36,35 @@ int32_t main() {
|
||||
|
||||
// Prepare the game
|
||||
game_t *game = &GAME_STATE;
|
||||
input_t *input = &game->engine.input;
|
||||
|
||||
// Init the game
|
||||
if(gameInit(game)) {
|
||||
// Bind initial keys
|
||||
inputBind(INPUT_NULL, (inputsource_t)GLFW_KEY_ESCAPE);
|
||||
inputBind(INPUT_DEBUG_UP, (inputsource_t)GLFW_KEY_W);
|
||||
inputBind(INPUT_DEBUG_DOWN, (inputsource_t)GLFW_KEY_S);
|
||||
inputBind(INPUT_DEBUG_LEFT, (inputsource_t)GLFW_KEY_A);
|
||||
inputBind(INPUT_DEBUG_RIGHT, (inputsource_t)GLFW_KEY_D);
|
||||
inputBind(INPUT_DEBUG_RAISE, (inputsource_t)GLFW_KEY_Q);
|
||||
inputBind(INPUT_DEBUG_LOWER, (inputsource_t)GLFW_KEY_E);
|
||||
inputBind(INPUT_DEBUG_FINE, (inputsource_t)GLFW_KEY_LEFT_CONTROL);
|
||||
inputBind(INPUT_DEBUG_PLUS, (inputsource_t)GLFW_KEY_EQUAL);
|
||||
inputBind(INPUT_DEBUG_MINUS, (inputsource_t)GLFW_KEY_MINUS);
|
||||
inputBind(input, INPUT_NULL, (inputsource_t)GLFW_KEY_ESCAPE);
|
||||
inputBind(input, INPUT_DEBUG_UP, (inputsource_t)GLFW_KEY_W);
|
||||
inputBind(input, INPUT_DEBUG_DOWN, (inputsource_t)GLFW_KEY_S);
|
||||
inputBind(input, INPUT_DEBUG_LEFT, (inputsource_t)GLFW_KEY_A);
|
||||
inputBind(input, INPUT_DEBUG_RIGHT, (inputsource_t)GLFW_KEY_D);
|
||||
inputBind(input, INPUT_DEBUG_RAISE, (inputsource_t)GLFW_KEY_Q);
|
||||
inputBind(input, INPUT_DEBUG_LOWER, (inputsource_t)GLFW_KEY_E);
|
||||
inputBind(input, INPUT_DEBUG_FINE, (inputsource_t)GLFW_KEY_LEFT_CONTROL);
|
||||
inputBind(input, INPUT_DEBUG_PLUS, (inputsource_t)GLFW_KEY_EQUAL);
|
||||
inputBind(input, INPUT_DEBUG_MINUS, (inputsource_t)GLFW_KEY_MINUS);
|
||||
|
||||
inputBind(INPUT_UP, (inputsource_t)GLFW_KEY_UP);
|
||||
inputBind(INPUT_DOWN, (inputsource_t)GLFW_KEY_DOWN);
|
||||
inputBind(INPUT_LEFT, (inputsource_t)GLFW_KEY_LEFT);
|
||||
inputBind(INPUT_RIGHT, (inputsource_t)GLFW_KEY_RIGHT);
|
||||
inputBind(INPUT_UP, (inputsource_t)GLFW_KEY_W);
|
||||
inputBind(INPUT_DOWN, (inputsource_t)GLFW_KEY_S);
|
||||
inputBind(INPUT_LEFT, (inputsource_t)GLFW_KEY_A);
|
||||
inputBind(INPUT_RIGHT, (inputsource_t)GLFW_KEY_D);
|
||||
inputBind(input, INPUT_UP, (inputsource_t)GLFW_KEY_UP);
|
||||
inputBind(input, INPUT_DOWN, (inputsource_t)GLFW_KEY_DOWN);
|
||||
inputBind(input, INPUT_LEFT, (inputsource_t)GLFW_KEY_LEFT);
|
||||
inputBind(input, INPUT_RIGHT, (inputsource_t)GLFW_KEY_RIGHT);
|
||||
inputBind(input, INPUT_UP, (inputsource_t)GLFW_KEY_W);
|
||||
inputBind(input, INPUT_DOWN, (inputsource_t)GLFW_KEY_S);
|
||||
inputBind(input, INPUT_LEFT, (inputsource_t)GLFW_KEY_A);
|
||||
inputBind(input, INPUT_RIGHT, (inputsource_t)GLFW_KEY_D);
|
||||
|
||||
// Init the render resolution
|
||||
renderSetResolution(WINDOW_WIDTH_DEFAULT, WINDOW_HEIGHT_DEFAULT);
|
||||
renderSetResolution(&game->engine.render,
|
||||
WINDOW_WIDTH_DEFAULT, WINDOW_HEIGHT_DEFAULT
|
||||
);
|
||||
|
||||
// Update the window title.
|
||||
glfwSetWindowTitle(window, GAME_STATE.name);
|
||||
@ -95,16 +98,17 @@ int32_t main() {
|
||||
}
|
||||
|
||||
void glfwOnResize(GLFWwindow *window, int32_t width, int32_t height) {
|
||||
renderSetResolution(width, height);
|
||||
renderSetResolution(&GAME_STATE.engine.render, width, height);
|
||||
}
|
||||
|
||||
void glfwOnKey(GLFWwindow *window,
|
||||
int32_t key, int32_t scancode, int32_t action, int32_t mods
|
||||
) {
|
||||
input_t *input = &GAME_STATE.engine.input;
|
||||
if(action == GLFW_PRESS) {
|
||||
INPUT_STATE.buffer[key] = 1;
|
||||
input->buffer[key] = 1;
|
||||
} else if(action == GLFW_RELEASE) {
|
||||
INPUT_STATE.buffer[key] = 0;
|
||||
input->buffer[key] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user