void move_ball(t_all *all) { int ret; if ((ret = set_ball_pos(&all->ball.pos.y, all->ball.pos.y + all->ball.vspeed.y, -1.5, 1)) <= 0) { if (ret == -1) all->ball.vspeed.y = -all->ball.vspeed.y; else { init_ball(&all->ball); init_ship(&all->ship); if (--all->life == 0) ft_print_shell(all, "Vous avez perdu !!"); all->cur = 1; } } if (set_ball_pos(&all->ball.pos.x, all->ball.pos.x + all->ball.vspeed.x, -1, 1) == -1) all->ball.vspeed.x = -all->ball.vspeed.x; if (check_ship_collision(&all->ball, &all->ship) == TRUE) ball_rebound(&all->ball, &all->ship); if (check_brick_collision(&all->ball, &all->map)) all->score += 10; }
void cursor_position_callback( GLFWwindow* window, double x, double y ) { cursor_x = (float) x; cursor_y = (float) y; if ( override_pos ) set_ball_pos(cursor_x, cursor_y); }
void mouse_button_callback( GLFWwindow* window, int button, int action, int mods ) { if (button != GLFW_MOUSE_BUTTON_LEFT) return; if (action == GLFW_PRESS) { override_pos = GLFW_TRUE; set_ball_pos(cursor_x, cursor_y); } else { override_pos = GLFW_FALSE; } }