示例#1
0
        public void CheckBottomCollision()
        {
            CheckGameOver();
            if (gameover)
            {
                return;
            }
            if (active_piece.didHitBin()) //|| active_piece.didHit())
            {
                soundEngine.fastPlace();
                for (int i = 0; i < 4; i++)
                {
                    Grid.addToGrid(active_piece.boxes[i].x, active_piece.boxes[i].y, active_piece.boxes[i]);
                    ZeroOneGrid.zeroGrid[active_piece.boxes[i].y, active_piece.boxes[i].x] = 1;
                }
                // Check for any completed rows:
                int rowsCollapsed = collapse();
                stats.updateStats(rowsCollapsed);
                // Adjusts the game speed based on the current level, capped at MAX_SPEED:
                fallDelay = Math.Max(Constants.START_SPEED - (stats.getLevelNum() * 2), Constants.MAX_SPEED);
                //active_piece = generateRandomShape();
                FutureSetToActiveThenGenerateNew();
            }
            else if (active_piece.didHit())
            {
                soundEngine.fastPlace();
                for (int i = 0; i < 4; i++)
                {
                    Grid.addToGrid(active_piece.boxes[i].x, active_piece.boxes[i].y, active_piece.boxes[i]);
                    ZeroOneGrid.zeroGrid[active_piece.boxes[i].y, active_piece.boxes[i].x] = 1;
                }
                int rowsCollapsed = collapse();
                stats.updateStats(rowsCollapsed);
                fallDelay = Math.Max(Constants.START_SPEED - (stats.getLevelNum() * 2), Constants.MAX_SPEED);

                //active_piece = generateRandomShape();
                FutureSetToActiveThenGenerateNew();
            }
        }
示例#2
0
        static public void drawStrings(GameStats stats)
        {
            int levels = stats.getLevelNum();
            int lines  = stats.getLineCount();
            int score  = stats.getScore();

            SpriteFont LevelLabel  = new SpriteFont("LEVEL " + levels, 280, 300);
            SpriteFont LineslLabel = new SpriteFont("LINES " + lines, 280, 275);
            SpriteFont ScoreLabel  = new SpriteFont("SCORES " + score, 280, 250);

            LevelLabel.Draw();
            LineslLabel.Draw();
            ScoreLabel.Draw();
        }
示例#3
0
        //-----------------------------------------------------------------------------
        // Game::Update()
        //      Called once per frame, update data, tranformations, etc
        //      Use this function to control process order
        //      Input, AI, Physics, Animation, and Graphics
        //-----------------------------------------------------------------------------
        public override void Update()
        {
            // Snd update - Need to be called once a frame
            AudioEngine.Update();

            //-----------------------------------------------------------
            // Input Test
            //-----------------------------------------------------------

            // InputTest.KeyboardTest();
            // InputTest.MouseTest();

            //-----------------------------------------------------------
            // Sound Experiments
            //-----------------------------------------------------------

            // Adjust music theme volume
            if (music.Volume > 0.30f)
            {
                vol_delta = -0.002f;
            }
            else if (music.Volume < 0.00f)
            {
                vol_delta = 0.002f;
            }
            music.Volume += vol_delta;

            //--------------------------------------------------------
            // Rotate Sprite
            //--------------------------------------------------------

            pRedBird.angle = pRedBird.angle + 0.01f;
            pRedBird.Update();

            //--------------------------------------------------------
            // Keyboard test
            //--------------------------------------------------------

            // Quick hack to have a one off call.
            // you need to release the keyboard between calls
            if (Azul.Input.GetKeyState(Azul.AZUL_KEY.KEY_ENTER) && prevEnterKey == 0)
            {
                prevEnterKey = Azul.AZUL_KEY.KEY_ENTER;
                sndShoot     = AudioEngine.Play2D(srcShoot, false, false, false);
            }
            else
            {
                if (!Azul.Input.GetKeyState(Azul.AZUL_KEY.KEY_ENTER))
                {
                    prevEnterKey = 0;
                }
            }

            //--------------------------------------------------------
            // Stats test
            //--------------------------------------------------------

            stats.setScore(stats.getScore() + 1);
            if (statsCount % 400 == 0)
            {
                stats.setLevelNum(stats.getLevelNum() + 1);
            }
            if (statsCount % 50 == 0)
            {
                stats.setLineCount(stats.getLineCount() + 1);
            }
            statsCount++;
        }