Exemple #1
0
        public void PlayGameSound(GameScene game)
        {
            if (device == null) return;

            ticks++;

            // �Đ����I�����Buffer����ځ[�񂷂�B
            for (int i = 0; i < numChannels; i++)
            {
                if (!channels[i].Buffer.Status.Playing)
                {
                    channels[i].Buffer.Dispose();
                    numChannels--;
                    for (int j = i; j < numChannels; j++)
                    {
                        channels[j] = channels[j + 1];
                    }
                }
            }

            if (ticks % 2 == 0)
            {
                for (int i = 0; i < numChannels; i++)
                {
                    channels[i].Buffer.Pan = CalcPan(channels[i].Thing);
                    channels[i].Buffer.Volume = CalcVolume(channels[i].Thing);
                }
            }

            game.ThingList.PlaySound(this, buffers);
        }
Exemple #2
0
 public Switch(GameScene game, int row, int col)
     : base(game, row, col)
 {
     Position.Y = row * Mafia.BLOCK_WIDTH + 12;
     pressed = false;
     pressSound = false;
 }
Exemple #3
0
 public Box(GameScene game, int row, int col)
     : base(game, row, col)
 {
     LandState = ON_GROUND;
     prevLandState = ON_GROUND;
     MoveCount = 0;
     pushed = false;
 }
Exemple #4
0
 public Tiun(GameScene game, Vector position, int direction, int speed, int life, int type)
     : base(game, position)
 {
     this.direction = direction;
     this.speed = speed;
     this.life = life;
     this.type = type;
 }
Exemple #5
0
 public Thing(GameScene game, Vector position)
 {
     this.Game = game;
     this.Position = position;
     Velocity = Vector.Zero;
     Removed = false;
     Carry = new ThingList();
 }
Exemple #6
0
        public FallBlock(GameScene game, int row, int col, int type)
            : base(game, row, col)
        {
            this.type = type;
            falling = false;
            damaged = false;

            fallSound = false;
        }
Exemple #7
0
 public Door(GameScene game, int row, int col, bool open)
     : base(game, row, col)
 {
     Position.X = col * Mafia.BLOCK_WIDTH + 4;
     Position.Y = (row - 3) * Mafia.BLOCK_WIDTH;
     Open = open;
     closeHeight = row * Mafia.BLOCK_WIDTH;
     openHeight = closeHeight - 48;
 }
Exemple #8
0
 public Thing(GameScene game, int row, int col)
 {
     this.Game = game;
     Position.X = col * Mafia.BLOCK_WIDTH;
     Position.Y = row * Mafia.BLOCK_WIDTH;
     Velocity = Vector.Zero;
     Removed = false;
     Carry = new ThingList();
 }
Exemple #9
0
        public Lift(GameScene game, int row, int col, int behavior)
            : base(game, row, col)
        {
            switch (behavior)
            {
                case 0:
                    Velocity.X = -1;
                    break;
                case 1:
                    Velocity.Y = -1;
                    break;
                case 2:
                    Velocity.X = 1;
                    break;
                case 3:
                    Velocity.Y = 1;
                    break;
                case 4:
                    Velocity.X = -2;
                    break;
                case 5:
                    Velocity.Y = -2;
                    break;
                case 6:
                    Velocity.X = 2;
                    break;
                case 7:
                    Velocity.Y = 2;
                    break;
                case 8:
                    Velocity.X = -4;
                    break;
                case 9:
                    Velocity.X = 4;
                    break;

            }

            moveCount = ((liftCount++) % 16) * 2;
        }
Exemple #10
0
 public Player(GameScene game, int row, int col, int direction)
     : base(game, row, col)
 {
     if (direction == RIGHT)
     {
         this.Direction = RIGHT;
     }
     else
     {
         this.Direction = LEFT;
     }
     Animation = 0;
     LandState = IN_AIR;
     JumpTick = -1;
     focus = Vector.Zero;
     if (Center.X + focus.X < Mafia.SCREEN_WIDTH / 2)
     {
         focus.X = Mafia.SCREEN_WIDTH / 2 - Center.X;
     }
     else if (Center.X + focus.X > game.Map.Width - Mafia.SCREEN_WIDTH / 2)
     {
         focus.X = game.Map.Width - Mafia.SCREEN_WIDTH / 2 - Center.X;
     }
     if (Center.Y + focus.Y < Mafia.SCREEN_HEIGHT / 2)
     {
         focus.Y = Mafia.SCREEN_HEIGHT / 2 - Center.Y;
     }
     else if (Center.Y + focus.Y > game.Map.Height - Mafia.SCREEN_HEIGHT / 2)
     {
         focus.Y = game.Map.Height - Mafia.SCREEN_HEIGHT / 2 - Center.Y;
     }
     missed = false;
     left = up = right = down = false;
     jumpSound = false;
     tiunSound = false;
     coinSound = false;
 }
