// // Method: NewGame(); // private void NewGame() { TetrixState = TetrixStateEnum.StoppedState; m_objEngine = new Engine(ROWS, COLS); m_intShape = m_objEngine.GetShape(); m_intShapeHeight = m_objEngine.ShapeHeight; m_intShapeWidth = m_objEngine.ShapeWidth; timer1.Interval = TIMER_START; m_intScore = 0; m_intLevel = 1; m_intRowCount = 0; m_intShapeCount = 0; Refresh(); }
// // Method: timer tick handler // private void timer1_Tick(object sender, System.EventArgs e) { // stop timer timer1.Stop(); // shape changed? if (m_objEngine.TimerMove() == true) { // shrink well while (m_objEngine.ShrinkWell(false, INDEX_BLACK) == true) { // paint black this.Refresh(); System.Threading.Thread.Sleep(100); // paint dark gray m_objEngine.ShrinkWell(false, INDEX_DK_GRAY); this.Refresh(); System.Threading.Thread.Sleep(100); // paint light gray m_objEngine.ShrinkWell(false, INDEX_LT_GRAY); this.Refresh(); System.Threading.Thread.Sleep(100); // paint white m_objEngine.ShrinkWell(false, INDEX_WHITE); this.Refresh(); System.Threading.Thread.Sleep(100); // remove line m_objEngine.ShrinkWell(true, INDEX_NULL); // keep count of rows ++m_intRowCount; // give points m_intScore += 100 * m_intLevel; } // get new shape matrix m_intShape = m_objEngine.GetShape(); m_intShapeHeight = m_objEngine.ShapeHeight; m_intShapeWidth = m_objEngine.ShapeWidth; // give score update m_intScore += 10 * m_intLevel; // count new shape if ((++m_intShapeCount % SHAPES_PER_LEVEL) == 0) { ++m_intLevel; if (timer1.Interval > TIMER_MINIMUM) { timer1.Interval -= TIMER_DELTA; } } } // engine still active? if (m_objEngine.Active == false) { GameOver(); return; } // restart timer timer1.Start(); // repaint screen this.Refresh(); }