Esempio n. 1
0
        public void Update()
        {
            YOffset++;
            if (YOffset == ScaleHelper.ScaleHeight(Block.BlockHeight) - 1)
            {
                // Get a new random row
                Row randomRow = Row.RandomRow(this);

                // Insert into position 0 on both the rows and columns (its just easier this way)
                rows.Insert(0, randomRow);
                for (var i = 0; i < columns.Length; i++)
                {
                    columns[i].Insert(0, randomRow[i]);
                    columnIsDirty[i] = true;
                }

                YOffset = 0;
            }

            // Check for matches in rows/columns
            DoMatchChecking();

            // Update our rows
            foreach (Row r in rows)
            {
                r.Update();
            }
        }
        // Main draw method
        public void Draw(SpriteBatch spriteBatch)
        {
            position.Y = ScaleHelper.BackBufferHeight - parent.YOffset - (ScaleHelper.ScaleHeight(Block.BlockHeight * parent.IndexOfRow(this)));

            foreach (Block b in blocks)
            {
                b.Draw(spriteBatch);
            }
        }
        // Constructor
        public Row(GameBoard parent)
        {
            this.parent = parent;
            blocks      = new Block[6];

            position = new Point(
                ScaleHelper.ScaleWidth(GameBoard.GameBoardXAnchor),
                ScaleHelper.BackBufferHeight - parent.YOffset - (ScaleHelper.ScaleHeight(Block.BlockHeight * parent.IndexOfRow(this))));
        }
        public void Update()
        {
            YOffset++;
            if (YOffset == ScaleHelper.ScaleHeight(Block.BlockHeight) - 1)
            {
                rows.Insert(0, Row.RandomRow(this));
                YOffset = 0;
            }

            // Update our rows
            foreach (Row r in rows)
            {
                r.Update();
            }
        }
Esempio n. 5
0
        // Main draw method
        public void Draw(SpriteBatch spriteBatch)
        {
            Point drawPos = new Point();

            drawPos.X = (ScaleHelper.ScaleWidth(GameBoard.GameBoardXAnchor) + (ScaleHelper.ScaleWidth(Block.BlockWidth) * position.X));
            drawPos.Y = (ScaleHelper.BackBufferHeight - parent.YOffset - (ScaleHelper.ScaleHeight(Block.BlockHeight) * position.Y));

            Point drawScale = new Point();

            drawScale.X = ScaleHelper.ScaleWidth(playerTexture.Width) / 2;
            drawScale.Y = ScaleHelper.ScaleHeight(playerTexture.Height) / 2;

            //spriteBatch.Draw(playerTexture, new Rectangle(drawPos, drawScale), Color.White);
            spriteBatch.Draw(playerTexture, new Rectangle(drawPos, drawScale), Color.Black);
        }
Esempio n. 6
0
        // This needs polishing
        private void OnMouseMoved(Point mousePosition)
        {
            mousePosition.X -= ScaleHelper.ScaleWidth(GameBoard.GameBoardXAnchor);
            // mousePosition.X -= ScaleHelper.ScaleWidth(Block.BlockWidth) / 2;
            mousePosition.Y -= ScaleHelper.ScaleHeight(Block.BlockHeight);

            position.X = mousePosition.X / ScaleHelper.ScaleWidth(Block.BlockWidth);
            position.Y = 12 - (mousePosition.Y / ScaleHelper.ScaleHeight(Block.BlockHeight));

            // Make sure X & Y are within bounds
            position.X = Math.Min(position.X, 4);
            position.X = Math.Max(position.X, 0);

            position.Y = Math.Min(position.Y, 12);
            position.Y = Math.Max(position.Y, 1);
        }
Esempio n. 7
0
        // Main draw method
        public void Draw(SpriteBatch spriteBatch)
        {
            // Draw the background
            spriteBatch.Draw(ContentHelper.GetTexture("gameBoardBackground"), new Rectangle(Point.Zero, new Point(ScaleHelper.BackBufferWidth, ScaleHelper.BackBufferHeight)), Color.Gray);

            // Draw the panel
            Rectangle drawRectangle = new Rectangle(
                new Point(widthBuffer, heightBuffer),
                new Point(ScaleHelper.ScaleWidth(pausePanel.Width), ScaleHelper.ScaleHeight(pausePanel.Height)));

            spriteBatch.Draw(pausePanel, drawRectangle, Color.PowderBlue);

            // Draw the buttons
            continueButton.Draw(spriteBatch);

            optionsButton.Draw(spriteBatch);
        }
