『壹』 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/