int main(int ac, char **av) { t_env e; ft_singleton(&e); e.lvl_list = NULL; if (!check_levels(ac, av, &e) || !glfwInit()) return (-1); e.maxscore = 0; e.lvl = 0; e.window = glfwCreateWindow(WINX, WINY, "Arkanoid", NULL, NULL); if (!e.window) { glfwTerminate(); return (-1); } glfwMakeContextCurrent(e.window); init_hooks(&e); ft_start_game(&e); while (!glfwWindowShouldClose(e.window) && e.state) { rule_them_all(&e); glfwPollEvents(); } glfwTerminate(); ft_put(e); return (0); }
void key_callback(GLFWwindow *window, int key, int scancode, int action, int mods) { if (key == GLFW_KEY_ESCAPE && action == GLFW_PRESS) glfwSetWindowShouldClose(window, GL_TRUE); else if (key == GLFW_KEY_SPACE && (action == GLFW_PRESS || action == GLFW_REPEAT)) ft_space(ft_singleton(NULL)); if (scancode && mods) mods = scancode; }
int main(void) { t_bal bal; t_brick brick; t_env e; init_env(&e); ft_singleton(&e); init_val(&bal); e.map = get_map("level/level1.txt"); e.curr_map = 1; init_window(&e); glfwSetKeyCallback(e.window, key_callback); glfwGetFramebufferSize(e.window, &e.width, &e.height); glClearColor(0.f, 0.f, 0.f, 0.0f); boucle_principal(&bal, &brick, &e); glfwTerminate(); return (0); }