コード例 #1
0
ファイル: Player.cs プロジェクト: StrugglingDoge/TetrisGame
        /// <summary>
        /// Draws the proper rectangles and grid on screen.
        /// </summary>
        /// <param name="graphics"></param>
        public void Draw()
        {
            if (graphics != InstanceManager.getGameGraphics())
            {
                graphics = InstanceManager.getGameGraphics();
            }

            for (int i = placedrect.Length - 1; i > 0; i--)
            {
                graphics.DrawImage(BlockUtils.translateColorToImage(storedColor[i], false), placedrect[i]);
            }

            predict.Draw(graphics, currentColor);

            bOne   = new Rectangle(plyX, plyY, 32, 32); // player controlled rect
            bTwo   = new Rectangle(plyX + r1, plyY + r2, 32, 32);
            bThree = new Rectangle(plyX - l1, plyY - l2, 32, 32);
            bFour  = new Rectangle(plyX + t2, plyY - t1, 32, 32);
            //draw player rectangles
            graphics.DrawImage(currentTetImage, bOne);
            graphics.DrawImage(currentTetImage, bTwo);
            graphics.DrawImage(currentTetImage, bThree);
            graphics.DrawImage(currentTetImage, bFour);

            //Helpful debug information
            if (Debug.isEnabled())
            {
                Rectangle[] positions = new Rectangle[] { bOne, bTwo, bThree, bFour };
                int         lastY     = 0;
                for (int i = 0; i < positions.Length; i++)
                {
                    string blPos = "";
                    switch (i)
                    {
                    case 1:
                        blPos = " r1: " + r1 + " r2: " + r2;
                        break;

                    case 2:
                        blPos = " l1: " + l1 + " l2: " + l2;
                        break;

                    case 3:
                        blPos = " t1: " + r1 + " t2: " + t2;
                        break;
                    }
                    graphics.DrawString("(" + i + ")X: " + positions[i].X + " " + " Y: " + positions[i].Y + blPos, debugFont, Brushes.White, new Point(0, (i * 18)));
                    lastY = i + 1;
                }
                graphics.DrawString("ply", debugFont, Brushes.Black, bOne.X + 3, bOne.Y + 5);
                graphics.DrawString("rgt", debugFont, Brushes.Black, bTwo.X + 4, bTwo.Y + 5);
                graphics.DrawString("lft", debugFont, Brushes.Black, bThree.X + 5, bThree.Y + 5);
                graphics.DrawString("top", debugFont, Brushes.Black, bFour.X + 3, bFour.Y + 5);
                graphics.DrawString("shape: " + InstanceManager.getRotate().getCurShape(), debugFont, Brushes.White, new Point(0, lastY * 18));
                for (int i = 0; i < 4; i++)
                {
                    graphics.DrawImage(BlockUtils.SetOpacity(BlockUtils.translateColorToImage(currentColor, true), 0.2F), InstanceManager.getRotateCheck().getRotationBlocks()[i]);
                }
            }
        }