int run_epikong() { t_map map; char *path; if ((path = init_screen()) == NULL) return (EXIT_FAILURE); if (start_music() == EXIT_FAILURE) return (EXIT_FAILURE); if (start_parsing(path, &map) == EXIT_FAILURE) return (EXIT_FAILURE); if (get_monster(&map) == EXIT_FAILURE) return (EXIT_FAILURE); if (get_hero(&map) == EXIT_FAILURE) return (EXIT_FAILURE); if (parse_map(&map) == EXIT_FAILURE) return (EXIT_FAILURE); return (EXIT_SUCCESS); }
/* Purpose: test the music functions Input : the array of music notes Returns: ouputs music Assume : nothing */ int main() { int j = 0; int i = 0; int music[104]; music = get_music(); start_music(); for (i = 0; i < 104; i++){ play_music(music[i]); while (j < 32000) j++ } stop_music(); return 0; }
int main(int ac, char **av) { t_visu *visu; if (ac == 2 && my_strcmp(av[1], "--help") == 0) return (show_help()); if ((visu = bunny_malloc(sizeof(t_visu))) == NULL) return (-1); visu->start_rendu = 0; if (!(visu->win = bunny_start(WIDTH, HEIGHT, false, "LEMIN DISPLAYER")) || (!(visu->pix = bunny_new_pixelarray(WIDTH, HEIGHT))) || (check_args(visu) == -1) || (load_ant(visu, av[1]) == -1) || (load_screen(visu, av[1]) == -1) || (start_music(visu, av[1]) == -1) || (init_ant_struct(visu) == -1)) return (-1); visu->rooms = reverse_rooms(visu->rooms); bunny_set_key_response(events); bunny_set_loop_main_function(main_loop); bunny_loop(visu->win, 60, visu); close_music(visu); delete_all_clipables(visu); free_all(visu); return (0); }
/* Purpose: animate and run the game with the clock Input : a char length pointer to the frame buffer and a long length pointer to the frame buffer Returns: nothing, but constantly runs the game and its functions Assume : nothing */ void animate_main(char *base,long *iBase) { long *back,*temp; int musicCounter = 0; int enMisCount = 0; int plMisCount = 0; int x,y = 0; long clock; long newClock; int mouseClicked = 0; unsigned short mouseX,mouseY; int i= 0,j = 0,k = 0,l = 0; int randX,randY,randX2; int fire = 0; int s = 0; int done = 0; int render = 0; struct missile friendlyMis[NUM_MISSILES]; struct missile enemyMis[NUM_MISSILES]; struct explosion explosions[NUM_EXPLOSIONS]; struct missile_Silo silo; struct city city1; struct city city2; struct city city3; struct city city4; struct city city5; struct city city6; int *music = get_music(); Vector original_Vector; /*start the music*/ stop_sound(); start_music(); /*init ther model*/ initialize_model(&city1,&city2,&city3,&city4,&city5,&city6,&silo,friendlyMis,enemyMis,explosions); /*create the backbuffer*/ back = (long *)(buffer + (256 -((long)&buffer)%256)); init_VBL_ISR(original_Vector); while(done == 0) { /*random values for enemy missiles*/ randX = rand() % BORDER_RIGHT + 16; randX2 = rand() % BORDER_RIGHT + 16; randY = rand() % GROUND_LEVEL - 200; /* needs to fire a player missile at the mouse click coordinates */ if (mouseClicked == TRUE) { /* process on input */ if (k > NUM_MISSILES-1) { k = 0; } if (friendlyMis[k].destroyed == TRUE) { friendlyMis[k].destroyed = FALSE; friendlyMis[k].currentY = GROUND_LEVEL-20; friendly_Missile_Fired(mouseX,mouseY, &friendlyMis[k],MISSILE_SILO_FIRING_POINT); missile_fired_sound(); k++; } } clock = clockGet(); if (clock != newClock) { /* process on clock change */ fire++; if(fire == MISSILE_FIRED_TIME) { enemyMis[j].destroyed = FALSE; enemy_Missile_Fired(randX, GROUND_LEVEL, &enemyMis[j],randX2); j++; if(fire == MISSILE_FIRED_TIME) { fire = 0; } if (j == NUM_MISSILES-1) { j = 0; } } mouseClicked = get_mouse_pos(&mouseX,&mouseY); if(render == 1) { render_main(back, city1, city2, city3, city4, city5, city6, silo, enemyMis,friendlyMis, explosions,mouseX,mouseY,render); } /* T */ temp = iBase; iBase = back; back = temp; /* wait for sync and then set the screen to the current buffer */ set_video_base_wrap((char *)iBase); /* process missiles might need to change to be able to handle more */ for (i = 0; i < NUM_MISSILES; i++) { if (enemyMis[i].destroyed == FALSE && explosions[i].exists == FALSE) { processEnemyMissiles(&enemyMis[i],&explosions[i],clock,ENEMY_SPEED); } if (friendlyMis[i].destroyed == FALSE && explosions[i+NUM_MISSILES].exists == FALSE) { processEnemyMissiles(&friendlyMis[i],&explosions[i+NUM_MISSILES],clock,FRIENDLY_SPEED); } } /* process explosions might need to change to be able to handle more */ for (i = 0; i < NUM_EXPLOSIONS; i++) { if (explosions[i].exists == TRUE) { processExplosions(&explosions[i]); } } /* process missile -> explosion collisions */ for (i = NUM_MISSILES; i < NUM_EXPLOSIONS; i++) { if (explosions[i].exists == TRUE) { processCollisions(friendlyMis,enemyMis,explosions[i]); } } /* process explosion -> city explosions */ for (i = 0; i < NUM_MISSILES; i++) { if (explosions[i].hit_city != FALSE) { city_collision(explosions[i].hit_city,&city1,&city2,&city3,&city4,&city5,&city6); } } if (musicCounter < SONG_LENGTH){ if (fire % 4 == 0) { play_music(music[musicCounter]); musicCounter++; } } else { musicCounter = 0; } } newClock = clockGet(); done = game_over(city1,city2,city3,city4,city5,city6); } stop_sound(); }