• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            隨筆 - 96  文章 - 255  trackbacks - 0
            <2008年2月>
            272829303112
            3456789
            10111213141516
            17181920212223
            2425262728291
            2345678

            E-mail:zbln426@163.com QQ:85132383 長期尋找對戰略游戲感興趣的合作伙伴。

            常用鏈接

            留言簿(21)

            隨筆分類

            隨筆檔案

            SDL相關網站

            我的個人網頁

            我的小游戲

            資源下載

            搜索

            •  

            積分與排名

            • 積分 - 493120
            • 排名 - 39

            最新評論

            閱讀排行榜

            評論排行榜


            //UVi Soft ( 2008 )
            //Long Fei ( lf426 ), E-mail: zbln426@163.com
            //Laboratory of ZaiBieLiunNian
            //http://www.shnenglu.com/lf426/

            //FileName: MixSoundClass.hpp

            #ifndef MIX_SOUND_CLASS_HPP
            #define MIX_SOUND_CLASS_HPP

            #include 
            <iostream>
            #include 
            <string>
            #include 
            "SDL/SDL.h"
            #include 
            "SDL/SDL_mixer.h"

            class BaseMixSound
            {
            private:
                
            static int MixNUM;
            protected:
                BaseMixSound();
            public:
                
            virtual ~BaseMixSound();
            };

            class EffectSound: public BaseMixSound
            {
            private:
                Mix_Chunk
            * sound;
            public:
                EffectSound(
            const std::string& sound_fileName);
                
            ~EffectSound();
                
            void play() const;
            };

            class MusicSound: public BaseMixSound
            {
            private:
                Mix_Music
            * music;
            public:
                MusicSound(
            const std::string& music_fileName);
                
            ~MusicSound();
                
            void play() const;
                
            void stop() const;
            };

            #endif

            //UVi Soft ( 2008 )
            //Long Fei ( lf426 ), E-mail: zbln426@163.com
            //Laboratory of ZaiBieLiunNian
            //http://www.shnenglu.com/lf426/

            #include 
            "MixSoundClass.hpp"

            //*******************************
            //class BaseMixSound

            int BaseMixSound::MixNUM = 0;

            BaseMixSound::BaseMixSound()
            {
                
            if ( MixNUM == 0 ){
                    
            if( Mix_OpenAudio( 22050, MIX_DEFAULT_FORMAT, 24096 ) == -1 ){
                        std::cerr 
            << "Mix_Open ERROR" << std::endl;
                        exit(
            -1);
                    }
                }
                MixNUM
            ++;
            }

            BaseMixSound::
            ~BaseMixSound()
            {
                MixNUM
            --;
                
            if ( MixNUM == 0 ){
                    Mix_CloseAudio();
                }
            }

            //*******************************



            //*******************************
            //class EffectSound

            EffectSound::EffectSound(
            const std::string& sound_fileName)
            {
                sound 
            = Mix_LoadWAV(sound_fileName.c_str());
                
            if ( sound == 0 ){
                    std::cerr 
            << sound_fileName << " : load failed!" << std::endl;
                }
            }

            EffectSound::
            ~EffectSound()
            {
                Mix_FreeChunk(sound);
            }

            void EffectSound::play() const
            {
                 
            if( Mix_PlayChannel(-1, sound, 0== -1 ){
                     std::cerr 
            << "Mix_PlayChannel() ERROR" << std::endl;
                 }
            }

            //*******************************



            //*******************************
            //class MusicSound

            MusicSound::MusicSound(
            const std::string& music_fileName)
            {
                music 
            = Mix_LoadMUS(music_fileName.c_str());
                
            if (  music == 0 ){
                    std::cerr 
            << music_fileName << " : load failed!" << std::endl;
                }
            }

            MusicSound::
            ~MusicSound()
            {
                Mix_FreeMusic(music);
            }

            void MusicSound::play() const
            {
                
            if( Mix_PlayingMusic() == false ){
                    
            if( Mix_PlayMusic( music, -1 ) == -1 ){
                        std::cerr 
            << "Mix_PlayMusic() ERROR" << std::endl;
                    }
                } 
            else {
                    
            if( Mix_PausedMusic() == 1) {
                        Mix_ResumeMusic();
                    }
                    
            else {
                        Mix_PauseMusic();
                    }
                }
            }

            void MusicSound::stop() const
            {
                Mix_HaltMusic();
            }

            //***************************************

            lib: SDL.lib, SDLmain.lib
                 SDL_mixer.lib

            dll: SDL.dll
                 libogg-0.dll, libvorbis-0.dll, libvorbisfile-3.dll, SDL_mixer.dll, smpeg.dll

            last update: 2008-04-20
            posted on 2008-04-20 01:49 lf426 閱讀(3369) 評論(0)  編輯 收藏 引用 所屬分類: mySDL_GameEngine
            国产精品久久久久9999| 狠狠综合久久综合88亚洲| 久久WWW免费人成一看片| 久久精品人人槡人妻人人玩AV | 久久成人精品| 日产精品久久久久久久| 久久精品国产亚洲精品| 狠狠久久亚洲欧美专区| 香蕉久久av一区二区三区| 99久久亚洲综合精品网站| 久久久久久噜噜精品免费直播| 亚洲国产精品成人久久蜜臀 | 日韩欧美亚洲国产精品字幕久久久| 人妻精品久久无码区| 91精品国产综合久久四虎久久无码一级| 久久久久这里只有精品| 国产亚州精品女人久久久久久 | 少妇人妻88久久中文字幕| 久久综合九色综合久99| 精品久久久久久中文字幕大豆网| 欧美久久综合性欧美| A狠狠久久蜜臀婷色中文网| 亚洲va久久久噜噜噜久久狠狠| 国产精品亚洲美女久久久| 久久精品国产99国产电影网| 国产毛片欧美毛片久久久| 久久久国产亚洲精品| 久久久久高潮毛片免费全部播放 | 免费观看久久精彩视频| 日本久久久久亚洲中字幕| 久久精品国产AV一区二区三区| 日本精品一区二区久久久| 国产高清国内精品福利99久久| 99久久久久| 国产亚洲精午夜久久久久久| 久久国产精品-久久精品| 久久中文字幕一区二区| 国产高清美女一级a毛片久久w | 国产精品99久久久久久人| 久久精品国产网红主播| 国产精品久久成人影院|