Exemplo n.º 1
0
 // Reset the score
 public void ResetScore()
 {
     score       = 0;
     scoreString = GetScoreString();
     // Make sure the score is right-aligned
     scorePosition.X = scoreRectangle.Right - ScaleHelper.ScaleWidth((int)scoreFont.MeasureString(scoreString).X);
 }
Exemplo n.º 2
0
        // Main draw method
        public void Draw(SpriteBatch spriteBatch)
        {
            // Don't draw matched blocks (!!TEMP!!)
            if (isMatched)
            {
                return;
            }

            if (type != BlockType.Empty)
            {
                // Create a point for the "actual" position of the tile
                Point actualPosition = new Point(
                    ScaleHelper.ScaleWidth((int)position.X),
                    (int)position.Y);

                // Create a point for the "actual" scale of the tile
                Point actualScale = ScaleHelper.ScalePoint(new Point(BlockWidth, BlockHeight));

                // Draw the tile
                spriteBatch.Draw(TileTexture, new Rectangle(actualPosition, actualScale), Color.White);

                // Calculate the "actual" position of the symbol (add 1/4 of the block height)
                actualPosition.X += (int)Math.Ceiling((float)actualScale.X / 4);
                actualPosition.Y += (int)Math.Ceiling((float)actualScale.Y / 4);

                // Calculate the scale of the symbol (half of that of the block)
                actualScale.X /= 2;
                actualScale.Y /= 2;

                // Draw the symbol
                spriteBatch.Draw(SymbolTexture, new Rectangle(actualPosition, actualScale), Color.White);
            }
        }
Exemplo n.º 3
0
        // Main draw method
        public void Draw(SpriteBatch spriteBatch)
        {
            if (type == BlockType.Empty)
            {
                return; // Never draw empty blocks
            }
            if (drawThisFrame)
            {
                // Create a point for the "actual" position of the tile
                Point drawPosition = new Point(
                    ScaleHelper.ScaleWidth((int)position.X),
                    (int)position.Y);

                // Create a point for the "actual" scale of the tile
                Point drawScale = ScaleHelper.ScalePoint(new Point(BlockWidth, BlockHeight));

                // Draw the tile
                spriteBatch.Draw(TileTexture, new Rectangle(drawPosition, drawScale), drawColor);

                // Calculate the "actual" position of the symbol (add 1/4 of the block height)
                drawPosition.X += (int)Math.Ceiling((float)drawScale.X / 4);
                drawPosition.Y += (int)Math.Ceiling((float)drawScale.Y / 4);

                // Calculate the scale of the symbol (half of that of the block)
                drawScale.X /= 2;
                drawScale.Y /= 2;

                // Draw the symbol
                spriteBatch.Draw(SymbolTexture, new Rectangle(drawPosition, drawScale), drawColor);
            }
        }
Exemplo n.º 4
0
 // Add to the combo
 public void AddCombo()
 {
     combo++;
     comboString = GetComboString();
     // Make sure the combo is right-aligned
     comboPosition.X = comboRectangle.Right - ScaleHelper.ScaleWidth((int)scoreFont.MeasureString(comboString).X);
 }
Exemplo n.º 5
0
 // Add to the score
 public void AddScore()
 {
     score      += RandomHelper.Next(100, 999) * combo;
     score       = Math.Min(MaxScore, score); // Make sure score doesn't overflow
     scoreString = GetScoreString();
     // Make sure the score is right-aligned
     scorePosition.X = scoreRectangle.Right - ScaleHelper.ScaleWidth((int)scoreFont.MeasureString(scoreString).X);
 }
Exemplo n.º 6
0
        // 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))));
        }
Exemplo n.º 7
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);
        }
Exemplo n.º 8
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);
        }
Exemplo n.º 9
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);
        }
Exemplo n.º 10
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");
        }
Exemplo n.º 11
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);
        }