• <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年4月>
            303112345
            6789101112
            13141516171819
            20212223242526
            27282930123
            45678910

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

            常用鏈接

            留言簿(21)

            隨筆分類

            隨筆檔案

            SDL相關網站

            我的個人網頁

            我的小游戲

            資源下載

            搜索

            •  

            積分與排名

            • 積分 - 492138
            • 排名 - 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
            日本久久久久久久久久| 亚洲欧美一级久久精品| 中文字幕久久精品无码| 国产午夜精品理论片久久| 久久亚洲AV成人无码国产| 欧美久久久久久精选9999| 久久久久久久人妻无码中文字幕爆 | 久久精品成人影院| 久久久久久国产精品免费无码| 99久久777色| 9久久9久久精品| 久久久精品人妻无码专区不卡 | 亚洲国产高清精品线久久| 欧洲人妻丰满av无码久久不卡| 久久精品国产99国产精品| 午夜精品久久久久久久| 久久婷婷激情综合色综合俺也去| 国产精品丝袜久久久久久不卡| 曰曰摸天天摸人人看久久久| 国产亚洲美女精品久久久久狼| 久久综合噜噜激激的五月天| 欧美精品一区二区久久| 嫩草影院久久99| 国内精品久久久久久麻豆| 色8久久人人97超碰香蕉987| 国产精品综合久久第一页| 国产精品18久久久久久vr| 久久无码AV中文出轨人妻| 久久亚洲AV成人无码电影| 久久经典免费视频| 久久精品亚洲中文字幕无码麻豆| 久久久久国色AV免费看图片 | 久久久艹| 欧美久久综合九色综合| 人妻无码精品久久亚瑟影视| 国产毛片久久久久久国产毛片| 97久久天天综合色天天综合色hd| 日韩乱码人妻无码中文字幕久久 | 国色天香久久久久久久小说 | 99久久人妻无码精品系列蜜桃 | 欧洲性大片xxxxx久久久|