//исцртува нова форма public void AddPiece() { switch (next) { case 0: currentShape = new OPiece(NUMBER_COLUMNS); shade = new OPiece(NUMBER_COLUMNS); break; case 1: currentShape = new IPiece(NUMBER_COLUMNS); shade = new OPiece(NUMBER_COLUMNS); break; case 2: currentShape = new TPiece(NUMBER_COLUMNS); shade = new OPiece(NUMBER_COLUMNS); break; case 3: currentShape = new JPiece(NUMBER_COLUMNS); shade = new OPiece(NUMBER_COLUMNS); break; case 4: currentShape = new LPiece(NUMBER_COLUMNS); shade = new OPiece(NUMBER_COLUMNS); break; case 5: currentShape = new ZPiece(NUMBER_COLUMNS); shade = new OPiece(NUMBER_COLUMNS); break; case 6: currentShape = new SPiece(NUMBER_COLUMNS); shade = new OPiece(NUMBER_COLUMNS); break; } foreach (IndexKeeper index in currentShape.positions) { matrix[index.X, index.Y].Color = currentShape.color; matrix[index.X, index.Y].taken = true; } Draw(); Random random = new Random(); next = random.Next(7); DrawNext(next); }
//ја исцртува следната форма public void DrawNext(int i) { Shape shape = null; switch (i) { case 0: shape = new OPiece(6); break; case 1: shape = new IPiece(6); break; case 2: shape = new TPiece(6); break; case 3: shape = new JPiece(6); break; case 4: shape = new LPiece(6); break; case 5: shape = new ZPiece(6); break; case 6: shape = new SPiece(6); break; } g2.Clear(BACKGROUND_COLOR); Brush brush = new SolidBrush(shape.color); foreach (IndexKeeper index in shape.positions) { g2.FillRectangle(brush, (float)(index.Y * 17 + 0.5), (float)((index.X + 2) * 17 - 0.5), 16, 16); } brush.Dispose(); }