void ft_go(t_struct **matr) { ft_expose(matr); mlx_string_put(matr[0]->mlx, matr[0]->win, 600, 200, 0xFF0000, "3"); sleep(1); ft_expose(matr); mlx_string_put(matr[0]->mlx, matr[0]->win, 600, 200, 0xBB5500, "2"); sleep(1); ft_expose(matr); mlx_string_put(matr[0]->mlx, matr[0]->win, 600, 200, 0x55BB00, "1"); sleep(1); ft_expose(matr); mlx_string_put(matr[0]->mlx, matr[0]->win, 600, 200, 0x00FF00, "GO !!"); sleep(1); }
int ft_relaise(int key, t_struct **matr) { if (key == 65307) exit (0); if (key == 65361) matr[0]->player->turn = 0; if (key == 65363) matr[0]->player->turn = 0; if (key == 65362) matr[0]->player->move = 0; if (key == 65364) matr[0]->player->move = 0; ft_expose(matr); return (0); }
int ft_mask(int key, t_struct **matr) { if (key == 65307) { ft_freeall(matr); exit (0); } if (key == 65361) matr[0]->player->turn = 1; if (key == 65363) matr[0]->player->turn = 2; if (key == 65362) matr[0]->player->move = 1; if (key == 65364) matr[0]->player->move = 2; ft_expose(matr); return (0); }
void ft_aliase_fin(t_env *env, int ***img) { int i; int j; i = -1; while (++i < env->dt->y_max) { j = -1; while (++j < env->dt->x_max) { img[i][j][0] = img[i][j][0] / (1 + 4 * env->dt->opt_aa); img[i][j][1] = img[i][j][1] / (1 + 4 * env->dt->opt_aa); img[i][j][2] = img[i][j][2] / (1 + 4 * env->dt->opt_aa); ft_mlx_add_col(env->dt, img[i][j], j, i); free(img[i][j]); } free(img[i]); } free(img); ft_expose(env); }
int ft_key(t_struct **matr) { double t; t = matr[0]->player->direction; matr[0]->player->inertie += fmod((t - matr[0]->player->inertie) * 1.5, 380); if (matr[0]->player->turn == 1 && (matr[0]->i > 40 || matr[0]->i < -40)) matr[0]->player->direction = matr[0]->i > 0 ? t + 0.6 : t - 0.6; if (matr[0]->player->turn == 2 && (matr[0]->i > 40 || matr[0]->i < -40)) matr[0]->player->direction = matr[0]->i < 0 ? t + 0.6 : t - 0.6; if (matr[0]->player->turn != 0) matr[0]->i = (matr[0]->i > 0) ? matr[0]->i - 1 : matr[0]->i + 1; if (matr[0]->player->move == 1) matr[0]->i = (matr[0]->i + 2) < 1800 ? matr[0]->i + 9 : 1800; else if (matr[0]->player->move == 2) matr[0]->i = (matr[0]->i - 4) > -800 ? matr[0]->i - 7 : -800; matr[0]->i = (matr[0]->i - 4) > 0 ? matr[0]->i - 4 : matr[0]->i + 4; if (matr[0]->i > 0) matr = ft_colision_up(matr, matr[0]->i/10); else matr = ft_colision_down(matr, matr[0]->i/10); ft_expose(matr); return (1); }