Exemple #11
0
 public Player(GameScene game, int row, int col, int direction) : base(game, row, col)
 {
     if (direction == RIGHT)
     {
         this.Direction = RIGHT;
     }
     else
     {
         this.Direction = LEFT;
     }
     Animation = 0;
     LandState = IN_AIR;
     JumpTick  = -1;
     focus     = Vector.Zero;
     if (Center.X + focus.X < Mafia.SCREEN_WIDTH / 2)
     {
         focus.X = Mafia.SCREEN_WIDTH / 2 - Center.X;
     }
     else if (Center.X + focus.X > game.Map.Width - Mafia.SCREEN_WIDTH / 2)
     {
         focus.X = game.Map.Width - Mafia.SCREEN_WIDTH / 2 - Center.X;
     }
     if (Center.Y + focus.Y < Mafia.SCREEN_HEIGHT / 2)
     {
         focus.Y = Mafia.SCREEN_HEIGHT / 2 - Center.Y;
     }
     else if (Center.Y + focus.Y > game.Map.Height - Mafia.SCREEN_HEIGHT / 2)
     {
         focus.Y = game.Map.Height - Mafia.SCREEN_HEIGHT / 2 - Center.Y;
     }
     missed    = false;
     left      = up = right = down = false;
     jumpSound = false;
     tiunSound = false;
     coinSound = false;
 }
Exemple #12
0
 public Coin(GameScene game, int row, int col)
     : base(game, row, col)
 {
     animation = 0;
 }
Exemple #13
0
        public GameScene CreateGame()
        {
            GameScene game = new GameScene(title, numRows, numCols);

            for (int row = 0; row < numRows; row++)
            {
                for (int col = 0; col < numCols; col++)
                {
                    try
                    {
                        switch (source[row][col])
                        {
                        case ' ':
                            game.Map[row, col] = Map.NONE;
                            break;

                        case '<':
                            if (row != numRows - 1 && source[row + 1][col] == 'F')
                            {
                                game.AddFallBlock(row, col, Map.SPIKE_LEFT);
                            }
                            else if (row != numRows - 1 && source[row + 1][col] == 'E')
                            {
                                game.AddDelayedFallBlock(row, col, Map.SPIKE_LEFT);
                            }
                            else
                            {
                                game.Map[row, col] = Map.SPIKE_LEFT;
                            }
                            break;

                        case 'A':
                            game.Map[row, col] = Map.SPIKE_UP;
                            break;

                        case '>':
                            if (row != numRows - 1 && source[row + 1][col] == 'F')
                            {
                                game.AddFallBlock(row, col, Map.SPIKE_RIGHT);
                            }
                            else if (row != numRows - 1 && source[row + 1][col] == 'E')
                            {
                                game.AddDelayedFallBlock(row, col, Map.SPIKE_RIGHT);
                            }
                            else
                            {
                                game.Map[row, col] = Map.SPIKE_RIGHT;
                            }
                            break;

                        case 'V':
                            if (row != numRows - 1 && source[row + 1][col] == 'F')
                            {
                                game.AddFallBlock(row, col, Map.SPIKE_DOWN);
                            }
                            else if (row != numRows - 1 && source[row + 1][col] == 'E')
                            {
                                game.AddDelayedFallBlock(row, col, Map.SPIKE_DOWN);
                            }
                            else
                            {
                                game.Map[row, col] = Map.SPIKE_DOWN;
                            }
                            break;

                        case 'P':
                            game.AddPlayer(row, col, int.Parse(source[row + 1][col].ToString()));
                            break;

                        case 'C':
                            game.AddCoin(row, col);
                            break;

                        case 'L':
                            game.AddLift(row, col, int.Parse(source[row][col + 1].ToString()));
                            break;

                        case 'R':
                            game.Map[row, col] = Map.LIFT_RETURN;
                            break;

                        case 'H':
                            game.AddSpring(row, col);
                            break;

                        case 'B':
                            game.AddBox(row, col);
                            break;

                        case 'S':
                            game.AddSwitch(row, col);
                            break;

                        case 'D':
                            game.AddDoor(row, col, int.Parse(source[row + 1][col].ToString()));
                            if (source[row + 1][col - 1] == '<' || source[row + 1][col + 1] == '>')
                            {
                                game.Map[row + 1, col] = Map.DOOR_SLIDE;
                            }
                            game.Map[row - 1, col] = Map.DOOR_SLIDE;
                            game.Map[row - 2, col] = Map.DOOR_SLIDE;
                            game.Map[row - 3, col] = Map.DOOR_SLIDE;
                            break;

                        default:
                            if ('a' <= source[row][col] && source[row][col] <= 'z')
                            {
                                if (row != numRows - 1 && source[row + 1][col] == 'F')
                                {
                                    game.AddFallBlock(row, col, 1);
                                }
                                else if (row != numRows - 1 && source[row + 1][col] == 'E')
                                {
                                    game.AddDelayedFallBlock(row, col, 1);
                                }
                                else
                                {
                                    game.Map[row, col] = 1;
                                }
                            }
                            break;
                        }
                    }
                    catch
                    {
                        throw new Exception(fileName + " の " + (row + 4) + " 行 " + (col + 1) + " 列の辺りがおかしいです><");
                    }
                }
            }
            return(game);
        }
