public void Draw(Graphics graphics, Brush currentColor) { tOne = new Rectangle(plyX, plyY, 32, 32); // player controlled rect tTwo = new Rectangle(tTwo.X, plyY + InstanceManager.getRotate().getr2(), 32, 32); tThree = new Rectangle(tThree.X, plyY - InstanceManager.getRotate().getl2(), 32, 32); tFour = new Rectangle(tFour.X, plyY - InstanceManager.getRotate().gett1(), 32, 32); //draw player rectangles Image currentImage = BlockUtils.SetOpacity(BlockUtils.translateColorToImage(currentColor, true), currentOpacity); graphics.DrawImage(currentImage, tOne); graphics.DrawImage(currentImage, tTwo); graphics.DrawImage(currentImage, tThree); graphics.DrawImage(currentImage, tFour); if (currentOpacity >= 0.8F) { addOpacity = false; } if (currentOpacity > 0.4F && !addOpacity) { currentOpacity -= 0.01F; } if (addOpacity) { currentOpacity += 0.01F; } if (currentOpacity <= 0.4F) { addOpacity = true; } }
/// <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]); } } }