• <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://m.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://m.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
            国产欧美久久久精品| 久久免费高清视频| 久久久久久久综合狠狠综合| 欧美精品一区二区久久| 青青草原综合久久大伊人| 蜜臀av性久久久久蜜臀aⅴ麻豆 | 日本人妻丰满熟妇久久久久久| 奇米综合四色77777久久| 天天综合久久久网| 久久久久亚洲AV综合波多野结衣| 最新久久免费视频| 久久综合欧美成人| 久久久久久精品久久久久| 久久国产亚洲精品麻豆| 欧美精品国产综合久久| 亚洲午夜精品久久久久久人妖| 综合久久给合久久狠狠狠97色| 狠狠色丁香久久婷婷综| 久久精品免费全国观看国产| 91久久香蕉国产熟女线看| 午夜天堂精品久久久久| 亚洲人成网站999久久久综合| 国产精品女同久久久久电影院| 久久久久久噜噜精品免费直播| 精品国产VA久久久久久久冰| 色狠狠久久综合网| 久久久久亚洲AV成人网人人网站| 97超级碰碰碰久久久久| 久久久久亚洲av无码专区导航| 亚洲精品无码久久毛片| 国产无套内射久久久国产| 久久亚洲高清观看| www.久久热| 国产精品久久久久久搜索| 国产午夜福利精品久久2021| 久久91精品国产91久| 怡红院日本一道日本久久 | 国产欧美一区二区久久| 色婷婷综合久久久久中文 | 亚洲国产成人精品久久久国产成人一区二区三区综 | 国产一区二区精品久久|