‘壹’ c语言制作小游戏时怎么添加图片音乐,代码怎么打
添加音乐还是比较麻烦的
一个简单的思路是
先找一个开源的播放器代码
或者直接搞一个播放器接口的库
然后
把背景音乐存成文件,
在打开游戏的时候
创建线程进行播放。
代码编写:
PlaySound
The
PlaySound
function
plays
a
sound
specified
by
the
given
filename,
resource,
or
system
event.
(A
system
event
may
be
associated
with
a
sound
in
the
registry
or
in
the
WIN.INI
file.)
BOOL
PlaySound(
LPCSTR
pszSound,
HMODULE
hmod,
DWORD
fdwSound
);
Parameters
pszSound
A
string
that
specifies
the
sound
to
play.
If
this
parameter
is
NULL,
any
currently
playing
waveform
sound
is
stopped.
To
stop
a
non-waveform
sound,
specify
SND_PURGE
in
the
fdwSound
parameter.
Three
flags
in
fdwSound
(SND_ALIAS,
SND_FILENAME,
and
SND_RESOURCE)
determine
whether
the
name
is
interpreted
as
an
alias
for
a
system
event,
a
filename,
or
a
resource
identifier.
If
none
of
these
flags
are
specified,
PlaySound
searches
the
registry
or
the
WIN.INI
file
for
an
association
with
the
specified
sound
name.
If
an
association
is
found,
the
sound
event
is
played.
If
no
association
is
found
in
the
registry,
the
name
is
interpreted
as
a
filename.
hmod
Handle
of
the
executable
file
that
contains
the
resource
to
be
loaded.
This
parameter
must
be
NULL
unless
SND_RESOURCE
is
specified
in
fdwSound.
fdwSound
Flags
for
playing
the
sound.
The
following
values
are
defined:
SND_APPLICATION
The
sound
is
played
using
an
application-specific
association.
SND_ALIAS
The
pszSound
parameter
is
a
system-event
alias
in
the
registry
or
the
WIN.INI
file.
Do
not
use
with
either
SND_FILENAME
or
SND_RESOURCE.
SND_ALIAS_ID
The
pszSound
parameter
is
a
predefined
sound
identifier.
SND_ASYNC
The
sound
is
played
asynchronously
and
PlaySound
returns
immediately
after
beginning
the
sound.
To
terminate
an
asynchronously
played
waveform
sound,
call
PlaySound
with
pszSound
set
to
NULL.
SND_FILENAME
The
pszSound
parameter
is
a
filename.
SND_LOOP
The
sound
plays
repeatedly
until
PlaySound
is
called
again
with
the
pszSound
parameter
set
to
NULL.
You
must
also
specify
the
SND_ASYNC
flag
to
indicate
an
asynchronous
sound
event.
SND_MEMORY
A
sound
event's
file
is
loaded
in
RAM.
The
parameter
specified
by
pszSound
must
point
to
an
image
of
a
sound
in
memory.
SND_NODEFAULT
No
default
sound
event
is
used.
If
the
sound
cannot
be
found,
PlaySound
returns
silently
without
playing
the
default
sound.
SND_NOSTOP
The
specified
sound
event
will
yield
to
another
sound
event
that
is
already
playing.
If
a
sound
cannot
be
played
because
the
resource
needed
to
generate
that
sound
is
busy
playing
another
sound,
the
function
immediately
returns
FALSE
without
playing
the
requested
sound.
If
this
flag
is
not
specified,
PlaySound
attempts
to
stop
the
currently
playing
sound
so
that
the
device
can
be
used
to
play
the
new
sound.
SND_NOWAIT
If
the
driver
is
busy,
return
immediately
without
playing
the
sound.
SND_PURGE
Sounds
are
to
be
stopped
for
the
calling
task.
If
pszSound
is
not
NULL,
all
instances
of
the
specified
sound
are
stopped.
If
pszSound
is
NULL,
all
sounds
that
are
playing
on
behalf
of
the
calling
task
are
stopped.
You
must
also
specify
the
instance
handle
to
stop
SND_RESOURCE
events.
SND_RESOURCE
The
pszSound
parameter
is
a
resource
identifier;
hmod
must
identify
the
instance
that
contains
the
resource.
SND_SYNC
Synchronous
playback
of
a
sound
event.
PlaySound
returns
after
the
sound
event
completes.
Return
Values
Returns
TRUE
if
successful
or
FALSE
otherwise.
Remarks
The
sound
specified
by
pszSound
must
fit
into
available
physical
memory
and
be
playable
by
an
installed
waveform-audio
device
driver.
PlaySound
searches
the
following
directories
for
sound
files:
the
current
directory;
the
Windows
directory;
the
Windows
system
directory;
directories
listed
in
the
PATH
environment
variable;
and
the
list
of
directories
mapped
in
a
network.
For
more
information
about
the
directory
search
order,
see
the
documentation
for
the
OpenFile
function.
If
it
cannot
find
the
specified
sound,
PlaySound
uses
the
default
system
event
sound
entry
instead.
If
the
function
can
find
neither
the
system
default
entry
nor
the
default
sound,
it
makes
no
sound
and
returns
FALSE.
QuickInfo
Windows
NT:
Requires
version
3.1
or
later.
Windows:
Requires
Windows
95
or
later.
Windows
CE:
Unsupported.
Header:
Declared
in
mmsystem.h.
Import
Library:
Use
winmm.lib.
Unicode:
Implemented
as
Unicode
and
ANSI
versions
on
Windows
NT.
See
Also
Waveform
Audio
Overview,
Waveform
Functions
‘贰’ c语言能干什么 C语言的这些用处你知道吗
1、C语言可以做嵌入式开发。如51单片机、ARM等。
2、C语言可以写漂亮的界面。以windows开发为例,你可以学习《windows程序设计(第五版)》,学完就可以写出界面来。还有一些开源库界面库,例如soui也是用C写出来的。
3、C语言可以做服务器开发,现在的游戏服务器端大多都是C/C++开发的。《windows核心编程》里面的例子就是用C写的。
4、C语言可以写游戏。cocos2d—x就是C/C++写的。DirectX也是。
5、C语言可以写驱动程序。windows下各种硬件驱动都是C/C++写的。腾讯游戏保护软件(TP)也是驱动程序。
6、C语言可以写外挂。想学写外挂的童鞋们可以看看郁金香的外挂编程视频教程。
7、C语言可以做视频图片流媒体处理。有兴趣的朋友可以学习一下ffmpeg、live555、sdl等开源库。
8、C语言可以做网页和爬虫相关的编程。想了解的同学可以去看gsoap、libcur等相关开源库。
9、C语言可以进行黑客编程。配合汇编获取随机地址、调shellcode等。
‘叁’ 做大型网络游戏或者是手机游戏,是用C语言做的吗
C语言就像当年爱迪生发明的白炽灯一样,现在装修房子我们只单单用白炽灯吗?当然不是,还有其他选择(很多漂亮的灯管)。。。我是外行,简单喜欢编程,以我的知识,记得画面渲染有OpenGL,DirectX3D,3DMax。当然程序还有各种各样游戏引擎,都是很好的工具可以加快开发速度。。记得之前看过一个大神的帖子说,当年(90年代)他们写游戏还在操控底层显卡(真是牛人),现在我们只简单用成熟的引擎来直接开发就好,不用太关心底层
‘肆’ 如何用c语言制作简单的游戏类似扫雷贪吃蛇
‘伍’ 学完c语言我想做游戏开发有人教吗
1.继续学C++,然后就可以进入开源游戏引擎cocos2d-x的世界了,
2.很多非常火的游戏都是用这个引擎开发出来的,
3.如果你学好之后,进公司做个一两年,踏实干,月薪过万问题不大的。
4.解决你的问题了吗?开源的东西主要靠自己学,你把cocos2d-x引擎的代码下载下来,自己研究,不懂的找资料,相信你可以的!
‘陆’ c语言有哪些开源图形库
最着名的就是GTK了。。。和QT对着干的那个。。GNOME就是它开发的
还有比如用于游戏的SDL、或者使用脚本的TCL/TK的库,用于嵌入式的minigui的
最有名的就是GTK了。。。模拟OO封装,就是学习难度太大了,不亚于winapi。。。
‘柒’ C语言能开发什么
1.多平台通用软件
所谓多平台通用软件,就是指这个软件可以在很多系统上使用。例如,如果想让你写的同一个程序很好地运行在DOS、Windows 98、Windows XP、Windows CE、Linux、UNIX等多个操作系统上,C语言确实是个不错的选择。知道Apache吗?它是一个开源Web服务器工程,其中的HTTP服务器可以运行于很多平台,Windows、Linux和UNIX都是可以的,这个服务器就是用C语言开发的。
2.操作系统
由于C语言可以很自然地与汇编语言结合,又比汇编语言好用,能够很灵活地控制计算机硬件,因此很适合开发操作系统。Windows很老的版本都是用C语言写的,之后改用C++了,不过C++是兼容C语言的。Linux和UNIX系列的操作系统内核几乎都是用C语言写的,而且很多运行在板子上的嵌入式操作系统基本都是用C语言结合汇编写的。如果你真想做个操作系统,C语言绝对可以胜任。
3.复杂运算软件
之所以说C语言适合进行复杂计算软件的开发,是因为:(1)复杂计算软件本身很单纯,只需要计算机进行计算就可以了;(2)C语言本身有丰富的运算功能,完全可以实现复杂计算功能;(3)因为C语言是一种接近底层语言的高级语言,所以它写出来的程序在计算机上的运行效率很高。所以,要想做一个需要复杂而高效计算功能的软件,选择C语言绝对不会令你失望的。如果你经常做科学计算,用过MATLAB软件,它其中一部分也是用C语言写的。
‘捌’ 用于c语言编程的一个软件,我同学都叫它cf,和那个游戏的名字类似,不是vs2008,谁知道叫什么名字呀⊙o⊙
难道是Cloud Foundry是一个开源的PaaS云计算平台,它提供给开发者自由度去选择云平台,开发框架和应
用服务。
‘玖’ 用C语言编写出围棋游戏,要求如下。希望有位大神前来帮忙
看上去只有寥寥数语,但实际上包括很多功能,可以看看是否有相应的开源代码,自己写那没有十天半个月是搞不定的。
‘拾’ 跪求 c语言 sdl 编写的超级玛丽 第一次编写 主要是想看看思路 因为从来没用过sdl
偶然路过一下。。。
这个游戏是用SDL写的,不过貌似是C++。。。名叫secret maryo chronicles
去sourceforge.net一搜就找到了。。。开源的。。。
官网是:http://www.secretmaryo.org/