• <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 長(zhǎng)期尋找對(duì)戰(zhàn)略游戲感興趣的合作伙伴。

            常用鏈接

            留言簿(21)

            隨筆分類

            隨筆檔案

            SDL相關(guān)網(wǎng)站

            我的個(gè)人網(wǎng)頁(yè)

            我的小游戲

            資源下載

            搜索

            •  

            積分與排名

            • 積分 - 493181
            • 排名 - 39

            最新評(píng)論

            閱讀排行榜

            評(píng)論排行榜


            //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 閱讀(3370) 評(píng)論(0)  編輯 收藏 引用 所屬分類: mySDL_GameEngine
            观看 国产综合久久久久鬼色 欧美 亚洲 一区二区| 9191精品国产免费久久| 亚洲AV无码1区2区久久| 久久久久久久久无码精品亚洲日韩| 日本久久久久亚洲中字幕| 99久久精品国产一区二区| 久久亚洲AV无码精品色午夜| 久久精品无码专区免费东京热 | 怡红院日本一道日本久久 | 51久久夜色精品国产| 色欲综合久久躁天天躁| 狠狠色丁香久久综合婷婷| 国产精品久久久久a影院| 久久国产精品-久久精品| 久久亚洲精品无码aⅴ大香| 99热精品久久只有精品| 久久久久久国产精品无码超碰| 久久人人爽人人爽人人片AV东京热| 日韩精品久久久久久免费| 久久久高清免费视频| 久久99精品免费一区二区| 99久久国语露脸精品国产| 国内精品久久久久久久久电影网 | 久久久久无码国产精品不卡| 国产99久久精品一区二区| 麻豆成人久久精品二区三区免费 | 中文字幕精品无码久久久久久3D日动漫 | 99热成人精品免费久久| 高清免费久久午夜精品| 日韩久久久久久中文人妻| 久久国产欧美日韩精品| 欧美日韩中文字幕久久久不卡 | 久久久久久一区国产精品| 99久久婷婷国产综合精品草原| 精品国产一区二区三区久久久狼 | 久久综合狠狠综合久久| 久久精品国产2020| 亚洲国产精品久久电影欧美 | 精品久久久久久无码国产| 国产精品久久久天天影视香蕉 | 久久精品国产清自在天天线|