int main(int argc, char **argv) { t_env e; int i_x; int i_y; i_x = WIN_X * 2 / 5; i_y = WIN_Y * 2 / 5; if (argc == 2) { ft_parse(&e, argv[1]); ft_drawsettings(&e); e.mlx = mlx_init(); e.win = mlx_new_window(e.mlx, WIN_X, WIN_Y, "mlx42"); e.im = mlx_new_image(e.mlx, WIN_X, WIN_Y); e.imc = mlx_get_data_addr(e.im, &e.bpp, &e.imlen, &e.endi); mlx_string_put(e.mlx, e.win, i_x, i_y, 0xccccff, WELCOME); mlx_string_put(e.mlx, e.win, i_x + 16, i_y + 20, 0xccccff, START); mlx_hook(e.win, KEYPRESS, KEYPRESSMASK, ft_key_settings, &e); mlx_loop(e.mlx); } else ft_error("error : invalid number of arguments"); return (0); }
void advance_indice(t_glob *glob, int y) { static int count_part = 0; char *tmp; if (CALC_SIZEY / 100 * count_part == y) { aff_kikoo(glob, count_part); if (count_part <= 100 && !(count_part > 42 && count_part < 48) && !(count_part > 69 && count_part < 75)) { clean_percent(glob); mlx_string_put(glob->graph->mlx_ptr, glob->graph->win_ptr, AFF_SIZEX / 2 - 10, AFF_SIZEY / 2 + 15, AFF_COLOR, (tmp = my_putnbr_in_str((count_part)))); free(tmp); } mlx_string_put(glob->graph->mlx_ptr, glob->graph->win_ptr, AFF_SIZEX / 2 + 10, AFF_SIZEY / 2 + 15, AFF_COLOR, "%"); mlx_string_put(glob->graph->mlx_ptr, glob->graph->win_ptr, AFF_SIZEX * count_part / 100, AFF_SIZEY / 2, CHARG_COLOR, "|"); count_part++; } }
void how_to_use_it(t_gps *gps) { mlx_string_put(gps->mlx, gps->win, 10, 10, 0xFFFFFF, "9 / 6 : Zoom"); mlx_string_put(gps->mlx, gps->win, 10, 30, 0xFFFFFF, "+ / - : hauteur"); mlx_string_put(gps->mlx, gps->win, 10, 50, 0xFFFFFF, "Fleches dir. : se deplacer"); }
void draw_window(t_env *e) { int x; int y; void (*f)(int x, int y, t_env *e, int i); y = -1; e->data = mlx_get_data_addr(e->img, &(e->bpp), &(e->sl), &(e->endi)); if (ft_strcmp(e->fractal, "mandelbrot") == 0) (f) = &mandelbrot; else if (ft_strcmp(e->fractal, "julia") == 0) (f) = &julia; else if (ft_strcmp(e->fractal, "fisheye") == 0) (f) = &fisheye; else if (ft_strcmp(e->fractal, "burningship") == 0) (f) = &burningship; choose_palette(e); while (++y < WIN_Y && f) { x = -1; while (++x < WIN_X) f(x, y, e, 0); } mlx_put_image_to_window(e->mlx, e->win, e->img, 0, 0); mlx_string_put(e->mlx, e->win, 0, 2, 0x808080, "Fractale\t\t: "); mlx_string_put(e->mlx, e->win, 110, 2, 0x808080, e->fractal); }
void ft_write_op(t_coord *e) { mlx_string_put(e->mlx, e->win, 35, 35, HUD_COLOR, "Quit = ESC"); mlx_string_put(e->mlx, e->win, 35, 55, HUD_COLOR, "Move = ^ v < >"); mlx_string_put(e->mlx, e->win, 35, 75, HUD_COLOR, "Zoom = + -"); ft_put_hud(e); }
static void setup_scene_menu(t_env *env) { DIR *flux; struct dirent *dir; int y; int i; y = 300; i = 0; flux = opendir("./scenes"); env->menu->tab_scn = (char**)malloc(sizeof(char*) * 50); mlx_string_put(env->mlx, env->win_menu, 175, 115, 0xF00D532, "Liste des scenes"); while ((dir = readdir(flux))) { if (ft_strcmp(dir->d_name, "..") != 0 && ft_strcmp(dir->d_name, ".") != 0 && ft_strcmp(dir->d_name, "saved") != 0) { if (add_scene_to_tab(env->menu->tab_scn, dir->d_name, i) == 1) i++; } } add_scene_to_tab(env->menu->tab_scn, "", -i); closedir(flux); env->menu->nbr_scn = i; env->menu->page_max = i % 5; draw_scene_menu(env, env->menu->tab_scn); i = env->menu->index; mlx_string_put(env->mlx, env->win_menu, 130, 250 + (50 * i), 0xF00D532, "->"); }
int expose_julia(mlx_t *mlx) { if (mlx->img_julia) mlx_destroy_image(mlx->mlx_ptr, mlx->img_julia); mlx->img_julia = mlx_new_image(mlx->mlx_ptr, WIDTH, HEIGHT); mlx->data_julia = mlx_get_data_addr(mlx->img_julia, &(mlx->bpp), &(mlx->sizeline), &(mlx->endian)); reinit_julia(mlx); while (mlx->point_julia->x < WIDTH) { mlx->point_julia->y = 0; while(mlx->point_julia->y < HEIGHT) { give_c_julia_value(mlx); julia_while_calc(mlx); mlx->point_julia->y++; } mlx->point_julia->x++; } mlx_put_image_to_window(mlx->mlx_ptr, mlx->win_julia, mlx->img_julia, 0, 0); if (mlx->bonus_julia->locked == FALSE) mlx_string_put(mlx->mlx_ptr, mlx->win_julia,50,50, 0x00FF00, "UNLOCKED"); else mlx_string_put(mlx->mlx_ptr, mlx->win_julia,50,50, 0x00FF00, "LOCKED"); return (0); }
static void draw_str_menu(t_all *all) { char *enter; int i; char *str; char *tmp1; char *tmp2; i = 1; enter = "Please enter the NUMBER of the map you want to launch."; mlx_string_put(MLX, WIN, (MAPW - ft_strlen("WELCOME :D") * 10) / 2, (MAPH / 2) - 90, PINK, "WELCOME :D"); mlx_string_put(MLX, WIN, (MAPW - ft_strlen(enter) * 10) / 2, MAPH / 2, RED, enter); while (NAME[i]) { str = ft_itoa(i); tmp1 = ft_strjoin(" = ", NAME[i]); tmp2 = ft_strjoin(str, tmp1); mlx_string_put(MLX, WIN, (MAPW - (44 + ft_strlen(NAME[i]) * 10)) / 2, MAPH / 2 + 30 * i, GREEN, tmp2); ft_strdel(&tmp1); ft_strdel(&tmp2); ft_strdel(&str); i++; } }
void set_overlay(t_env *yolo) { mlx_string_put(yolo->mlx, yolo->win, 10, 20, BLUE, "Project : FDF"); mlx_string_put(yolo->mlx, yolo->win, 10, 40, BLUE, "Commands :"); mlx_string_put(yolo->mlx, yolo->win, 10, 60, WHITE, "Arrows = Move"); mlx_string_put(yolo->mlx, yolo->win, 10, 80, WHITE, "+/- = ZOOM/DEZOOM"); mlx_string_put(yolo->mlx, yolo->win, 10, 100, RED, "*// = Enlarge\ / Reduce"); mlx_string_put(yolo->mlx, yolo->win, 10, 120, RED, "ECS = Quit"); }
void render_menu(t_event *e) { mlx_string_put(e->mlx, e->win, e->width / 2 - 3 * 9, 5, 0xffffff, "WOLF3D"); mlx_string_put(e->mlx, e->win, e->width / 2 - 2 * 9, e->height / 2 - 22, (e->menu_select == 0) ? 0xff0000 : 0xffffff, "Play"); mlx_string_put(e->mlx, e->win, e->width / 2 - 7 * 9, e->height / 2 - 7, (e->menu_select == 1) ? 0xff0000 : 0xffffff, "Texture Editor"); mlx_string_put(e->mlx, e->win, e->width / 2 - 2 * 9, e->height / 2 + 8, (e->menu_select == 2) ? 0xff0000 : 0xffffff, "Exit"); }
void valuesdisplay(t_env *e) { int x; int y; x = e->arg.winx - 150; y = e->arg.winy - 100; mlx_string_put(e->mlx, e->win, x, y, 0xFFFFFF, "orix = "); mlx_string_put(e->mlx, e->win, x + 75, y, 0xFFFFFF, ft_itoa(e->orix)); mlx_string_put(e->mlx, e->win, x, y + 20, 0xFFFFFF, "oriy = "); mlx_string_put(e->mlx, e->win, x + 75, y += 20, 0xFFFFFF, ft_itoa(e->oriy)); }
void put_fps(t_env *env) { char *fps; if ((fps = ft_itoa(env->fps))) { mlx_string_put(env->window->mlx, env->window->mlx_window , 11, 11, 0x000000, fps); mlx_string_put(env->window->mlx, env->window->mlx_window , 10, 10, 0xFF0000, fps); free(fps); } }
static void aff(int i, t_glob *g, char *s) { if (ft_strlen(s) == 1) { mlx_string_put(g->e->mlx, g->e->win, g->e->x_0 + 6, g->e->y_0 + 15, ft_color(g, i), "0"); mlx_string_put(g->e->mlx, g->e->win, g->e->x_0 + 16, g->e->y_0 + 15, ft_color(g, i), s); } else mlx_string_put(g->e->mlx, g->e->win, g->e->x_0 + 6, g->e->y_0 + 15, ft_color(g, i), s); }
void ft_welcome(t_env *e) { int x; int y; x = 510; y = 200; mlx_string_put(e->mlx, e->win, x + 50, y, 0x009999FF, WELCOME); mlx_string_put(e->mlx, e->win, x - 20, y + 30, 0x009999FF, SELECT); mlx_string_put(e->mlx, e->win, x + 70, y + 60, 0x009999FF, EASY); mlx_string_put(e->mlx, e->win, x + 70, y + 80, 0x009999FF, MEDIUM); mlx_string_put(e->mlx, e->win, x + 70, y + 100, 0x009999FF, HARD); }
int ft_wolf3d(t_glob *gl) { gl->img = mlx_new_image(gl->mlx, gl->s_x, gl->s_y); gl->disp = mlx_get_data_addr(gl->img, &(gl->bpp), &(gl->sizeline), &(gl->endian)); ft_move_rot(gl); ft_detect_wall(gl); mlx_string_put(gl->mlx, gl->win, 20, 20, 0xFFFFFF, "FPS : "); mlx_string_put(gl->mlx, gl->win, 80, 20, 0xFFFFFF, ft_itoa(1.0 / gl->ftime)); if (gl->sprint) gl->ms = gl->ms * 2; return (0); }
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); }
static void aff_kikoo(t_glob *glob, int count_part) { if (count_part == 0) mlx_string_put(glob->graph->mlx_ptr, glob->graph->win_ptr, 5, 15, AFF_COLOR, "Raytracing de la scene en cours..."); if (count_part == 42) mlx_string_put(glob->graph->mlx_ptr, glob->graph->win_ptr, 5, 30, AFF_COLOR, "Just take a break to enjoy the 42 !"); if (count_part == 69) mlx_string_put(glob->graph->mlx_ptr, glob->graph->win_ptr, 5, 45, AFF_COLOR, "Just take another to enjoy the 69 !"); if (count_part == 90) mlx_string_put(glob->graph->mlx_ptr, glob->graph->win_ptr, 5, 60, AFF_COLOR, "Bientot fini ! ;)"); }
void Xaxis_bis(t_mlx *ptr) { mlx_string_put(ptr->mlx, ptr->win, 45, 15, 0xFFFFFF, "X (nombre de bombyx)"); mlx_string_put(ptr->mlx, ptr->win, 95, 39, 0xFFFFFF, "/\\"); mlx_string_put(ptr->mlx, ptr->win, 90, 1020, 0xFFFFFF, "1.0"); mlx_string_put(ptr->mlx, ptr->win, 250, 1020, 0xFFFFFF, "1.5"); mlx_string_put(ptr->mlx, ptr->win, 400, 1020, 0xFFFFFF, "2.0"); mlx_string_put(ptr->mlx, ptr->win, 550, 1020, 0xFFFFFF, "2.5"); mlx_string_put(ptr->mlx, ptr->win, 700, 1020, 0xFFFFFF, "3.0"); mlx_string_put(ptr->mlx, ptr->win, 850, 1020, 0xFFFFFF, "3.5"); mlx_string_put(ptr->mlx, ptr->win, 1000, 1020, 0xFFFFFF, "4.0"); }
int loop_hook(t_event *e) { if (e->menu == MAIN_MENU) control_menu(e); else if (e->menu == GAME) control_player(e); else if (e->menu == TEXTURE_EDITOR) control_edit_tex(e); clear(e); if (e->menu == GAME) { render_map(e); render_minimap(e); } else if (e->menu == TEXTURE_EDITOR) render_edit_tex(e); mlx_put_image_to_window(e->mlx, e->win, e->img.addr, 0, 0); if (e->menu == GAME) mlx_string_put(e->mlx, e->win, 5, e->height - 22, 0xffffff, "Arrow or WASD to move and rotate"); if (e->menu == MAIN_MENU) render_menu(e); else if (e->menu == TEXTURE_EDITOR) render_edit_tex_gui(e); return (0); }
void w_draw_form(t_env *e) { t_coord pos; t_coord dim; dim.x = 30; dim.y = 30; pos.x = 5; pos.y = 5; create_img(e, dim, "xpm/close.xpm", pos); dim.x = 36; dim.y = 12; pos.x = 200; pos.y = e->height / 6; if (e->set->color == 1) create_img(e, dim, "xpm/on.xpm", pos); else create_img(e, dim, "xpm/off.xpm", pos); pos.y = 5 * e->height / 6; mlx_string_put(e->mlx, e->win, 200, pos.y - 5, 0xff1212, "Beta !"); if (e->set->straff == 1) create_img(e, dim, "xpm/on.xpm", pos); else create_img(e, dim, "xpm/off.xpm", pos); dim.x = 200; pos.y = 3 * e->height / 6; draw_cursor(e, dim, pos, 0x8904B1); }
void draw_winner(t_env *e) { int i; char *s[2]; t_clist *save; i = 15; save = e->clist; while (save) { if (save->client_nb == 0) { save = save->next; continue ; } i += 15; asprintf(&s[0], PL3, save->client_nb, save->lvl, save->posy, save->posx, fill_ori(save), save->inv[0], save->inv[1], save->inv[2], save->inv[3], save->inv[4], save->inv[5], save->inv[6], save->teamname); mlx_string_put(e->mlx->mlx, e->mlx->win2, 5, i, WHITE, s[0]); save = save->next; free(s[0]); } i += 15; asprintf(&s[0], "%s won the game !", e->winner); MSP(MLX->mlx, MLX->win2, INFO_WIDTH / 2 - STR_WIN_LEN, i, WHITE, s[0]); }
int ft_move(t_env *env) { env->adr = mlx_new_image(env->mlx, env->win_h, env->win_l); env->img = mlx_get_data_addr(env->adr, &env->bpp, &env->sl, &env->endian); ft_fractal(env); mlx_put_image_to_window(env->mlx, env->win, env->adr, 0, 0); mlx_string_put(env->mlx, env->win, 50, 5, 0xff0000, "zoom:"); mlx_string_put(env->mlx, env->win, 50, 30, 0xff0000, ft_itoa(env->zoom)); mlx_string_put(env->mlx, env->win, 390, 30, 0xff0000, ft_itoa(env->imax)); mlx_string_put(env->mlx, env->win, 390, 5, 0xff0000, "iteration:"); return (0); }
void display_cycle(t_dmlx *m, t_dvm *v) { char txt[500]; mlx_string_put(m->mlx, m->win, TEXTCYCLEX - ((ft_strlen(ft_strcpy(txt , ft_itoastatic(v->cycle))) / 2) * TXTDECALLAGEX) , TEXTCYCLEY, TXTCOLACTUAL, txt); mlx_string_put(m->mlx, m->win, TEXTCPERLOOPX - ((ft_strlen(ft_strcpy(txt , ft_itoastatic(v->cperloop))) / 2) * TXTDECALLAGEX) , TEXTCPERLOOPY, TXTCOLACTUAL, txt); mlx_string_put(m->mlx, m->win, TEXTCTODIECOUNTX - ((ft_strlen(ft_strcpy(txt , ft_itoastatic(v->ctodiecount))) / 2) * TXTDECALLAGEX) , TEXTCTODIECOUNTY, TXTCOLACTUAL, txt); mlx_string_put(m->mlx, m->win, TEXTCTODIEX, TEXTCTODIEY, TXTCOLCTODIE , ft_itoastatic(v->ctodie)); }
void print_load_msg(char *s, t_all *all) { int len; len = my_strlen(s); len = (WIN_X / 2) - (len / 2) * 6; mlx_string_put(all->mlx_ptr, all->win_ptr, len, 2 * WIN_Y / 3 - 10, 0xaa77ff, s); }
int ft_expose_hook(t_data *data) { mlx_clear_window(data->mlx, data->win); mlx_string_put(data->mlx, data->win, 10, 10, 0x00FFFF, "(H)MENU"); ft_putdot(data, data->new1, -1, -1); return (0); }
int draw_map(t_all *all) { char *legende1; char *legende2; legende1 = "ESC to quit || ENTER to return Menu || DEL to delete"; legende2 = "'-' or '+' to zoom || 'W-A-S-D' to move || UP and DOWN \ to change Z || 'Q-E-LEFT-RIGHT' to incline Y"; zmin_and_zmax(all); draw_point_y(all); draw_point_x(all); mlx_string_put(MLX, WIN, (MAPW - ft_strlen(legende1) * 11) / 2, MAPH - 60, YELLOW, legende1); mlx_string_put(MLX, WIN, (MAPW - ft_strlen(legende2) * 11) / 2, MAPH - 30, YELLOW, legende2); return (1); }
int fdf(t_env *env) { t_node *tmp; char *str; str = ft_itoa(env->param->zoom); tmp = env->map; while (tmp) { draw_line(env, tmp); tmp = tmp->next; } mlx_put_image_to_window(env->mlx, env->win, env->img->img, 0, 0); mlx_string_put(env->mlx, env->win, 695, 791, 0xAEECFE, "Current zoom x"); mlx_string_put(env->mlx, env->win, 839, 791, 0xFFFFFF, str); free(str); str = ft_itoa(env->param->xdefault); mlx_string_put(env->mlx, env->win, 170, 791, 0xAEECFE, "position.x = "); mlx_string_put(env->mlx, env->win, 300, 791, 0xFFFFFF, str); free(str); str = ft_itoa(env->param->ydefault); mlx_string_put(env->mlx, env->win, 170, 811, 0xAEECFE, "position.y = "); mlx_string_put(env->mlx, env->win, 300, 811, 0xFFFFFF, str); free(str); str = (env->proj) ? "Current proj : par" : "Current proj : iso"; mlx_string_put(env->mlx, env->win, 695, 811, 0xAEECFE, str); return (0); }
void Xaxis(t_mlx *ptr) { mlx_string_put(ptr->mlx, ptr->win, 45, 15, 0xFFFFFF, "X (nombre de bombyx)"); mlx_string_put(ptr->mlx, ptr->win, 95, 39, 0xFFFFFF, "/\\"); mlx_string_put(ptr->mlx, ptr->win, 90, 1020, 0xFFFFFF, "0"); mlx_string_put(ptr->mlx, ptr->win, 300, 1020, 0xFFFFFF, "20"); mlx_string_put(ptr->mlx, ptr->win, 500, 1020, 0xFFFFFF, "40"); mlx_string_put(ptr->mlx, ptr->win, 700, 1020, 0xFFFFFF, "60"); mlx_string_put(ptr->mlx, ptr->win, 900, 1020, 0xFFFFFF, "80"); mlx_string_put(ptr->mlx, ptr->win, 1100, 1020, 0xFFFFFF, "100"); }
void print_title_bis(char *i_min, char *i_max, t_mlx *ptr) { mlx_string_put(ptr->mlx, ptr->win, 1520, 225, 0xFFFFFF, "106bombyx"); mlx_string_put(ptr->mlx, ptr->win, 1490, 250, 0xFFFFFF, "blanqu_a / dubosc_a"); mlx_string_put(ptr->mlx, ptr->win, 1420, 325, 0xFFFFFF, "Graphique representant le nombre x de bombyx"); mlx_string_put(ptr->mlx, ptr->win, 1450, 350, 0xFFFFFF, "en fonction du taux de croissance"); mlx_string_put(ptr->mlx, ptr->win, 1480, 400, 0xFFFFFF, "Donnees: i_min = "); mlx_string_put(ptr->mlx, ptr->win, 1590, 400, 0xFFFFFF, i_min); mlx_string_put(ptr->mlx, ptr->win, 1535, 425, 0xFFFFFF, "i_max = "); mlx_string_put(ptr->mlx, ptr->win, 1590, 425, 0xFFFFFF, i_max); }
void cartridge(t_all *all) { mlx_string_put(all->env.mlx, all->env.win, 10, 15, 0xFFC700, "Fractal:"); mlx_string_put(all->env.mlx, all->env.win, 90, 15, 0xFFC700, all->name); mlx_string_put(all->env.mlx, all->env.win, 10, 30, 0xFFC700, "CUDA:"); mlx_string_put(all->env.mlx, all->env.win, 90, 30, (all->cuda_frac ? 0x00FF00 : 0XFF0000), (all->cuda_frac ? "ON" : "OFF")); mlx_string_put(all->env.mlx, all->env.win, 10, 45, 0xFFC700, "Iterations:"); mlx_string_put(all->env.mlx, all->env.win, 90, 45, 0xFFC700, ft_itoa(all->ite_max)); mlx_string_put(all->env.mlx, all->env.win, 500, 15, 0xFFC700, "Iteration +/- : A/D"); mlx_string_put(all->env.mlx, all->env.win, 500, 30, 0xFFC700, "Navigation : Arrows"); mlx_string_put(all->env.mlx, all->env.win, 500, 45, 0xFFC700, "Zoom : Scroll Mouse"); mlx_string_put(all->env.mlx, all->env.win, 500, 60, 0xFFC700, "Exit : ESC"); }