Exemple #14
0
 public Switch(GameScene game, int row, int col) : base(game, row, col)
 {
     Position.Y = row * Mafia.BLOCK_WIDTH + 12;
     pressed    = false;
     pressSound = false;
 }
Exemple #15
0
 public void DrawGameScene(GameScene game)
 {
     game.Draw(this);
 }
Exemple #16
0
 public Spring(GameScene game, int row, int col) : base(game, row, col)
 {
     animation = 0;
 }
Exemple #17
0
 public void DrawGameScene(GameScene game)
 {
     game.Draw(this);
 }
Exemple #18
0
 public Spring(GameScene game, int row, int col)
     : base(game, row, col)
 {
     animation = 0;
 }
Exemple #19
0
 public Coin(GameScene game, int row, int col) : base(game, row, col)
 {
     animation = 0;
 }
Exemple #20
0
 public GameScene CreateGame()
 {
     GameScene game = new GameScene(title, numRows, numCols);
     for (int row = 0; row < numRows; row++)
     {
         for (int col = 0; col < numCols; col++)
         {
             try
             {
                 switch (source[row][col])
                 {
                     case ' ':
                         game.Map[row, col] = Map.NONE;
                         break;
                     case '<':
                         if (row != numRows - 1 && source[row + 1][col] == 'F') game.AddFallBlock(row, col, Map.SPIKE_LEFT);
                         else if (row != numRows - 1 && source[row + 1][col] == 'E') game.AddDelayedFallBlock(row, col, Map.SPIKE_LEFT);
                         else game.Map[row, col] = Map.SPIKE_LEFT;
                         break;
                     case 'A':
                         game.Map[row, col] = Map.SPIKE_UP;
                         break;
                     case '>':
                         if (row != numRows - 1 && source[row + 1][col] == 'F') game.AddFallBlock(row, col, Map.SPIKE_RIGHT);
                         else if (row != numRows - 1 && source[row + 1][col] == 'E') game.AddDelayedFallBlock(row, col, Map.SPIKE_RIGHT);
                         else game.Map[row, col] = Map.SPIKE_RIGHT;
                         break;
                     case 'V':
                         if (row != numRows - 1 && source[row + 1][col] == 'F') game.AddFallBlock(row, col, Map.SPIKE_DOWN);
                         else if (row != numRows - 1 && source[row + 1][col] == 'E') game.AddDelayedFallBlock(row, col, Map.SPIKE_DOWN);
                         else game.Map[row, col] = Map.SPIKE_DOWN;
                         break;
                     case 'P':
                         game.AddPlayer(row, col, int.Parse(source[row + 1][col].ToString()));
                         break;
                     case 'C':
                         game.AddCoin(row, col);
                         break;
                     case 'L':
                         game.AddLift(row, col, int.Parse(source[row][col + 1].ToString()));
                         break;
                     case 'R':
                         game.Map[row, col] = Map.LIFT_RETURN;
                         break;
                     case 'H':
                         game.AddSpring(row, col);
                         break;
                     case 'B':
                         game.AddBox(row, col);
                         break;
                     case 'S':
                         game.AddSwitch(row, col);
                         break;
                     case 'D':
                         game.AddDoor(row, col, int.Parse(source[row + 1][col].ToString()));
                         if (source[row + 1][col - 1] == '<' || source[row + 1][col + 1] == '>')
                         {
                             game.Map[row + 1, col] = Map.DOOR_SLIDE;
                         }
                         game.Map[row - 1, col] = Map.DOOR_SLIDE;
                         game.Map[row - 2, col] = Map.DOOR_SLIDE;
                         game.Map[row - 3, col] = Map.DOOR_SLIDE;
                         break;
                     default:
                         if ('a' <= source[row][col] && source[row][col] <= 'z')
                         {
                             if (row != numRows - 1 && source[row + 1][col] == 'F') game.AddFallBlock(row, col, 1);
                             else if (row != numRows - 1 && source[row + 1][col] == 'E') game.AddDelayedFallBlock(row, col, 1);
                             else game.Map[row, col] = 1;
                         }
                         break;
                 }
             }
             catch
             {
                 throw new Exception(fileName + " �� " + (row + 4) + " �s " + (col + 1) + " ��̕ӂ肪���������ł�����");
             }
         }
     }
     return game;
 }
