int main(int ac, char **av) { t_env e; if (ac == 2 && av) { if (!(e.mlx = mlx_init())) exit_gracefully("mlx_init: Connexion to Xserver failed."); if (!(e.win = mlx_new_window(e.mlx, WIDTH, HEIGHT, "Wolf3D"))) exit_gracefully("mlx_new_window: Could not create window."); if (!(e.img = mlx_new_image(e.mlx, WIDTH, HEIGHT))) exit_gracefully("mlx_new_image: Could not create image."); if (!(e.table = mlx_get_data_addr(e.img, &e.bpp, &e.size, &e.endian))) exit_gracefully("mlx_get_data_addr: Could not read data."); ft_count_columns(&e, av[1]); e.x = e.map_line / 2; e.y = e.map_col / 2; ft_line(&e, 1.2); ft_draw(&e); mlx_expose_hook(e.win, &ft_exposehook, &e); mlx_hook(e.win, KeyPress, KeyPressMask, &ft_keypress, &e); mlx_loop(e.mlx); } else exit_gracefully("\033[33mUsage : ./wolf3d <map.name>\033[0m"); return (0); }
void Play_Cut_Ten( void ) { SYS_SOUNDHANDLE sample_one; sample_one = SYS_LoadSound( "wav_data/computer/narr10.wav" ); if( sample_one == NULL ) { fprintf(stderr, "Bad wav in cut one \n"); exit_gracefully(); } if( game_configuration.sound_on ) Play_Voice( sample_one ); sprintf(load_string, "%c:/fli/ten.fli", cdrom_drive_letter ); Play_Fli_Buffered(load_string); if( game_configuration.sound_on ) while( !Is_Voice_Done() ); sb_free_sample( sample_one ); } /* End of Play_Cut_Ten() */
int ft_keypress(int keycode, t_env *e) { if (keycode == 65307) exit_gracefully("You exited the program"); mlx_clear_window(e->mlx, e->win); ft_draw(e); return (0); }
void handle_signals(int signo) { if(signo == SIGTERM) printf("\n[*] Received SIGTERM.\n"); else if(signo == SIGINT) printf("\n[*] Received SIGTERM.\n"); exit_gracefully(); }
void Play_Intro_Animation( void ) { SYS_SOUNDHANDLE sample_one, sample_two, sample_three; sb_mod_file *my_mod; my_mod = sb_load_mod_file( "anything.mod" ); sample_one = SYS_LoadSound( "wav_data/computer/intro1.wav" ); sample_two = SYS_LoadSound( "wav_data/computer/intro2.wav" ); sample_three = SYS_LoadSound( "wav_data/computer/intro3.wav" ); if( sample_one == NULL || sample_two == NULL || sample_three == NULL ) { fprintf(stderr, "Bad wav in intro \n"); exit_gracefully(); } if( game_configuration.sound_on ) { sb_mod_play(my_mod); Play_Voice( sample_one ); } sprintf(load_string, "%c:/fli/house.fli", cdrom_drive_letter ); Play_Fli_Buffered(load_string); if( game_configuration.sound_on ) while( !Is_Voice_Done() ); sprintf(load_string, "%c:/fli/logo.fli", cdrom_drive_letter ); if( game_configuration.sound_on ) Play_Voice( sample_two ); Play_Fli_Buffered(load_string); if( game_configuration.sound_on ) while( !Is_Voice_Done() ); if( game_configuration.sound_on ) { Play_Voice( sample_three ); while( !Is_Voice_Done() ); } if( game_configuration.sound_on ) sb_mod_pause(); sb_free_sample( sample_one ); sb_free_sample( sample_two ); sb_free_sample( sample_three ); sb_free_mod_file( my_mod ); } /* End of Play_Intro_Animation() */
int main() { /* Set a custom error handler */ turtle_error_handler_set(&handle_error); /* Create the stack of global elevation data */ turtle_stack_create(&stack, "share/topography", 0, NULL, NULL); /* * Create a RGF93 local projection map, centered on the Auberge des * Gros Manaux at Col de Ceyssat, Auvergne, France */ const int nx = 201; const int ny = 201; struct turtle_map_info info = { .nx = 201, .ny = 201, .x = { 693530.7, 699530.7 }, .y = { 6515284.5, 6521284.5 }, .z = { 500., 1500. } }; turtle_map_create(&map, &info, "Lambert 93"); const struct turtle_projection * rgf93 = turtle_map_projection(map); /* Fill the local map from the global data */ int ix, iy; for (ix = 0; ix < nx; ix++) for (iy = 0; iy < ny; iy++) { /* Get the node geodetic coordinates */ double x, y, latitude, longitude; turtle_map_node(map, ix, iy, &x, &y, NULL); turtle_projection_unproject( rgf93, x, y, &latitude, &longitude); /* Fill the elevation */ double elevation; turtle_stack_elevation( stack, latitude, longitude, &elevation, NULL); turtle_map_fill(map, ix, iy, elevation); } /* Dump the projection map to disk */ turtle_map_dump(map, "share/data/pdd-30m.png"); /* Clean and exit */ exit_gracefully(TURTLE_RETURN_SUCCESS); }
/* Handler for TURTLE library errors */ void handle_error(enum turtle_return code, turtle_function_t * function, const char * message) { fprintf(stderr, "A TURTLE library error occurred:\n%s\n", message); exit_gracefully(EXIT_FAILURE); }