私はこれを理解しようとして10時間起きていました。ogg または mp3 ファイルを allegro 4 で再生するために、さまざまなライブラリを試してみました。DUMB ライブラリをダウンロードし、インクルード ファイルと lib ファイルを mingw のそれぞれの場所にコピーしました (コードブロックを使用しています)。ライブラリをコンパイラにインストールする正しい方法は何ですか? ここに私のコードがあります..
#include <allegro.h>
#include <iostream>
#include <stdlib.h>
#include <aldumb.h>
#include "CUSTOM_FUNCTIONS_HEADER.h"
#include "status_screen_functions_header.h"
#define WHITE makecol(255,255,255)
//General Game Settings
int volume = 128;
int pan = 128;
int pitch = 1000;
#
int main(int argc, char *argv[]){
allegro_init();
atexit(&dumb_exit);//initialize dumb
dumb_register_stdfiles(); //tELL DUMB HOW TO OPEN FILES
install_keyboard();
if(install_sound(DIGI_AUTODETECT, MIDI_NONE, "") != 0){
allegro_message("error initializing the sound system");
}
set_color_depth(16);
set_gfx_mode(GFX_AUTODETECT_WINDOWED, 1100, 550, 0, 0);
write_status_screen("Status$>_Allegro Engine Initialization Successfull");
//******************************************************************************//
//*****************************************************************************//
//Write code below this line since allegro has been initialized//
BITMAP *dragon;
BITMAP *main_title, *main_menu;
BITMAP *buffer;
/*Menu music*/
// load_sample("OG_MUSIC\\straight_outta_compton_menu.ogg");
//Setup Audiostream for Main Menu Music//
write_status_screen("Status$> Loading OG Music Stream: \"Straight Outta Compton.OGG\"");
DUH *myduh;
myduh = dumb_load_it_quick("OG_MUSIC\\straight_outta_compton_menu.ogg");
AL_DUH_PLAYER *dp = al_start_duh(myduh, 2, 0,
volume, 4096, 48000);;
//logg_get_stream("straight_outta_compton_menu.ogg", volume, pan, true);
SAMPLE *menu_guntrigger = load_sample("OG_MUSIC\\gun_menu_choose.wav");
/*Menu count*/
int menct = 0;
buffer = create_bitmap(1100, 480);
textprintf_ex(screen, font, 0, 0, WHITE, 0, "Resolution = %ix%i ", SCREEN_W, SCREEN_H);
dragon = load_bitmap("BITMAPS\\COMPTON_START_MENU_FADED_TWO.bmp", NULL);
main_title = load_bitmap("BITMAPS\\OGM_TITLE.bmp", NULL);
main_menu = load_bitmap("BITMAPS\\MAIN_MENU.bmp", NULL);
write_status_screen("Status$>_Bitmaps loaded into memory!");
write_status_screen("Status$> Loading OG Sound Effects......:");
rest(650);
rest(700);
int frames_drawn = 0;
while(!key[KEY_ESC]){
/*Handle Controls First modulus 2 to make selection easier, every second frame, keypress is captured. DO NOT DO THIS FOR ACTUAL GAMEPLAY*/
if(key[KEY_UP] && frames_drawn % 2 == 0){
play_sample(menu_guntrigger, volume, pan, pitch, FALSE);
menct--;
} else if (key[KEY_DOWN] && frames_drawn % 3 == 0){
play_sample(menu_guntrigger, volume, pan, pitch, FALSE);
menct++;
}
if (menct > 3){
play_sample(menu_guntrigger, volume, pan, pitch, FALSE);
menct = 0;
}else if (menct <0){
play_sample(menu_guntrigger, volume, pan, pitch, FALSE);
menct = 3;
}
rest(10);
//Erase everything
clear(buffer);
//status box
rectfill(screen, 0, 480, 1100, 483, WHITE);
/*Draw the frame based on user input*/
draw_sprite(buffer, dragon, 0, 0);
draw_sprite(buffer, main_title, 315, 10);
drawframe(buffer, main_menu, 485, 145, 332, 305, 0, 0, 4, menct);
//blit(main_title, screen, 0, 0, 50, 50, 540, 96);
//masked_blit(main_title, screen, 0, 0, 50, 50, 540, 96);
//masked_blit(source, dest, framex, framey, x, y, width, height);
textprintf_ex(buffer, font, 900, 470, WHITE, 0, "Written By: Kelvin Silva", bitmap_color_depth(screen));
textprintf_ex(buffer, font, 0, 470, WHITE, 0, "Frames Drawn: %i", frames_drawn);
blit(buffer, screen, 0, 0, 0, 0, 1100, 480);
/*pollduh*/
al_poll_duh(dp);
/*Wait for vsync, rest a little, update framecount and prompt for more input*/
vsync();
frames_drawn++;
rest(50);
}
write_status_screen("Status$>_Game Loop Ended...");
clear_status_screen();
//NOTE NEED TO SETUP MEMORY DESTRUCTION
destroy_bitmap(dragon);
destroy_bitmap(main_title);
destroy_bitmap(buffer);
allegro_exit();
return 0;
}
END_OF_MAIN()
d:\programs\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.7.1\..\..\..\libaldmd.a(alplay.o)||In function `al_start_duh':|
D:\Users\Kelvin_Silva\Downloads\dumb-0.9.3\dumb-0.9.3\src\allegro\alplay.c|48|undefined reference to `al_assert'|
D:\Users\Kelvin_Silva\Downloads\dumb-0.9.3\dumb-0.9.3\src\allegro\alplay.c|49|undefined reference to `al_assert'|
D:\Users\Kelvin_Silva\Downloads\dumb-0.9.3\dumb-0.9.3\src\allegro\alplay.c|62|undefined reference to `play_audio_stream'|
D:\Users\Kelvin_Silva\Downloads\dumb-0.9.3\dumb-0.9.3\src\allegro\alplay.c|69|undefined reference to `voice_set_priority'|
D:\Users\Kelvin_Silva\Downloads\dumb-0.9.3\dumb-0.9.3\src\allegro\alplay.c|74|undefined reference to `stop_audio_stream'|
d:\programs\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.7.1\..\..\..\libaldmd.a(alplay.o)||In function `al_stop_duh':|
D:\Users\Kelvin_Silva\Downloads\dumb-0.9.3\dumb-0.9.3\src\allegro\alplay.c|92|undefined reference to `stop_audio_stream'|
d:\programs\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.7.1\..\..\..\libaldmd.a(alplay.o)||In function `al_pause_duh':|
D:\Users\Kelvin_Silva\Downloads\dumb-0.9.3\dumb-0.9.3\src\allegro\alplay.c|103|undefined reference to `voice_stop'|
d:\programs\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.7.1\..\..\..\libaldmd.a(alplay.o)||In function `al_resume_duh':|
D:\Users\Kelvin_Silva\Downloads\dumb-0.9.3\dumb-0.9.3\src\allegro\alplay.c|113|undefined reference to `voice_start'|
d:\programs\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.7.1\..\..\..\libaldmd.a(alplay.o)||In function `al_duh_set_priority':|
D:\Users\Kelvin_Silva\Downloads\dumb-0.9.3\dumb-0.9.3\src\allegro\alplay.c|123|undefined reference to `voice_set_priority'|
d:\programs\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.7.1\..\..\..\libaldmd.a(alplay.o)||In function `al_poll_duh':|
D:\Users\Kelvin_Silva\Downloads\dumb-0.9.3\dumb-0.9.3\src\allegro\alplay.c|156|undefined reference to `get_audio_stream_buffer'|
D:\Users\Kelvin_Silva\Downloads\dumb-0.9.3\dumb-0.9.3\src\allegro\alplay.c|166|undefined reference to `free_audio_stream_buffer'|
D:\Users\Kelvin_Silva\Downloads\dumb-0.9.3\dumb-0.9.3\src\allegro\alplay.c|167|undefined reference to `stop_audio_stream'|
D:\Users\Kelvin_Silva\Downloads\dumb-0.9.3\dumb-0.9.3\src\allegro\alplay.c|179|undefined reference to `free_audio_stream_buffer'|
d:\programs\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.7.1\..\..\..\libaldmd.a(alplay.o)||In function `al_duh_encapsulate_sigrenderer':|
D:\Users\Kelvin_Silva\Downloads\dumb-0.9.3\dumb-0.9.3\src\allegro\alplay.c|208|undefined reference to `al_assert'|
D:\Users\Kelvin_Silva\Downloads\dumb-0.9.3\dumb-0.9.3\src\allegro\alplay.c|209|undefined reference to `al_assert'|
D:\Users\Kelvin_Silva\Downloads\dumb-0.9.3\dumb-0.9.3\src\allegro\alplay.c|215|undefined reference to `play_audio_stream'|
D:\Users\Kelvin_Silva\Downloads\dumb-0.9.3\dumb-0.9.3\src\allegro\alplay.c|222|undefined reference to `voice_set_priority'|
d:\programs\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.7.1\..\..\..\libaldmd.a(alplay.o)||In function `al_duh_decompose_to_sigrenderer':|
D:\Users\Kelvin_Silva\Downloads\dumb-0.9.3\dumb-0.9.3\src\allegro\alplay.c|248|undefined reference to `stop_audio_stream'|
||=== Build finished: 18 errors, 0 warnings (0 minutes, 0 seconds) ===|