| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 3572 人关注过本帖
标题:求解答:贪吃蛇小游戏如何插入背景音乐?
只看楼主 加入收藏
永远没有永远
Rank: 2
等 级:论坛游民
帖 子:12
专家分:20
注 册:2019-10-5
结帖率:0
收藏
 问题点数:0 回复次数:4 
求解答:贪吃蛇小游戏如何插入背景音乐?
求解答:贪吃蛇游戏如何插入背景音乐?
我做了一个贪吃蛇小游戏,求问如何插入音乐。
 用的编译器是C-free5。
 试过的代码如下:
#include <stdio.h>
 #include <Windows.h>
 #include <mmsystem.h>
 #pragma comment(lib, "WINMM.LIB")

 int main(  )
 {
     PlaySoundA( "E:\\作业\\计算机程序设计作业\\大作业\\u06wt232.wav", NULL, SND_FILENAME|SND_ASYNC );
     puts( " -------- " );
     system( "pause" );
     PlaySoundA( NULL, NULL, SND_FILENAME|SND_ASYNC );
     return 0;

 }


  #include <stdio.h>
  #include <windows.h>
  #include <mmsystem.h>
  #pragma comment(lib, "winmm.lib")
 int  main(){
  PlaySound (TEXT("E:\\作业\\计算机程序设计作业\\大作业\\u06wt232.wav"), NULL, SND_ASYNC | SND_NODEFAULT);
   
  while (1)
  {
    printf("program is running... here\n");   //这里跑你的程序,按 Ctrl-C  组合键,结束程序。
  Sleep(1000);  //休息1秒
}
exit(0);
  }


 #include<stdio.h>
 #include<stdlib.h>
 #include<windows.h>
 #include <mmsystem.h>//导入声音头文件
#pragma comment(lib,"Winmm.lib")
 int main()
 {
     sndPlaySound("E:\\作业\\计算机程序设计作业\\大作业\\u06wt232.wav",SND_ASYNC);
      while (1)
     {
        printf("program is running... here\n");
     }
 }


  

都会报错[Error] C:\Users\desty\Documents\C-Free\Temp\未命名3.cpp:8: undefined reference to `PlaySoundA@12'
 [Error] collect2: ld returned 1 exit status
求教感谢!
搜索更多相关主题的帖子: 插入 贪吃蛇 作业 include lib 
2019-12-24 15:39
rjsp
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
等 级:版主
威 望:528
帖 子:9007
专家分:53942
注 册:2011-1-18
收藏
得分:0 
mingw 认识 #pragma comment(lib, "WINMM.LIB") 吗?
自己加
2019-12-24 16:46
永远没有永远
Rank: 2
等 级:论坛游民
帖 子:12
专家分:20
注 册:2019-10-5
收藏
得分:0 
试过了
是这样的
[Warning] D:\C-FREE~1\mingw\bin\..\lib\gcc\mingw32\3.4.5\..\..\..\..\include\c++\3.4.5\backward\backward_warning.h:32:2: warning: #warning This file includes at least one deprecated or antiquated header. Please consider using one of the 32 headers found in section 17.4.1.2 of the C++ standard. Examples include substituting the <X> header for the <X.h> header for C++ includes, or <iostream> instead of the deprecated header <iostream.h>. To disable this warning use -Wno-deprecated.

[Error] D:\C-FREE~1\mingw\bin\ld.exe: cannot find -lWINMM.LIB

[Error] collect2: ld returned 1 exit status
2019-12-24 17:10
rjsp
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
等 级:版主
威 望:528
帖 子:9007
专家分:53942
注 册:2011-1-18
收藏
得分:0 
[Error] D:\C-FREE~1\mingw\bin\ld.exe: cannot find -lWINMM.LIB

link参数加  -lWINMM 试试,注意大小写,你自己查一查文件名是什么
2019-12-24 18:18
永远没有永远
Rank: 2
等 级:论坛游民
帖 子:12
专家分:20
注 册:2019-10-5
收藏
得分:0 
非常感谢!
现在不报错了……
但是没声音
2019-12-24 19:34
快速回复:求解答:贪吃蛇小游戏如何插入背景音乐?
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.015176 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved