/// <summary> /// Rotates /// </summary> public void Rotate() { if (IsRunning) { Tetris tetris = m_tetris; ushort matrix = tetris.GetMatrix(); if (!HitTest(matrix, 0, 0)) { tetris.MatrixTransform(); } RenderCurrentTetris(0, 0); } }
/// <summary> /// Moves right. /// </summary> public void MoveRight() { if (IsRunning) { Tetris tetris = m_tetris; ushort matrix = tetris.GetMatrix(); if (HitTest(matrix, 0, 1)) { RenderCurrentTetris(0, 0); } else { RenderCurrentTetris(0, 1); } } }
static TetrisController() { /* 0100 0000 0100 1111 0100 0000 0100 0000 */ TetrisIGroup = new CircularQueue<ushort>(new ushort[] { 17476, 3840 }); /* 0010 0100 0011 0000 0010 0111 0010 0111 0110 0000 0010 0001 0000 0000 0000 0000 */ TetrisJGroup = new CircularQueue<ushort>(new ushort[] { 8800, 18176, 12832, 1808 }); /* 0100 0000 1100 0010 0100 1110 0100 1110 0110 1000 0100 0000 0000 0000 0000 0000 */ TetrisLGroup = new CircularQueue<ushort>(new ushort[] { 17504, 3712, 50240, 11776 }); /* 0000 0110 0110 0000 */ TetrisOGroup = new CircularQueue<ushort>(new ushort[] { 1632 }); /* 0100 0011 0110 0110 0010 0000 0000 0000 */ TetrisSGroup = new CircularQueue<ushort>(new ushort[] { 17952, 13824 }); /* 0010 0010 0000 0010 0111 0011 0111 0110 0000 0010 0010 0010 0000 0000 0000 0000 */ TetrisTGroup = new CircularQueue<ushort>(new ushort[] { 9984, 8992, 1824, 9760 }); /* 0010 0110 0110 0011 0100 0000 0000 0000 */ TetrisZGroup = new CircularQueue<ushort>(new ushort[] { 9792, 25344 }); TetrisI = new Tetris(TetrisIGroup, Brushes.Red); TetrisJ = new Tetris(TetrisJGroup, Brushes.Cyan); TetrisL = new Tetris(TetrisLGroup, Brushes.Yellow); TetrisO = new Tetris(TetrisOGroup, Brushes.Blue); TetrisS = new Tetris(TetrisSGroup, Brushes.Green); TetrisT = new Tetris(TetrisTGroup, Brushes.Orange); TetrisZ = new Tetris(TetrisZGroup, Brushes.Purple); Tetris = new List<Tetris>(new Tetris[] { TetrisI, TetrisJ, TetrisL, TetrisO, TetrisS, TetrisT, TetrisZ }); }
private void CreateNextTetris() { TetrisBlock[,] blocks = m_blocks; m_tetris = (m_nextTetris != null ? m_nextTetris : Tetris[Rand.Next(0, 6)]); m_nextTetris = Tetris[Rand.Next(0, 6)]; m_row = TETRIS_START_ROW; m_col = TETRIS_START_COLUMN; DrawNextTetris(); }
static TetrisController() { /* * 0100 0000 * 0100 1111 * 0100 0000 * 0100 0000 */ TetrisIGroup = new CircularQueue <ushort>(new ushort[] { 17476, 3840 }); /* * 0010 0100 0011 0000 * 0010 0111 0010 0111 * 0110 0000 0010 0001 * 0000 0000 0000 0000 */ TetrisJGroup = new CircularQueue <ushort>(new ushort[] { 8800, 18176, 12832, 1808 }); /* * 0100 0000 1100 0010 * 0100 1110 0100 1110 * 0110 1000 0100 0000 * 0000 0000 0000 0000 */ TetrisLGroup = new CircularQueue <ushort>(new ushort[] { 17504, 3712, 50240, 11776 }); /* * 0000 * 0110 * 0110 * 0000 */ TetrisOGroup = new CircularQueue <ushort>(new ushort[] { 1632 }); /* * 0100 0011 * 0110 0110 * 0010 0000 * 0000 0000 */ TetrisSGroup = new CircularQueue <ushort>(new ushort[] { 17952, 13824 }); /* * 0010 0010 0000 0010 * 0111 0011 0111 0110 * 0000 0010 0010 0010 * 0000 0000 0000 0000 */ TetrisTGroup = new CircularQueue <ushort>(new ushort[] { 9984, 8992, 1824, 9760 }); /* * 0010 0110 * 0110 0011 * 0100 0000 * 0000 0000 */ TetrisZGroup = new CircularQueue <ushort>(new ushort[] { 9792, 25344 }); TetrisI = new Tetris(TetrisIGroup, Brushes.Red); TetrisJ = new Tetris(TetrisJGroup, Brushes.Cyan); TetrisL = new Tetris(TetrisLGroup, Brushes.Yellow); TetrisO = new Tetris(TetrisOGroup, Brushes.Blue); TetrisS = new Tetris(TetrisSGroup, Brushes.Green); TetrisT = new Tetris(TetrisTGroup, Brushes.Orange); TetrisZ = new Tetris(TetrisZGroup, Brushes.Purple); Tetris = new List <Tetris>(new Tetris[] { TetrisI, TetrisJ, TetrisL, TetrisO, TetrisS, TetrisT, TetrisZ }); }