private void Form1_KeyDown(object sender, KeyEventArgs e) { if (!game.isRuning) { return; } switch (e.KeyCode) { case Keys.A: game.MoveLeft(); picBoard.Refresh(); break; case Keys.D: game.MoveRight(); picBoard.Refresh(); break; case Keys.W: game.Rotate(); picBoard.Refresh(); break; case Keys.S: game.MoveDown(); picBoard.Refresh(); break; default: break; } }
//오른쪽으로 이동한 곳에 도형 다시 그리기 private void MoveRight() { if (game.MoveRight()) { Region rg = MakeRegion(-1, 0); Invalidate(rg); } }
private void frmTetris_KeyUp(object sender, KeyEventArgs e) { if (!pause) { switch (e.KeyCode) { case Keys.Up: game.Rotate(); break; case Keys.Down: game.MoveDown(); break; case Keys.Left: game.MoveLeft(); break; case Keys.Right: game.MoveRight(); break; case Keys.Space: game.PlaceDown(); break; case Keys.R: if (gameIsOver) { game = new Game(); game.addObserver(this); gameIsOver = false; RefreshPictureBoxes(); tmrMove.Enabled = true; } break; case Keys.C: game.SwitchBank(); break; } } if (e.KeyCode == Keys.P) { pause = !pause; tmrMove.Enabled = !pause; //code for a menu } }