Exemple #21
0
        public void Run()
        {
            form = new Form();
            // �E�B���h�E�T�C�Y�•ς̕����ǂ��ˁH
            form.Icon = MafiaLoader.DefaultLoader.GetIcon("mafia.ico");
            form.Text = Mafia.TITLE;

            stages = new Stage[numStages];
            for (int i = 0; i < numStages; i++)
            {
                if (i < Mafia.NUM_STAGES)
                {
                    stages[i] = MafiaLoader.DefaultLoader.GetStage("stage" + i + ".stg");
                }
                else
                {
                    stages[i] = MafiaLoader.DefaultLoader.GetStage(stagePath[i - Mafia.NUM_STAGES]);
                }
            }
            if (stagePath.Length == 0)
            {
                currentStageIndex = 0;
            }
            else
            {
                currentStageIndex = Mafia.NUM_STAGES;
            }

            title = new TitleScene();
            select = new SelectScene(stages, 0);

            state = TITLE_SCENE;

            video = new MafiaVideo(form, MessageBox.Show("�t���X�N���[���ŋN�����܂����H", "�m�F", MessageBoxButtons.YesNo) == DialogResult.Yes);
            sound = new MafiaSound(form);
            input = new MafiaInput(form);

            try
            {
                bgm = new Audio(Application.StartupPath + "\\" + Mafia.RESOURCE_NAME + "\\mafia.mp3");
                bgm.Ending += new EventHandler(bgm_Ending);
            }
            catch
            {
            }

            form.Show();

            timer = new FpsTimer(Mafia.FPS, false);

            while (CheckState())
            {
                if (input.ShouldToggleFullscreen())
                {
                    video.ToggleFullscreen();
                }
                switch (state)
                {
                    case TITLE_SCENE:
                        // �C�F���h�E�Anull���ǂ����`�F�b�N���Ȃ���Ȃ��Ƃ͉�����
                        if (bgm != null && bgm.Playing)
                        {
                            bgm.Stop();
                        }
                        switch (title.Tick(input.GetCurrentTitleInput()))
                        {
                            case TitleScene.NONE:
                                if (timer.ShouldRender() && video.CheckDrawable())
                                {
                                    video.Begin();
                                    video.DrawTitleScene(title);
                                    video.DrawFps(timer.GetCurrentFps());
                                    video.End();
                                    video.Present();
                                }
                                break;
                            case TitleScene.START_GAME:
                                select.CurrentStage = currentStageIndex;
                                state = SELECT_SCENE_TITLE;
                                break;
                            case TitleScene.EXIT:
                                form.Close();
                                break;
                        }
                        break;
                    case SELECT_SCENE_TITLE:
                        {
                            title.Tick(TitleInput.Empty);
                            int result = select.Tick(input.GetCurrentSelectInput());
                            switch (result)
                            {
                                case SelectScene.NONE:
                                    if (timer.ShouldRender() && video.CheckDrawable())
                                    {
                                        video.Begin();
                                        video.DrawTitleScene(title);
                                        video.DrawSelectScene(select);
                                        video.DrawFps(timer.GetCurrentFps());
                                        video.End();
                                        video.Present();
                                    }
                                    sound.PlaySelectSound(select);
                                    break;
                                case SelectScene.GOTO_TITLE:
                                    state = TITLE_SCENE;
                                    break;
                                default:
                                    state = GAME_SCENE;
                                    game = stages[currentStageIndex = result].CreateGame();
                                    break;
                            }
                        }
                        break;
                    case GAME_SCENE:
                        if (bgm != null && !bgm.Playing)
                        {
                            bgm.Play();
                        }
                        switch (game.Tick(input.GetCurrentGameInput()))
                        {
                            case GameScene.NONE:
                                if (timer.ShouldRender() && video.CheckDrawable())
                                {
                                    video.Begin();
                                    video.DrawGameScene(game);
                                    video.DrawFps(timer.GetCurrentFps());
                                    video.End();
                                    video.Present();
                                }
                                sound.PlayGameSound(game);
                                break;
                            case GameScene.RESET_GAME:
                                sound.StopSounds();
                                game = stages[currentStageIndex].CreateGame();
                                break;
                            case GameScene.CLEAR_GAME:
                                sound.StopSounds();
                                currentStageIndex = (currentStageIndex + 1) % numStages;
                                game = stages[currentStageIndex].CreateGame();
                                break;
                            case GameScene.SELECT:
                                if (timer.ShouldRender() && video.CheckDrawable())
                                {
                                    video.Begin();
                                    video.DrawGameScene(game);
                                    video.DrawFps(timer.GetCurrentFps());
                                    video.End();
                                    video.Present();
                                }
                                sound.PlayGameSound(game);
                                select.CurrentStage = currentStageIndex;
                                state = SELECT_SCENE_GAME;
                                break;
                            case GameScene.GOTO_TITLE:
                                sound.StopSounds();
                                state = TITLE_SCENE;
                                break;
                        }
                        break;
                    case SELECT_SCENE_GAME:
                        game.Tick(GameInput.Empty);
                        {
                            int result = select.Tick(input.GetCurrentSelectInput());
                            switch (result)
                            {
                                case SelectScene.NONE:
                                    if (timer.ShouldRender() && video.CheckDrawable())
                                    {
                                        video.Begin();
                                        video.DrawGameScene(game);
                                        video.DrawSelectScene(select);
                                        video.DrawFps(timer.GetCurrentFps());
                                        video.End();
                                        video.Present();
                                    }
                                    sound.PlayGameSound(game);
                                    sound.PlaySelectSound(select);
                                    break;
                                case SelectScene.GOTO_TITLE:
                                    sound.StopSounds();
                                    state = TITLE_SCENE;
                                    break;
                                default:
                                    sound.StopSounds();
                                    game = stages[currentStageIndex = result].CreateGame();
                                    state = GAME_SCENE;
                                    break;
                            }
                        }
                        break;
                }
                Application.DoEvents();
                timer.Wait();
            }

            if (bgm != null)
            {
                if (bgm.Playing)
                {
                    bgm.Stop();
                }
                bgm.Dispose();
                bgm = null;
            }
            video.Dispose();
            video = null;
            sound.Dispose();
            sound = null;
            input.Dispose();
            input = null;
        }
