• <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年6月>
            25262728293031
            1234567
            891011121314
            15161718192021
            22232425262728
            293012345

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

            常用鏈接

            留言簿(21)

            隨筆分類

            隨筆檔案

            SDL相關網站

            我的個人網頁

            我的小游戲

            資源下載

            搜索

            •  

            積分與排名

            • 積分 - 492145
            • 排名 - 38

            最新評論

            閱讀排行榜

            評論排行榜


            //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 閱讀(3358) 評論(0)  編輯 收藏 引用 所屬分類: mySDL_GameEngine
            人人狠狠综合久久亚洲高清| 亚洲另类欧美综合久久图片区| 久久精品国产亚洲精品| 午夜精品久久久久久久久| 亚洲国产精品一区二区三区久久| 91精品国产91久久| 99久久99久久精品免费看蜜桃| 久久免费看黄a级毛片| 思思久久99热只有频精品66| 色99久久久久高潮综合影院| 欧美激情精品久久久久久久九九九 | 久久亚洲AV无码精品色午夜麻豆| 久久久久亚洲?V成人无码| 国内精品久久久久久久coent | 无码人妻久久一区二区三区蜜桃| 噜噜噜色噜噜噜久久| 久久精品国产亚洲av麻豆蜜芽| 天堂久久天堂AV色综合| 久久99久久99精品免视看动漫| 久久99国产精品久久99果冻传媒| 久久久中文字幕| 久久精品亚洲乱码伦伦中文| 婷婷久久五月天| 精品久久8x国产免费观看| 日韩精品久久久久久| 欧美久久综合九色综合| 亚洲AV乱码久久精品蜜桃| 国产美女久久久| 亚洲国产视频久久| 久久99精品久久久久久久久久 | 久久99精品九九九久久婷婷| 国产精品一区二区久久精品涩爱| 久久精品无码午夜福利理论片| 狠狠精品久久久无码中文字幕 | 亚洲综合日韩久久成人AV| 久久这里只有精品首页| 性做久久久久久久久| 久久久中文字幕| 亚洲va中文字幕无码久久不卡| 久久99精品久久久久久9蜜桃| 久久综合国产乱子伦精品免费|