【发布时间】:2021-02-08 17:19:51
【问题描述】:
我正在制作游戏,我必须添加一些音效和音乐。
我用谷歌搜索了一下,发现了流动的代码:
#include <conio.h>
#include "inc/fmod.h"
FSOUND_SAMPLE* handle;
int main ()
{
// init FMOD sound system
FSOUND_Init (44100, 32, 0);
// load and play mp3
handle=FSOUND_Sample_Load (0,"my.mp3",0, 0, 0);
FSOUND_PlaySound (0,handle);
// wait until the users hits a key to end the app
while (!_kbhit())
{
}
// clean up
FSOUND_Sample_Free (handle);
FSOUND_Close();
}
但是当我编译它时,我得到了流动的错误:
➜ Desktop gcc main.c
main.c:1:10: fatal error: 'conio.h' file not found
#include <conio.h>
^~~~~~~~~
1 error generated.
【问题讨论】:
-
conio.h 不适用于 gcc,请使用
curses.h代替 stackoverflow.com/questions/8792317/… -
_kbhit()也是一个 MS 函数。可能重复; How do I port this program from conio to curses? -
不幸的是,它是特定于操作系统的。
-
我能想到的最基本的方式:
putchar('\a'); /* and maybe */fflush(stdout); -
显然这段代码已经很多很多年了。根据您的目标系统(顺便说一句,那是哪一个?)您需要研究其他方式,例如播放 WAV 或 MP3。
标签: c soundeffect