Exemple #22
0
        public void Run()
        {
            form = new Form();
            // ウィンドウサイズ可変の方が良くね?
            form.Icon = MafiaLoader.DefaultLoader.GetIcon("mafia.ico");
            form.Text = Mafia.TITLE;

            stages = new Stage[numStages];
            for (int i = 0; i < numStages; i++)
            {
                if (i < Mafia.NUM_STAGES)
                {
                    stages[i] = MafiaLoader.DefaultLoader.GetStage("stage" + i + ".stg");
                }
                else
                {
                    stages[i] = MafiaLoader.DefaultLoader.GetStage(stagePath[i - Mafia.NUM_STAGES]);
                }
            }
            if (stagePath.Length == 0)
            {
                currentStageIndex = 0;
            }
            else
            {
                currentStageIndex = Mafia.NUM_STAGES;
            }

            title  = new TitleScene();
            select = new SelectScene(stages, 0);

            state = TITLE_SCENE;

            video = new MafiaVideo(form, MessageBox.Show("フルスクリーンで起動しますか?", "確認", MessageBoxButtons.YesNo) == DialogResult.Yes);
            sound = new MafiaSound(form);
            input = new MafiaInput(form);

            try
            {
                bgm         = new Audio(Application.StartupPath + "\\" + Mafia.RESOURCE_NAME + "\\mafia.mp3");
                bgm.Ending += new EventHandler(bgm_Ending);
            }
            catch
            {
            }

            form.Show();

            timer = new FpsTimer(Mafia.FPS, false);

            while (CheckState())
            {
                if (input.ShouldToggleFullscreen())
                {
                    video.ToggleFullscreen();
                }
                switch (state)
                {
                case TITLE_SCENE:
                    // イェンドウ、nullかどうかチェックしなきゃならんとは何事か
                    if (bgm != null && bgm.Playing)
                    {
                        bgm.Stop();
                    }
                    switch (title.Tick(input.GetCurrentTitleInput()))
                    {
                    case TitleScene.NONE:
                        if (timer.ShouldRender() && video.CheckDrawable())
                        {
                            video.Begin();
                            video.DrawTitleScene(title);
                            video.DrawFps(timer.GetCurrentFps());
                            video.End();
                            video.Present();
                        }
                        break;

                    case TitleScene.START_GAME:
                        select.CurrentStage = currentStageIndex;
                        state = SELECT_SCENE_TITLE;
                        break;

                    case TitleScene.EXIT:
                        form.Close();
                        break;
                    }
                    break;

                case SELECT_SCENE_TITLE:
                {
                    title.Tick(TitleInput.Empty);
                    int result = select.Tick(input.GetCurrentSelectInput());
                    switch (result)
                    {
                    case SelectScene.NONE:
                        if (timer.ShouldRender() && video.CheckDrawable())
                        {
                            video.Begin();
                            video.DrawTitleScene(title);
                            video.DrawSelectScene(select);
                            video.DrawFps(timer.GetCurrentFps());
                            video.End();
                            video.Present();
                        }
                        sound.PlaySelectSound(select);
                        break;

                    case SelectScene.GOTO_TITLE:
                        state = TITLE_SCENE;
                        break;

                    default:
                        state = GAME_SCENE;
                        game  = stages[currentStageIndex = result].CreateGame();
                        break;
                    }
                }
                break;

                case GAME_SCENE:
                    if (bgm != null && !bgm.Playing)
                    {
                        bgm.Play();
                    }
                    switch (game.Tick(input.GetCurrentGameInput()))
                    {
                    case GameScene.NONE:
                        if (timer.ShouldRender() && video.CheckDrawable())
                        {
                            video.Begin();
                            video.DrawGameScene(game);
                            video.DrawFps(timer.GetCurrentFps());
                            video.End();
                            video.Present();
                        }
                        sound.PlayGameSound(game);
                        break;

                    case GameScene.RESET_GAME:
                        sound.StopSounds();
                        game = stages[currentStageIndex].CreateGame();
                        break;

                    case GameScene.CLEAR_GAME:
                        sound.StopSounds();
                        currentStageIndex = (currentStageIndex + 1) % numStages;
                        game = stages[currentStageIndex].CreateGame();
                        break;

                    case GameScene.SELECT:
                        if (timer.ShouldRender() && video.CheckDrawable())
                        {
                            video.Begin();
                            video.DrawGameScene(game);
                            video.DrawFps(timer.GetCurrentFps());
                            video.End();
                            video.Present();
                        }
                        sound.PlayGameSound(game);
                        select.CurrentStage = currentStageIndex;
                        state = SELECT_SCENE_GAME;
                        break;

                    case GameScene.GOTO_TITLE:
                        sound.StopSounds();
                        state = TITLE_SCENE;
                        break;
                    }
                    break;

                case SELECT_SCENE_GAME:
                    game.Tick(GameInput.Empty);
                    {
                        int result = select.Tick(input.GetCurrentSelectInput());
                        switch (result)
                        {
                        case SelectScene.NONE:
                            if (timer.ShouldRender() && video.CheckDrawable())
                            {
                                video.Begin();
                                video.DrawGameScene(game);
                                video.DrawSelectScene(select);
                                video.DrawFps(timer.GetCurrentFps());
                                video.End();
                                video.Present();
                            }
                            sound.PlayGameSound(game);
                            sound.PlaySelectSound(select);
                            break;

                        case SelectScene.GOTO_TITLE:
                            sound.StopSounds();
                            state = TITLE_SCENE;
                            break;

                        default:
                            sound.StopSounds();
                            game  = stages[currentStageIndex = result].CreateGame();
                            state = GAME_SCENE;
                            break;
                        }
                    }
                    break;
                }
                Application.DoEvents();
                timer.Wait();
            }

            if (bgm != null)
            {
                if (bgm.Playing)
                {
                    bgm.Stop();
                }
                bgm.Dispose();
                bgm = null;
            }
            video.Dispose();
            video = null;
            sound.Dispose();
            sound = null;
            input.Dispose();
            input = null;
        }