资源简介
开源的超级玛丽源代码
界面极其华丽
编译即可运行(在Linux下可以使用)
代码片段和文件信息
/***************************************************************************
* audio.cpp - Audio Engine
*
* Copyright (C) 2003 - 2008 Florian Richter
***************************************************************************/
/*
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License or
(at your option) any later version.
You should have received a copy of the GNU General Public License
along with this program. If not see .
*/
#include “../audio/audio.h“
#include “../audio/sound_manager.h“
#include “../core/game_core.h“
#include “../level/level.h“
#include “../overworld/overworld.h“
#include “../user/preferences.h“
#include “../core/i18n.h“
/* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
void Finished_Sound( int channel )
{
// find the finished sound and free the data
for( AudioSoundList::iterator itr = pAudio->sounds.begin() itr_end = pAudio->sounds.end(); itr != itr_end; ++itr )
{
cAudio_Sound *obj = (*itr);
if( obj->m_channel == channel )
{
obj->Finished();
}
}
}
/* *** *** *** *** *** *** *** *** Audio Sound *** *** *** *** *** *** *** *** *** */
cAudio_Sound :: cAudio_Sound( void )
{
m_data = NULL;
m_channel = -1;
m_resource_id = -1;
}
cAudio_Sound :: ~cAudio_Sound( void )
{
Free();
}
void cAudio_Sound :: Load( cSound *data )
{
Free();
m_data = data;
}
void cAudio_Sound :: Free( void )
{
Stop();
if( m_data )
{
m_data = NULL;
}
m_channel = -1;
m_resource_id = -1;
}
void cAudio_Sound :: Finished( void )
{
m_channel = -1;
}
int cAudio_Sound :: Play( int use_res_id /* = -1 */ int loops /* = 0 */ )
{
if( !m_data || !m_data->m_chunk )
{
return 0;
}
if( use_res_id >= 0 )
{
for( AudioSoundList::iterator itr = pAudio->sounds.begin() itr_end = pAudio->sounds.end(); itr != itr_end; ++itr )
{
// get object pointer
cAudio_Sound *obj = (*itr);
// skip self
if( !obj || obj->m_channel == m_channel )
{
continue;
}
// stop Sounds using the given resource id
if( obj->m_resource_id == use_res_id )
{
obj->Stop();
}
}
}
m_resource_id = use_res_id;
// play sound
m_channel = Mix_PlayChannel( -1 m_data->m_chunk loops );
// add callback if sound finished playing
Mix_ChannelFinished( &Finished_Sound );
return m_channel;
}
void cAudio_Sound :: Stop( void )
{
// if not loaded or not playing
if( !m_data || m_channel < 0 )
{
return;
}
Mix_HaltChannel( m_channel );
m_channel = -1;
}
/* *** *** *** *** *** *** *** *** Audio *** *** *** *** *** *** *** *** *** */
cAudio :: cAudio( void )
{
initialised = 0;
sound_enabled = 0;
music_enabled = 0;
debug = 0;
sound_volume = 100;
music
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 17845 2008-08-25 13:44 src\audio\audio.cpp
文件 6302 2008-08-25 13:44 src\audio\audio.h
文件 18245 2008-12-14 16:03 src\audio\random_sound.cpp
文件 4581 2008-12-14 12:52 src\audio\random_sound.h
文件 2238 2008-08-25 13:05 src\audio\sound_manager.cpp
文件 2388 2008-08-25 12:59 src\audio\sound_manager.h
文件 8965 2008-12-18 20:02 src\core\camera.cpp
文件 2424 2008-07-02 03:56 src\core\camera.h
文件 11489 2008-12-03 14:17 src\core\collision.cpp
文件 5230 2008-12-03 14:17 src\core\collision.h
文件 45890 2008-12-22 21:13 src\core\editor.cpp
文件 7271 2008-12-22 21:13 src\core\editor.h
文件 2779 2008-05-23 06:43 src\core\file_parser.cpp
文件 1456 2008-07-02 03:56 src\core\file_parser.h
文件 4334 2008-04-22 10:41 src\core\fr
文件 3070 2008-07-02 03:56 src\core\fr
文件 52495 2008-12-21 20:26 src\core\game_core.cpp
文件 9158 2008-12-10 05:22 src\core\game_core.h
文件 984 2008-07-02 03:56 src\core\globals.h
文件 2018 2008-09-07 05:09 src\core\global_basic.h
文件 8559 2008-12-03 14:17 src\core\global_game.h
文件 1144 2008-07-02 03:56 src\core\global_gui.h
文件 986 2008-07-02 03:56 src\core\global_sdl.h
文件 3325 2008-12-16 17:38 src\core\i18n.cpp
文件 1176 2008-09-26 23:45 src\core\i18n.h
文件 29567 2008-12-12 05:27 src\core\main.cpp
文件 1484 2008-07-02 03:56 src\core\main.h
文件 3299 2008-07-02 03:56 src\core\math\point.h
文件 2090 2008-07-02 03:56 src\core\math\rect.h
文件 1629 2008-09-25 14:52 src\core\math\size.h
............此处省略137个文件信息
- 上一篇:数据结构课程设计学生信息管理系统
- 下一篇:89c51单片机电子琴设计
评论
共有 条评论