void restart() { if (tune != NULL) { stop_midi(); done = 0; play_midi(tune, 0); } }
void music_stop() { //al_stop_duh(tmplayer); //unload_duh(tmusic); //tmusic=NULL; //tmplayer=NULL; zcmusic_stop(zcmusic); zcmusic_unload_file(zcmusic); stop_midi(); set_midi_paused(false); currmidi=0; }
void som::parar() { if (tipo == T_WAV) { if(!smp) return; stop_sample(smp); } else if (tipo == T_MID) { if(!mid) return; stop_midi(); } }
// Run an NSF, or a MIDI if the NSF is missing somehow. bool try_zcmusic(char *filename, int track, int midi) { ZCMUSIC *newzcmusic = NULL; // Try the ZC directory first { char exepath[2048]; char musicpath[2048]; get_executable_name(exepath, 2048); replace_filename(musicpath, exepath, filename, 2048); newzcmusic=(ZCMUSIC*)zcmusic_load_file(musicpath); } // Not in ZC directory, try the quest directory if(newzcmusic==NULL) { char musicpath[2048]; replace_filename(musicpath, qstpath, filename, 2048); newzcmusic=(ZCMUSIC*)zcmusic_load_file(musicpath); } // Found it if(newzcmusic!=NULL) { zcmusic_stop(zcmusic); zcmusic_unload_file(zcmusic); stop_midi(); zcmusic=newzcmusic; zcmusic_play(zcmusic, emusic_volume); if(track>0) zcmusic_change_track(zcmusic,track); return true; } // Not found, play MIDI - unless this was called by a script (yay, magic numbers) else if(midi>-1000) jukebox(midi); return false; }
void newGame() { BITMAP *loadScreen = NULL; loadScreen = load_bitmap("Loading Screen.bmp", NULL); // Load our picture BITMAP *newBuffer = NULL; newBuffer = create_bitmap(1024,768); //Create an empty bitmap. float creditPosition = 1024; int aKey = -1; creditPosition = advanceCredits(0, creditPosition); creditPosition = advanceCredits(735, creditPosition); creditPosition = advanceCredits(1590, creditPosition); creditPosition = advanceCredits(2500, creditPosition); stop_midi(); SAMPLE *transmission1 = load_sample("Transmission1.wav"); play_sample(transmission1, 255, 0, 1000, 0); fallingText(); stop_sample(transmission1); draw_sprite(newBuffer, loadScreen, 0, 0); blit(newBuffer, screen, 0,0,0,0,1024,768);//Draw the buffer to the screen while (!key[KEY_SPACE]) { readkey(); } return; }
int main(int argc, char *argv[]) { int c, w, h; char buf[256], buf2[256]; ANIMATION_TYPE type; for (c = 1; c < argc; c++) { if (stricmp(argv[c], "-cheat") == 0) cheat = TRUE; if (stricmp(argv[c], "-jumpstart") == 0) jumpstart = TRUE; } /* The fonts we are using don't contain the full latin1 charset (not to * mention Unicode), so in order to display correctly author names in * the credits with 8-bit characters, we will convert them down to 7 * bits with a custom mapping table. Fortunately, Allegro comes with a * default custom mapping table which reduces Latin-1 and Extended-A * characters to 7 bits. We don't even need to call set_ucodepage()! */ set_uformat(U_ASCII_CP); srand(time(NULL)); if (allegro_init() != 0) return 1; install_keyboard(); install_timer(); install_mouse(); if (install_sound(DIGI_AUTODETECT, MIDI_AUTODETECT, NULL) != 0) { allegro_message("Error initialising sound\n%s\n", allegro_error); install_sound(DIGI_NONE, MIDI_NONE, NULL); } if (install_joystick(JOY_TYPE_AUTODETECT) != 0) { allegro_message("Error initialising joystick\n%s\n", allegro_error); install_joystick(JOY_TYPE_NONE); } if (set_gfx_mode(GFX_AUTODETECT, 320, 200, 0, 0) != 0) { if (set_gfx_mode(GFX_SAFE, 320, 200, 0, 0) != 0) { set_gfx_mode(GFX_TEXT, 0, 0, 0, 0); allegro_message("Unable to set any graphic mode\n%s\n", allegro_error); return 1; } } get_executable_name(buf, sizeof(buf)); replace_filename(buf2, buf, "demo.dat", sizeof(buf2)); set_color_conversion(COLORCONV_NONE); data = load_datafile(buf2); if (!data) { set_gfx_mode(GFX_TEXT, 0, 0, 0, 0); allegro_message("Error loading %s\n", buf2); exit(1); } if (!jumpstart) { intro_screen(); } clear_bitmap(screen); set_gui_colors(); set_mouse_sprite(NULL); if (!gfx_mode_select(&c, &w, &h)) exit(1); if (pick_animation_type(&type) < 0) exit(1); init_display(c, w, h, type); generate_explosions(); //stop_sample(data[INTRO_SPL].dat); clear_bitmap(screen); while (title_screen()) play_game(); destroy_display(); destroy_explosions(); stop_midi(); set_gfx_mode(GFX_TEXT, 0, 0, 0, 0); end_title(); unload_datafile(data); allegro_exit(); return 0; }
void StopMusic(void) { stop_midi(); }
void MusicDriver_Allegro::StopSong() { stop_midi(); }
void Sound::Sound::stop () { if (midi) stop_midi (); }
void play_DmapMusic() { static char tfile[2048]; static int ttrack=0; bool domidi=false; // Seems like this ought to call try_zcmusic()... if(DMaps[currdmap].tmusic[0]!=0) { if(zcmusic==NULL || strcmp(zcmusic->filename,DMaps[currdmap].tmusic)!=0 || (zcmusic->type==ZCMF_GME && zcmusic->track != DMaps[currdmap].tmusictrack)) { if(zcmusic != NULL) { zcmusic_stop(zcmusic); zcmusic_unload_file(zcmusic); zcmusic = NULL; } // Try the ZC directory first { char exepath[2048]; char musicpath[2048]; get_executable_name(exepath, 2048); replace_filename(musicpath, exepath, DMaps[currdmap].tmusic, 2048); zcmusic=(ZCMUSIC*)zcmusic_load_file(musicpath); } // Not in ZC directory, try the quest directory if(zcmusic==NULL) { char musicpath[2048]; replace_filename(musicpath, qstpath, DMaps[currdmap].tmusic, 2048); zcmusic=(ZCMUSIC*)zcmusic_load_file(musicpath); } if(zcmusic!=NULL) { stop_midi(); strcpy(tfile,DMaps[currdmap].tmusic); zcmusic_play(zcmusic, emusic_volume); int temptracks=0; temptracks=zcmusic_get_tracks(zcmusic); temptracks=(temptracks<2)?1:temptracks; ttrack = vbound(DMaps[currdmap].tmusictrack,0,temptracks-1); zcmusic_change_track(zcmusic,ttrack); } else { tfile[0] = 0; domidi=true; } } } else { domidi=true; } if(domidi) { int m=DMaps[currdmap].midi; switch(m) { case 1: jukebox(ZC_MIDI_OVERWORLD); break; case 2: jukebox(ZC_MIDI_DUNGEON); break; case 3: jukebox(ZC_MIDI_LEVEL9); break; default: if(m>=4 && m<4+MAXCUSTOMMIDIS) jukebox(m-4+ZC_MIDI_COUNT); else music_stop(); } } }
void destroy() { stop_midi(); destroy_midi(tune); tune = NULL; }
void main() { allegro_init(); install_keyboard(); set_color_depth(32); set_gfx_mode(GFX_AUTODETECT_WINDOWED, 1000, 600, 0, 0); install_int_ex(ContaMsec, MSEC_TO_TIMER(1)); install_int_ex(ContaSec, SECS_TO_TIMER(1)); install_sound(DIGI_AUTODETECT,MIDI_AUTODETECT,NULL); MIDI* bgSound = load_midi("sounds/BGM.mid"); SAMPLE* snakeHit = load_wav("sounds/cobraDamage.wav"); SAMPLE* snakeHitSelf = load_wav("sounds/cobraDamage2.wav"); SAMPLE* snakeDeath = load_wav("sounds/cobraDeath.wav"); SAMPLE* gameOver = load_wav("sounds/gameOver.wav"); InicializaPP(); int swt = 0; struct Cobra snake[500]; //Estrutura que representa a cobra e suas bmpPartes. int xst=0, yst=10, xst2=190, yst2 = 40; //Coordenadas de referência da área de Status do jogo int xL = 0, yL = 425, xL2 = 190, yL2 = 590; //Coordenadas de referência da Tabela de Comidas buffer = create_bitmap(800,600); //Bitmap principal de desenho status = create_bitmap(200,600); //Bitmap principal de desenho clear_to_color(status, makecol(0,0,0)); clear_to_color(buffer, makecol(0,0,0)); //INICIO: Inicializacao Sprites bmpSapo = load_bitmap("images/sapo_20x20.bmp",pallet); bmpAranha = load_bitmap("images/ARANHA_20X20.bmp",pallet); bmpMaca = load_bitmap("images/MACA_20x20.bmp",pallet); bmpMilho = load_bitmap("images/milho_20X20.bmp",pallet); bmpCobraHead = load_bitmap("images/cobraHeadVerde.bmp",pallet); bmpFundo = load_bitmap("images/fundoAreia.bmp",pallet); bmpCobrinha = load_bitmap("images/cobrinha.bmp",pallet); bmpParte = load_bitmap("images/cobraCorpo2.BMP",pallet); bmpBordaVert = load_bitmap("images/bordaVert.bmp",pallet); bmpBordaHoriz = load_bitmap("images/bordaHoriz.bmp",pallet); myfont = load_font("Terminal.pcx", pallet, NULL); //Fonte personalizada //FIM: Inicializacao Sprites //INICIO: Comidas Comida cmdSapo; cmdSapo.x = 300; cmdSapo.y = 400; cmdSapo.bmp = bmpSapo; cmdSapo.spStand = load_wav("sounds/sapoStand.wav"); cmdSapo.spDie = load_wav("sounds/sapoDie.wav"); cmdSapo.visible = true; cmdSapo.ponto = 50; cmdSapo.taman = 1; Comida cmdAranha; cmdAranha.x = 60; cmdAranha.y = 500; cmdAranha.bmp = bmpAranha; cmdAranha.spStand = load_wav("sounds/sapoStand.wav"); cmdAranha.spDie = load_wav("sounds/aranhaDie.wav"); cmdAranha.visible = true; cmdAranha.ponto = 30; cmdAranha.taman = 3; Comida cmdMaca; cmdMaca.x = 100; cmdMaca.y = 100; cmdMaca.bmp = bmpMaca; cmdMaca.spStand = load_wav("sounds/sapoStand.wav"); cmdMaca.spDie = snakeBit; cmdMaca.visible = true; cmdMaca.ponto = 20; cmdMaca.taman = 4; Comida cmdMilho; cmdMilho.x = 600; cmdMilho.y = 100; cmdMilho.bmp = bmpMilho; //cmdmilho.spStand = load_wav("sounds/sapoStand.wav"); cmdMilho.spDie = snakeBit; cmdMilho.visible = true; cmdMilho.ponto = 10; cmdMilho.taman = 5; Comida cmdCobrinha; cmdCobrinha.x = 600; cmdCobrinha.y = 480; cmdCobrinha.bmp = bmpCobrinha; cmdCobrinha.spStand = load_wav("sounds/cobrinhaStand.wav"); cmdCobrinha.spDie = load_wav("sounds/cobrinhaDie.wav"); cmdCobrinha.visible = true; cmdCobrinha.ponto = 40; cmdCobrinha.taman = 2; Comida comidas[20]; comidas[0] = cmdSapo; comidas[1] = cmdAranha; comidas[2] = cmdMaca; comidas[3] = cmdMilho; comidas[4] = cmdCobrinha; comidas[5] = cmdAranha; comidas[6] = cmdMilho; comidas[7] = cmdMilho; comidas[8] = cmdMilho; comidas[9] = cmdCobrinha; comidas[10] = cmdSapo; comidas[11] = cmdAranha; comidas[12] = cmdMaca; comidas[13] = cmdMilho; comidas[14] = cmdCobrinha; comidas[15] = cmdAranha; comidas[16] = cmdMilho; comidas[17] = cmdMilho; comidas[18] = cmdMilho; comidas[19] = cmdCobrinha; //FIM: Comidas Vida vidas[6]; for (int i = 0;i < 6; i++){ vidas[i].x = i*30; vidas[i].y = 0; vidas[i].bmp = bmpCobraHead; vidas[i].visible = true; } //INICIO: Desenho da área de status do jogo. Pontos, Fase, Tamanho, Tempo, Vidas for (int i = -1;i<2;i++){rect(status, xst+i, yst+i, xst2-i, 40-i, makecol(210,192,152));} textprintf_ex(status, myfont, xst+5,68, makecol(255,0,0), -1,"Fase: 1" ); for (int i = -1;i<2;i++){rect(status, xst+i, yst+50+i, xst2-i, yst2+50-i, makecol(210,192,152));} for (int i = -1;i<2;i++){rect(status, xst+i, yst+100+i, xst2-i, yst2+100-i, makecol(210,192,152));} for (int i = -1;i<2;i++){rect(status, xst+i, yst+150+i, xst2-i, yst2+150-i, makecol(210,192,152));} for (int i = 0;i < 6; i++){ if (vidas[i].visible){ draw_sprite(status, vidas[i].bmp, vidas[i].x, vidas[i].y+195); } } //FIM: Desenho da área status do jogo. Pontos, Fase, Tamanho, Tempo, Vidas //INICIO: Desenho da Tabela de Comida do jogo. textprintf_ex(status, myfont, xL,yL-20, makecol(255,0,0 ), -1,"Comidas" ); for (int i = -1;i<2;i++){rect(status, xL+i, yL+i, xL2-i, yL2-i, makecol(210,192,152));} draw_sprite(status, bmpMilho, xL+10, yL+10); textprintf_ex(status, font, xL+40,yL+20, makecol(255,255,0 ), -1,"10 pontos" ); draw_sprite(status, bmpMaca, xL+10, yL+40); textprintf_ex(status, font, xL+40,yL+50, makecol(255,0,0 ), -1,"20 pontos" ); draw_sprite(status, bmpAranha, xL+10, yL+70); textprintf_ex(status, font, xL+40,yL+80, makecol(153,0,255 ), -1,"30 pontos" ); draw_sprite(status, bmpCobrinha, xL+10, yL+100); textprintf_ex(status, font, xL+40,yL+110, makecol(255,255,153 ), -1,"40 pontos" ); draw_sprite(status, bmpSapo, xL+10, yL+130); textprintf_ex(status, font, xL+40,yL+140, makecol(110,220,0 ), -1,"50 pontos " ); //FIM: Desenho da Tabela de Comida do jogo. //INICIO: Desenho do campo de ação da cobra. draw_sprite(buffer, bmpFundo, xC,yC); draw_sprite(buffer, bmpBordaVert, xC,yC); draw_sprite(buffer, bmpBordaVert, xC2-20,yC); draw_sprite(buffer, bmpBordaHoriz, xC,xC); draw_sprite(buffer, bmpBordaHoriz, xC,yC2-20); //FIM: Desenho do campo de ação da cobra //INICIO: Desenho da cobra snake[0].bmp = bmpCobraHead; for (int i = 1;i<tamCobra;i++){ snake[i].bmp = bmpParte; } //FIM: Desenho da cobra char control; int veloc; control = menu_inicial(); if (control == 'j'){veloc = 120;}else{veloc = 50;} play_midi(bgSound,0); draw_sprite(screen,status,800,0); DesenhaCampoAcao(); int x=20, y=20 , xx, yy; int dirx = 20, diry = 0; int tipoCol = 0; int tamComida; //Tamanho que a comida capturada aumentará a cobra int ptsComida; //Quantidade de pontos que a comida vale int pontosAtual = 0; //Quantidade de pontos while (!key[KEY_ESC]) { DesenhaCampoAcao(); if(control == 't'){ if (key[KEY_UP]){ if (dirx != 0) { diry = -20; dirx = 0; } } if (key[KEY_DOWN]){ if (dirx != 0) { diry = 20; dirx = 0; } } if (key[KEY_LEFT]){ if (diry != 0) { dirx = -20; diry = 0; } } if (key[KEY_RIGHT]){ if (diry != 0) { dirx = 20; diry = 0; } } } else if(control = 'j') { swt = inp32(0x379); if (swt == 95){ if ((countMsecCmd / 100) > 1){ if (dirx == 20 && diry == 0) { diry = 20; dirx = 0; } else if (dirx == 0 && diry == 20) { dirx = -20; diry = 0; } else if (dirx == -20 && diry == 0) { diry = -20; dirx = 0; } else if (dirx == 0 && diry == -20) { dirx = 20; diry = 0; } countMsecCmd = 0; } } if (swt == 63){ if ((countMsecCmd / 100) > 1){ if (dirx == 0 && diry == 20) { diry = 0; dirx = 20; } else if (dirx == 20 && diry == 0) { dirx = 0; diry = -20; } else if (dirx == 0 && diry == -20) { diry = 0; dirx = -20; } else if (dirx == -20 && diry == 0) { dirx = 0; diry = 20; } countMsecCmd = 0; } } } if ((countMsec / veloc) > 1){ x += dirx; y += diry; if (VerifCollision(snake, comidas, x, y, &xx, &yy, tamCobra, &tipoCol, &ptsComida, &tamComida)){ switch (tipoCol){ case 0: break; case 1://colisao com corpo textprintf_ex(screen, font, 0,560, makecol(255,0,0 ), -1,"Colisao Em : x: %d y: %d TipoCol: %d", xx, yy, tipoCol); tipoCol = 0; ResetaPosicaoCobra(snake, tamCobra); play_sample(snakeHitSelf,255,90,1000,0); if (qtdVidas > 1){qtdVidas=0;} else {qtdVidas = -1;} MostraVidas(qtdVidas,vidas); x=20; y=20; dirx = 20; diry = 0; AcendeLuzes(); break; case 2://colisao obstaculos textprintf_ex(screen, font, 0,560, makecol(255,0,0 ), -1,"Colisao Em : x: %d y: %d TipoCol: %d", xx, yy, tipoCol); tipoCol = 0; ResetaPosicaoCobra(snake, tamCobra); play_sample(snakeHit,255,90,1000,0); qtdVidas--; MostraVidas(qtdVidas,vidas); x=20; y=20; dirx = 20; diry = 0; AcendeLuzes(); break; case 3: //colisao comida textprintf_ex(screen, font, 0,560, makecol(255,0,0 ), -1,"Colisao Em : x: %d y: %d TipoCol: %d", xx, yy, tipoCol); AumentaCobra(snake, &tamCobra, tamComida, bmpParte); pontosAtual += ptsComida; tipoCol = 0; CriaComida(comidas); break; } } MoveSnake(snake, x, y, tamCobra); MostraStatus(pontosAtual, tamCobra); draw_sprite(screen,status,800,0); countMsec = 0; for (int i = 0;i < tamCobra;i++){ draw_sprite(buffer, snake[i].bmp, snake[i].x,snake[i].y); } for (int i = 0;i < 10;i++){ if (comidas[i].visible){ draw_sprite(buffer, comidas[i].bmp, comidas[i].x,comidas[i].y); } } draw_sprite(screen,buffer,0,0); IntercalaLeds(); } else if(qtdVidas < 0) { play_sample(snakeDeath,255,90,1000,0); stop_midi(); play_sample(gameOver,255,90,1000,0); GravaRank(pontosAtual, countSec, tamCobra); clear_to_color(buffer, makecol(165,229,101)); clear_to_color(screen, makecol(165,229,101)); MostraRank(); textprintf_ex(buffer, myfont, 300,500, makecol(255,0,0), -1,"Aperte ESC para sair...." ); draw_sprite(screen,buffer,0,0); break; } } while (!key[KEY_ESC]) {} FinalizaPP(); }