Esempio n. 8
0
        //
        // Public fields
        //

        //
        // Constructor
        //

        public PauseMenu(Game1 parent)
        {
            this.parent = parent;
            pausePanel  = ContentHelper.GetTexture("grey_panel");

            //
            widthBuffer  = (ScaleHelper.BackBufferWidth - ScaleHelper.ScaleWidth(pausePanel.Width)) / 2;
            heightBuffer = (ScaleHelper.BackBufferHeight - ScaleHelper.ScaleHeight(pausePanel.Height)) / 2;

            int buttonWidthBuffer  = widthBuffer + (widthBuffer - 200) / 2;
            int buttonHeightBuffer = heightBuffer + (heightBuffer - 50) / 2;

            // Init buttons
            continueButton = new GuiButton(new Point(buttonWidthBuffer, buttonHeightBuffer), new Point(200, 50), "Continue");
            continueButton.GuiButtonClicked += Unpause;

            optionsButton = new GuiButton(new Point(buttonWidthBuffer, buttonHeightBuffer * 2), new Point(200, 50), "Options");
        }
Esempio n. 9
0
        // Main update method
        public void Update()
        {
            // Once a full row has been exposed on the bottom line, add another
            if (YOffset >= ScaleHelper.ScaleHeight(Block.BlockHeight))
            {
                AddRow(); YOffset = 0; // Reset the Y offset
            }

            // Update the player
            player.Update();

            // Update all blocks on the gameboard
            for (var i = 0; i < gameBoard.Rows; i++)
            {
                for (var j = 0; j < gameBoard.Columns; j++)
                {
                    var thisBlock = gameBoard[i, j];
                    // Only update this block if it is not empty
                    if (!(thisBlock.Type == BlockType.Empty))
                    {
                        // Update the position of this block based on the position in the board
                        thisBlock.UpdatePosition(j, i, YOffset);

                        // Now do the regular update
                        thisBlock.Update();

                        // If the block is now empty, flag it as empty on the gameboard
                        if (thisBlock.Type == BlockType.Empty)
                        {
                            gameBoard.RemoveItem(i, j);
                        }
                    }
                }
            }

            // Do the "gravity" of the gameboard
            gameBoard.CompressBoardDownwards();
            gameBoard.RemoveEmptyRows();

            // Check for any matches this frame
            DoMatchChecking();
        }
Esempio n. 10
0
        //
        // Constructor
        //
        public Score()
        {
            score     = 0;
            combo     = 1;// Combo is always 1x to start with
            scoreFont = ContentHelper.GetFont("KenVectorFutureThin");

            // Efficiency - set the draw variables here and recalculate them
            // if score changed (or screen size changes)
            scorePosition = new Vector2(
                ScaleHelper.BackBufferWidth - (ScaleHelper.BackBufferWidth / 3),
                ScaleHelper.BackBufferHeight / 15);

            scoreRectangle = new Rectangle(
                (int)scorePosition.X,
                (int)scorePosition.Y,
                ScaleHelper.ScaleWidth(ScoreBoxWidth),
                ScaleHelper.ScaleHeight(ScoreBoxHeight));

            scoreString = GetScoreString();
            // Make sure the score is right-aligned
            scorePosition.X = scoreRectangle.Right - ScaleHelper.ScaleWidth((int)scoreFont.MeasureString(scoreString).X);

            comboPosition = new Vector2(
                ScaleHelper.BackBufferWidth - (int)(ScaleHelper.BackBufferWidth / 5.6),
                ScaleHelper.BackBufferHeight / 5);

            comboRectangle = new Rectangle(
                (int)comboPosition.X,
                (int)comboPosition.Y,
                ScaleHelper.ScaleWidth(ComboBoxWidth),
                ScaleHelper.ScaleHeight(ComboBoxHeight));

            comboString = GetComboString();
            // Make sure the combo is right-aligned
            comboPosition.X = comboRectangle.Right - ScaleHelper.ScaleWidth((int)scoreFont.MeasureString(comboString).X);
        }